You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "lincoln lee (Jira)" <ji...@apache.org> on 2021/03/08 06:07:00 UTC

[jira] [Created] (FLINK-21655) Incorrect simplification for coalesce call on a groupingsets' result

lincoln lee created FLINK-21655:
-----------------------------------

             Summary: Incorrect simplification for coalesce call on a groupingsets' result
                 Key: FLINK-21655
                 URL: https://issues.apache.org/jira/browse/FLINK-21655
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
    Affects Versions: 1.12.2, 1.11.3
            Reporter: lincoln lee
             Fix For: 1.13.0


Currently the planner will do an incorrectly simplification for `coalesce` call on a `groupingsets`'s result, see the following query example:

{code:scala}

val sqlQuery =
 """
 |SELECT
 | a,
 | b,
 | coalesce(c, 'empty'),
 | avg(d)
 |FROM t1
 |GROUP BY GROUPING SETS ((a, b), (a, b, c))
 """.stripMargin

{code}

will generate a wrong plan which lost the `coalesce` call:

{code}

Calc(select=[a, b, c AS EXPR$2, EXPR$3])
+- HashAggregate(isMerge=[true], groupBy=[a, b, c, $e], select=[a, b, c, $e, Final_AVG(sum$0, count$1) AS EXPR$3])
 +- Exchange(distribution=[hash[a, b, c, $e]])
 +- LocalHashAggregate(groupBy=[a, b, c, $e], select=[a, b, c, $e, Partial_AVG(d) AS (sum$0, count$1)])
 +- Expand(projects=[\{a, b, c, d, 0 AS $e}, \{a, b, null AS c, d, 1 AS $e}])
 +- TableSourceScan(table=[[default_catalog, default_database, t1]], fields=[a, b, c, d])

{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)