mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 04:57:28 +00:00
(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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user