(improvement)(headless) Determine if there are any 'GROUP BY' fields that require compatibility with self-queries in WITH clauses. (#1734)

This commit is contained in:
lexluo09
2024-09-29 11:28:31 +08:00
committed by GitHub
parent 75f0e4d106
commit 5a163936a8
2 changed files with 20 additions and 6 deletions

View File

@@ -536,12 +536,17 @@ public class SqlSelectHelper {
if (!(selectStatement instanceof PlainSelect)) {
return false;
}
PlainSelect plainSelect = (PlainSelect) selectStatement;
GroupByElement groupBy = plainSelect.getGroupBy();
if (Objects.nonNull(groupBy)) {
GroupByVisitor replaceVisitor = new GroupByVisitor();
groupBy.accept(replaceVisitor);
return replaceVisitor.isHasAggregateFunction();
List<PlainSelect> withItem = getWithItem(selectStatement);
withItem.add((PlainSelect) selectStatement);
for (PlainSelect plainSelect : withItem) {
GroupByElement groupBy = plainSelect.getGroupBy();
if (Objects.nonNull(groupBy)) {
GroupByVisitor replaceVisitor = new GroupByVisitor();
groupBy.accept(replaceVisitor);
return replaceVisitor.isHasAggregateFunction();
}
}
return false;
}