[jira] [Created] (FLINK-8782) Rmove count agg if it is generated for sum agg in over window

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (FLINK-8782) Rmove count agg if it is generated for sum agg in over window

Shang Yuanchun (Jira)
Hequn Cheng created FLINK-8782:
----------------------------------

             Summary: Rmove count agg if it is generated for sum agg in over window
                 Key: FLINK-8782
                 URL: https://issues.apache.org/jira/browse/FLINK-8782
             Project: Flink
          Issue Type: Improvement
          Components: Table API & SQL
            Reporter: Hequn Cheng


Currently, sum agg in over window will generate another count agg which is redundant and affect performance. 

For the following sql:
{code:java}
val sqlQuery = "SELECT a, " +
 " SUM(b) OVER (" +
 " PARTITION BY a ORDER BY proctime ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) " +
 "FROM MyTable"{code}
the corresponding {{LogicalProject}} generated by over is:
{code:java}
CASE(>(COUNT($1) OVER (PARTITION BY $0 ORDER BY $5 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW), 0), CAST($SUM0($1) OVER (PARTITION BY $0 ORDER BY $5 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW)):BIGINT, null){code}
count is used to return null if count is zero while this logic is redundant since sum agg function will return null in this case.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)