Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
None
-
None
Description
For example, test in RelToSqlConverterTest:
@Test void testNestWindow() { String query = " SELECT RANK() OVER (ORDER BY \"daily_sales\" DESC) AS \"rank1\" " + "FROM ( SELECT \"product_name\", " + "SUM(\"product_id\") OVER (PARTITION BY \"product_name\") AS \"daily_sales\" " + "FROM \"product\" ) subquery"; String expected0 = "SELECT RANK() OVER (ORDER BY 2 DESC) AS \"$0\"\n" + "FROM \"foodmart\".\"product\""; RuleSet rules = RuleSets.ofList(CoreRules.PROJECT_TO_LOGICAL_PROJECT_AND_WINDOW); sql(query).optimize(rules, null) .ok(expected0); }
Plan:
LogicalWindow(window#0=[window(order by [1 DESC] aggs [RANK()])]) LogicalProject(product_name=[$3], $1=[$15]) LogicalWindow(window#0=[window(partition {3} aggs [SUM($1)])]) JdbcTableScan(table=[[foodmart, product]])
The first window is not correctly converted to SQL
Attachments
Issue Links
- Blocked
-
CALCITE-3876 RelToSqlConverter should not merge a Project that contains a window function that references a window function in input Project
-
- Closed
-
- links to