mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
Merge branch 'tencentmusic:master' into aibi
This commit is contained in:
@@ -80,6 +80,9 @@ public class Configuration {
|
|||||||
.setQuoting(Quoting.SINGLE_QUOTE).setQuotedCasing(Casing.TO_UPPER)
|
.setQuoting(Quoting.SINGLE_QUOTE).setQuotedCasing(Casing.TO_UPPER)
|
||||||
.setUnquotedCasing(Casing.TO_UPPER).setConformance(sqlDialect.getConformance())
|
.setUnquotedCasing(Casing.TO_UPPER).setConformance(sqlDialect.getConformance())
|
||||||
.setLex(Lex.BIG_QUERY);
|
.setLex(Lex.BIG_QUERY);
|
||||||
|
if (EngineType.HANADB.equals(engineType)) {
|
||||||
|
parserConfig = parserConfig.setQuoting(Quoting.DOUBLE_QUOTE);
|
||||||
|
}
|
||||||
parserConfig = parserConfig.setQuotedCasing(Casing.UNCHANGED);
|
parserConfig = parserConfig.setQuotedCasing(Casing.UNCHANGED);
|
||||||
parserConfig = parserConfig.setUnquotedCasing(Casing.UNCHANGED);
|
parserConfig = parserConfig.setUnquotedCasing(Casing.UNCHANGED);
|
||||||
return parserConfig.build();
|
return parserConfig.build();
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ public class SqlDialectFactory {
|
|||||||
.withDatabaseProduct(DatabaseProduct.BIG_QUERY).withLiteralQuoteString("'")
|
.withDatabaseProduct(DatabaseProduct.BIG_QUERY).withLiteralQuoteString("'")
|
||||||
.withLiteralEscapedQuoteString("''").withUnquotedCasing(Casing.UNCHANGED)
|
.withLiteralEscapedQuoteString("''").withUnquotedCasing(Casing.UNCHANGED)
|
||||||
.withQuotedCasing(Casing.UNCHANGED).withCaseSensitive(false);
|
.withQuotedCasing(Casing.UNCHANGED).withCaseSensitive(false);
|
||||||
|
public static final Context HANADB_CONTEXT = SqlDialect.EMPTY_CONTEXT
|
||||||
|
.withDatabaseProduct(DatabaseProduct.BIG_QUERY).withLiteralQuoteString("'")
|
||||||
|
.withIdentifierQuoteString("\"").withLiteralEscapedQuoteString("''").withUnquotedCasing(Casing.UNCHANGED)
|
||||||
|
.withQuotedCasing(Casing.UNCHANGED).withCaseSensitive(true);
|
||||||
private static Map<EngineType, SemanticSqlDialect> sqlDialectMap;
|
private static Map<EngineType, SemanticSqlDialect> sqlDialectMap;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -29,6 +33,7 @@ public class SqlDialectFactory {
|
|||||||
sqlDialectMap.put(EngineType.MYSQL, new SemanticSqlDialect(DEFAULT_CONTEXT));
|
sqlDialectMap.put(EngineType.MYSQL, new SemanticSqlDialect(DEFAULT_CONTEXT));
|
||||||
sqlDialectMap.put(EngineType.H2, new SemanticSqlDialect(DEFAULT_CONTEXT));
|
sqlDialectMap.put(EngineType.H2, new SemanticSqlDialect(DEFAULT_CONTEXT));
|
||||||
sqlDialectMap.put(EngineType.POSTGRESQL, new SemanticSqlDialect(POSTGRESQL_CONTEXT));
|
sqlDialectMap.put(EngineType.POSTGRESQL, new SemanticSqlDialect(POSTGRESQL_CONTEXT));
|
||||||
|
sqlDialectMap.put(EngineType.HANADB, new SemanticSqlDialect(HANADB_CONTEXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SemanticSqlDialect getSqlDialect(EngineType engineType) {
|
public static SemanticSqlDialect getSqlDialect(EngineType engineType) {
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ public enum EngineType {
|
|||||||
H2(5, "h2"),
|
H2(5, "h2"),
|
||||||
POSTGRESQL(6, "postgresql"),
|
POSTGRESQL(6, "postgresql"),
|
||||||
OTHER(7, "other"),
|
OTHER(7, "other"),
|
||||||
DUCKDB(8, "duckdb");
|
DUCKDB(8, "duckdb"),
|
||||||
|
HANADB(9, "hanadb");
|
||||||
|
|
||||||
private Integer code;
|
private Integer code;
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public class DbAdaptorFactory {
|
|||||||
dbAdaptorMap.put(EngineType.POSTGRESQL.getName(), new PostgresqlAdaptor());
|
dbAdaptorMap.put(EngineType.POSTGRESQL.getName(), new PostgresqlAdaptor());
|
||||||
dbAdaptorMap.put(EngineType.OTHER.getName(), new DefaultDbAdaptor());
|
dbAdaptorMap.put(EngineType.OTHER.getName(), new DefaultDbAdaptor());
|
||||||
dbAdaptorMap.put(EngineType.DUCKDB.getName(), new DuckdbAdaptor());
|
dbAdaptorMap.put(EngineType.DUCKDB.getName(), new DuckdbAdaptor());
|
||||||
|
dbAdaptorMap.put(EngineType.HANADB.getName(), new HanadbAdaptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DbAdaptor getEngineAdaptor(String engineType) {
|
public static DbAdaptor getEngineAdaptor(String engineType) {
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.tencent.supersonic.headless.core.adaptor.db;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class HanadbAdaptor extends DefaultDbAdaptor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String rewriteSql(String sql) {
|
||||||
|
return sql.replaceAll("`", "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ public class DbParameterFactory {
|
|||||||
parametersBuilder.put(EngineType.CLICKHOUSE.getName(), new ClickHouseParametersBuilder());
|
parametersBuilder.put(EngineType.CLICKHOUSE.getName(), new ClickHouseParametersBuilder());
|
||||||
parametersBuilder.put(EngineType.MYSQL.getName(), new MysqlParametersBuilder());
|
parametersBuilder.put(EngineType.MYSQL.getName(), new MysqlParametersBuilder());
|
||||||
parametersBuilder.put(EngineType.POSTGRESQL.getName(), new PostgresqlParametersBuilder());
|
parametersBuilder.put(EngineType.POSTGRESQL.getName(), new PostgresqlParametersBuilder());
|
||||||
|
parametersBuilder.put(EngineType.HANADB.getName(), new HanadbParametersBuilder());
|
||||||
parametersBuilder.put(EngineType.OTHER.getName(), new OtherParametersBuilder());
|
parametersBuilder.put(EngineType.OTHER.getName(), new OtherParametersBuilder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.tencent.supersonic.headless.server.pojo;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class HanadbParametersBuilder extends DefaultParametersBuilder {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DatabaseParameter> build() {
|
||||||
|
return super.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user