gortiz commented on code in PR #14448: URL: https://github.com/apache/pinot/pull/14448#discussion_r1848089067
########## pinot-query-planner/src/test/resources/queries/LiteralEvaluationPlans.json: ########## @@ -257,6 +257,55 @@ "description": "select non-exist literal function", "sql": "EXPLAIN PLAN FOR Select nonExistFun(1,2) FROM a", "expectedException": ".*No match found for function signature nonExistFun.*" + }, + { + "description": "Literal only filter on subquery is simplified", + "sql": "EXPLAIN PLAN FOR SELECT * FROM (SELECT CASE WHEN col1 = 'abc123' THEN 'val1' ELSE 'val2' END as val FROM a) WHERE val in ('val1', 'val2')", + "output": [ + "Execution Plan", + "\nLogicalProject(val=[CASE(=($0, _UTF-8'abc123'), _UTF-8'val1', _UTF-8'val2')])", + "\n LogicalTableScan(table=[[default, a]])", + "\n" + ] + } + ] + }, + "literal_planning_cte_tests": { + "comment": "Tests for CTEs involving literal only filters. The SQL parser cannot get rid of expressions that cross CTEs, so this is useful to check that the expressions are simplified in the logical plan.", + "queries": [ + { + "description": "Simple filter on constants is simplified", + "sql": "EXPLAIN PLAN FOR WITH CTE_B AS ( SELECT 'a' AS val FROM a GROUP BY val ) SELECT 1 FROM CTE_B WHERE val >= 'b'", + "output": [ + "Execution Plan", + "\nLogicalValues(tuples=[[]])", + "\n" + ] + }, + { + "description": "AND filter on constants is simplified", + "sql": "EXPLAIN PLAN FOR WITH CTE_B AS (SELECT 1692057600000 AS __ts FROM a GROUP BY __ts) SELECT 1692057600000 AS __ts FROM CTE_B WHERE __ts >= 1692057600000 AND __ts < 1693267200000 GROUP BY __ts", + "output": [ + "Execution Plan", + "\nLogicalProject(__ts=[1692057600000:BIGINT])", + "\n PinotLogicalAggregate(group=[{0}])", + "\n PinotLogicalExchange(distribution=[hash[0]])", + "\n PinotLogicalAggregate(group=[{0}])", + "\n LogicalProject(__ts=[1692057600000:BIGINT])", + "\n LogicalTableScan(table=[[default, a]])", + "\n" + ] Review Comment: maybe it is not very useful to dedicate resources to this but... isn't this something we should be able to optimize? -- 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