Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-3723

Aggregate Functions and scalar expressions shouldn't be mixed in select

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Critical
    • Resolution: Won't Fix
    • 1.0.1
    • None
    • Table SQL / API
    • None

    Description

      When we type

      select deptno, name, max(age) from dept group by deptno;

      in calcite or Oracle, it will complain

      Expression 'NAME' is not being grouped

      or

      Column 'dept.name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

      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.

      def select(exprs: Expression*)
      def agg(aggs: Aggregation*)
      ....
      
      tbl.groupBy('deptno)
         .agg('age.max, 'age.min)
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            yijieshen Yijie Shen
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: