vvivekiyer commented on code in PR #10248: URL: https://github.com/apache/pinot/pull/10248#discussion_r1116420526
########## pinot-query-planner/src/test/resources/queries/GroupByPlans.json: ########## @@ -91,6 +91,92 @@ "\n LogicalTableScan(table=[[a]])", "\n" ] + }, + { + "description": "SQL hint based group by optimization with select and aggregate column", + "sql": "EXPLAIN PLAN FOR SELECT /*+ SKIP_LEAF_STAGE_GROUP_BY_AGGREGATION */ a.col1, SUM(a.col3) FROM a GROUP BY a.col1", + "output": [ + "Execution Plan", + "\nLogicalAggregate(group=[{0}], EXPR$1=[$SUM0($1)])", + "\n LogicalExchange(distribution=[hash[0]])", + "\n LogicalProject(col1=[$2], col3=[$1])", + "\n LogicalTableScan(table=[[a]])", + "\n" + ] + }, + { + "description": "SQL hint based group by optimization with filter", + "sql": "EXPLAIN PLAN FOR SELECT /*+ SKIP_LEAF_STAGE_GROUP_BY_AGGREGATION */ a.col1, SUM(a.col3) FROM a WHERE a.col3 >= 0 AND a.col2 = 'a' GROUP BY a.col1", + "output": [ + "Execution Plan", + "\nLogicalAggregate(group=[{2}], EXPR$1=[$SUM0($1)])", + "\n LogicalExchange(distribution=[hash[2]])", + "\n LogicalProject(col2=[$0], col3=[$1], col1=[$2])", + "\n LogicalFilter(condition=[AND(>=($1, 0), =($0, 'a'))])", + "\n LogicalTableScan(table=[[a]])", + "\n" + ] + }, + { + "description": "SQL hint based group by optimization count(*) with filter", + "sql": "EXPLAIN PLAN FOR SELECT /*+ SKIP_LEAF_STAGE_GROUP_BY_AGGREGATION */ a.col1, COUNT(*) FROM a WHERE a.col3 >= 0 AND a.col2 = 'a' GROUP BY a.col1", + "notes": "TODO: Needs follow up. Project should only keep a.col1 since the other columns are pushed to the filter, but it currently keeps them all", + "output": [ + "Execution Plan", + "\nLogicalAggregate(group=[{2}], EXPR$1=[COUNT()])", + "\n LogicalExchange(distribution=[hash[2]])", + "\n LogicalProject(col2=[$0], col3=[$1], col1=[$2])", + "\n LogicalFilter(condition=[AND(>=($1, 0), =($0, 'a'))])", + "\n LogicalTableScan(table=[[a]])", + "\n" + ] + }, + { + "description": "SQL hint based group by optimization on 2 columns with filter", + "sql": "EXPLAIN PLAN FOR SELECT /*+ SKIP_LEAF_STAGE_GROUP_BY_AGGREGATION */ a.col2, a.col1, SUM(a.col3) FROM a WHERE a.col3 >= 0 AND a.col1 = 'a' GROUP BY a.col1, a.col2", Review Comment: We have this implicit test where we perform multiple aggregations on a single column (some of the aggregations are in HAVING clause). But added an explicit test as well. -- 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. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org