benWize commented on a change in pull request #16200:
URL: https://github.com/apache/beam/pull/16200#discussion_r782616094



##########
File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/AggregateScanConverter.java
##########
@@ -240,18 +244,22 @@ private AggregateCall convertAggCall(
     }
 
     List<Integer> argList = new ArrayList<>();
-    for (ResolvedExpr expr :
-        ((ResolvedAggregateFunctionCall) 
computedColumn.getExpr()).getArgumentList()) {
+    ResolvedAggregateFunctionCall expr = ((ResolvedAggregateFunctionCall) 
computedColumn.getExpr());
+    List<ZetaSQLResolvedNodeKind.ResolvedNodeKind> resolvedNodeKinds =
+        Arrays.asList(RESOLVED_CAST, RESOLVED_COLUMN_REF, 
RESOLVED_GET_STRUCT_FIELD);
+    for (int i = 0; i < expr.getArgumentList().size(); i++) {
       // Throw an error if aggregate function's input isn't either a ColumnRef 
or a cast(ColumnRef).
       // TODO: is there a general way to handle aggregation calls conversion?
-      if (expr.nodeKind() == RESOLVED_CAST
-          || expr.nodeKind() == RESOLVED_COLUMN_REF
-          || expr.nodeKind() == RESOLVED_GET_STRUCT_FIELD) {
+      ZetaSQLResolvedNodeKind.ResolvedNodeKind resolvedNodeKind =
+          expr.getArgumentList().get(i).nodeKind();
+      if (i == 0 && resolvedNodeKinds.contains(resolvedNodeKind)) {

Review comment:
       I added both tests cases and also change the condition to throw an 
exception in the case of a literal as the first argument. Both tests fall in 
this case https://ci-beam.apache.org/job/beam_PreCommit_SQL_Commit/4616/.
   The tests also failed before changing the condition but with a different 
exception




-- 
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