(improvement)(Headless) define the measure without agg funciton by the model (#1864)

This commit is contained in:
jipeli
2024-10-30 22:13:13 +08:00
committed by GitHub
parent 68d5dac14c
commit 858feb9c3c
4 changed files with 36 additions and 6 deletions

View File

@@ -89,4 +89,18 @@ public class SqlMergeWithUtils {
SqlPrettyWriter writer = new SqlPrettyWriter(config);
return writer.format(resultNode);
}
public static boolean hasWith(EngineType engineType, String sql) throws SqlParseException {
SqlParser.Config parserConfig = Configuration.getParserConfig(engineType);
SqlParser parser = SqlParser.create(sql, parserConfig);
SqlNode sqlNode = parser.parseQuery();
SqlNode sqlSelect = sqlNode;
if (sqlNode instanceof SqlOrderBy) {
SqlOrderBy sqlOrderBy = (SqlOrderBy) sqlNode;
sqlSelect = sqlOrderBy.query;
} else if (sqlNode instanceof SqlSelect) {
sqlSelect = (SqlSelect) sqlNode;
}
return sqlSelect instanceof SqlWith;
}
}