fix: 修复 calcite 转 SQL Server CONCAT 异常 #16860

This commit is contained in:
junjun
2025-09-04 17:19:05 +08:00
committed by Junjun
parent 0e181452f0
commit 6eca8d59b1

View File

@@ -13,6 +13,7 @@ import org.apache.calcite.sql.SqlDialect;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.dialect.*;
import org.apache.calcite.sql.parser.SqlParser;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -143,7 +144,11 @@ public abstract class Provider {
}
SqlParser parser = SqlParser.create(sql, SqlParser.Config.DEFAULT.withLex(Lex.JAVA));
SqlNode sqlNode = parser.parseStmt();
return sqlNode.toSqlString(getDialect(value)).toString();
String dialect = sqlNode.toSqlString(getDialect(value)).toString();
if (StringUtils.equalsIgnoreCase(value.getType(), "sqlServer")) {
dialect = dialect.replaceAll("\\[CONCAT]", "CONCAT");
}
return dialect;
} catch (Exception e) {
DEException.throwException(e.getMessage());
}