mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-15 06:27:21 +00:00
(improvement)(Headless) remove mysql function name backticks (#909)
This commit is contained in:
@@ -89,12 +89,7 @@ public abstract class SemanticNode {
|
||||
}
|
||||
|
||||
public static String getSql(SqlNode sqlNode, EngineType engineType) {
|
||||
SemanticSqlDialect sqlDialect = SqlDialectFactory.getSqlDialect(engineType);
|
||||
SqlWriterConfig config = SqlPrettyWriter.config().withDialect(sqlDialect)
|
||||
.withKeywordsLowerCase(false).withClauseEndsLine(true).withAlwaysUseParentheses(false)
|
||||
.withSelectListItemsOnSeparateLines(false).withUpdateSetListNewline(false).withIndentation(0);
|
||||
|
||||
UnaryOperator<SqlWriterConfig> sqlWriterConfigUnaryOperator = (c) -> config;
|
||||
UnaryOperator<SqlWriterConfig> sqlWriterConfigUnaryOperator = (c) -> getSqlWriterConfig(engineType);
|
||||
return sqlNode.toSqlString(sqlWriterConfigUnaryOperator).getSql();
|
||||
}
|
||||
|
||||
@@ -167,6 +162,18 @@ public abstract class SemanticNode {
|
||||
return sqlNode;
|
||||
}
|
||||
|
||||
private static SqlWriterConfig getSqlWriterConfig(EngineType engineType) {
|
||||
SemanticSqlDialect sqlDialect = SqlDialectFactory.getSqlDialect(engineType);
|
||||
SqlWriterConfig config = SqlPrettyWriter.config().withDialect(sqlDialect)
|
||||
.withKeywordsLowerCase(false).withClauseEndsLine(true).withAlwaysUseParentheses(false)
|
||||
.withSelectListItemsOnSeparateLines(false).withUpdateSetListNewline(false).withIndentation(0);
|
||||
if (EngineType.MYSQL.equals(engineType)) {
|
||||
//no backticks around function name
|
||||
config = config.withQuoteAllIdentifiers(false);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
private static void sqlVisit(SqlNode sqlNode, Map<String, Object> parseInfo) {
|
||||
SqlKind kind = sqlNode.getKind();
|
||||
switch (kind) {
|
||||
|
||||
Reference in New Issue
Block a user