DonnyZone commented on a change in pull request #1556: [CALCITE-3438] Validator 
should disallow use of the GROUPING function inside a FILTER clause 
URL: https://github.com/apache/calcite/pull/1556#discussion_r347201882
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/sql/validate/AggVisitor.java
 ##########
 @@ -44,6 +44,9 @@
    * or group auxiliary functions (e.g. {@code TUMBLE_START}). */
   protected final boolean group;
   protected final SqlNameMatcher nameMatcher;
+  /** Whether to find grouping functions (i.e., {@code GROUP_ID},
+   * {@code GROUPING_ID}, {@code GROUPING}).*/
+  private boolean grouping = false;
 
 Review comment:
   @julianhyde 
   I noticed that AggVisitor treats grouping functions differently as other 
aggregate functions (`!(operator instanceof SqlAbstractGroupFunction)`).
   It is implemented in 
[CALCITE-2135](https://issues.apache.org/jira/browse/CALCITE-2135).
   By default, it ignores these grouping functions. Meanwhile, Calcite 
validator also deals with the logic specifically in some places. 
   For example,
   ```
   sql("select ^group_id()^ from emp")
   ```
   throws `"GROUP_ID operator may only occur in an aggregate query"`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to