Eliaaazzz commented on code in PR #17380:
URL: https://github.com/apache/iotdb/pull/17380#discussion_r3004830477


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java:
##########
@@ -2718,6 +2724,69 @@ private Analysis.GroupingSetAnalysis analyzeGroupBy(
       return result;
     }
 
+    private Analysis.GroupingSetAnalysis analyzeGroupByAll(
+        QuerySpecification node, Scope scope, List<Expression> 
outputExpressions) {
+      ImmutableList.Builder<List<Set<FieldId>>> sets = ImmutableList.builder();
+      ImmutableList.Builder<Expression> complexExpressions = 
ImmutableList.builder();
+      ImmutableList.Builder<Expression> groupingExpressions = 
ImmutableList.builder();
+      FunctionCall gapFillColumn = null;
+      ImmutableList.Builder<Expression> gapFillGroupingExpressions = 
ImmutableList.builder();
+
+      for (Expression outputExpression : outputExpressions) {
+        List<FunctionCall> aggregates =
+            extractAggregateFunctions(ImmutableList.of(outputExpression));
+        List<FunctionCall> windowFunctions =
+            extractWindowFunctions(ImmutableList.of(outputExpression));
+        if (!aggregates.isEmpty() || !windowFunctions.isEmpty()) {
+          continue;
+        }

Review Comment:
   Fixed in ed29a53. Now for expressions containing both aggregate and 
non-aggregate parts, extract column references outside aggregate/window 
function boundaries instead of skipping the whole expression.
   
   For example, `SELECT s1 + avg(s2) FROM t1 GROUP BY ALL` is now equivalent to 
`GROUP BY s1`.
   
   Implementation: added `extractNonAggregateColumnReferences` in 
`ExpressionTreeUtils` — it walks the expression tree but stops recursing into 
aggregate/window function subtrees, collecting only the 
`Identifier`/`DereferenceExpression` nodes outside those boundaries.
   
   Also added corresponding unit tests and integration tests to cover this case.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to