[ https://issues.apache.org/jira/browse/FLINK-3723?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15235448#comment-15235448 ]
Fabian Hueske commented on FLINK-3723: -------------------------------------- Yes, you are right {{extractAggCalls}} is definitely not straight-forward. In fact, the implementation of {{GroupedTable.select()}} internally pulls the aggregations and expressions on top of aggregated and grouped fields apart and internally applies first an aggregation and a subsequent select on the aggregated results. So it does internally what you are proposing to offer at the API level. The validation check happens in line 468 in the {{catch}} clause. `toRexNode` throws an exception if it refers a non-grouped or non-aggregated field. I think you have a point here. Adding an {{agg}} method might simplify things considerably. However, I don't like the implicit forward of grouping attributes and would prefer to also explicitly define the grouping attributes that should be part of the aggregation result. In any case, we should reach out for more community feedback before starting to work on this features. > Aggregate Functions and scalar expressions shouldn't be mixed in select > ----------------------------------------------------------------------- > > Key: FLINK-3723 > URL: https://issues.apache.org/jira/browse/FLINK-3723 > Project: Flink > Issue Type: Improvement > Components: Table API > Affects Versions: 1.0.1 > Reporter: Yijie Shen > > When we type {code}select deptno, name, max(age) from dept group by > deptno;{code} in calcite or Oracle, it will complain {code}Expression 'NAME' > is not being grouped{code} or {code}Column 'dept.name' is invalid in the > select list because it is not contained in either an aggregate function or > the GROUP BY clause.{code} because of the nondeterministic result. > Therefore, I suggest to separate the current functionality of `select` into > two api, the new `select` only handle scalar expressions, and an `agg` accept > Aggregates. > {code} > def select(exprs: Expression*) > def agg(aggs: Aggregation*) > .... > tbl.groupBy('deptno) > .agg('age.max, 'age.min) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)