-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ux): allow window functions in predicates and compile to `QUALIF…
…Y` where possible (#9787)
- Loading branch information
Showing
28 changed files
with
390 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...tests/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/bigquery/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SELECT | ||
* | ||
FROM ( | ||
SELECT | ||
`t0`.`x`, | ||
SUM(`t0`.`x`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS `y` | ||
FROM `t` AS `t0` | ||
) AS `t1` | ||
WHERE | ||
`t1`.`y` <= 37 | ||
QUALIFY | ||
AVG(`t1`.`x`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) IS NOT NULL |
12 changes: 12 additions & 0 deletions
12
...sts/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/clickhouse/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SELECT | ||
* | ||
FROM ( | ||
SELECT | ||
"t0"."x" AS "x", | ||
SUM("t0"."x") OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS "y" | ||
FROM "t" AS "t0" | ||
) AS "t1" | ||
WHERE | ||
"t1"."y" <= 37 | ||
QUALIFY | ||
isNotNull(AVG("t1"."x") OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)) |
19 changes: 19 additions & 0 deletions
19
...sts/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/datafusion/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
SELECT | ||
"x", | ||
"y" | ||
FROM ( | ||
SELECT | ||
"t1"."x", | ||
"t1"."y", | ||
AVG("t1"."x") OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS _w | ||
FROM ( | ||
SELECT | ||
"t0"."x", | ||
SUM("t0"."x") OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS "y" | ||
FROM "t" AS "t0" | ||
) AS "t1" | ||
WHERE | ||
"t1"."y" <= 37 | ||
) AS _t | ||
WHERE | ||
_w IS NOT NULL |
19 changes: 19 additions & 0 deletions
19
...ds/tests/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/druid/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
SELECT | ||
"x", | ||
"y" | ||
FROM ( | ||
SELECT | ||
"t1"."x", | ||
"t1"."y", | ||
AVG("t1"."x") OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS _w | ||
FROM ( | ||
SELECT | ||
"t0"."x", | ||
SUM("t0"."x") OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS "y" | ||
FROM "t" AS "t0" | ||
) AS "t1" | ||
WHERE | ||
"t1"."y" <= 37 | ||
) AS _t | ||
WHERE | ||
_w IS NOT NULL |
12 changes: 12 additions & 0 deletions
12
...s/tests/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/duckdb/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SELECT | ||
* | ||
FROM ( | ||
SELECT | ||
"t0"."x", | ||
SUM("t0"."x") OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS "y" | ||
FROM "t" AS "t0" | ||
) AS "t1" | ||
WHERE | ||
"t1"."y" <= 37 | ||
QUALIFY | ||
AVG("t1"."x") OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) IS NOT NULL |
19 changes: 19 additions & 0 deletions
19
...s/tests/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/exasol/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
SELECT | ||
"x", | ||
"y" | ||
FROM ( | ||
SELECT | ||
"t1"."x", | ||
"t1"."y", | ||
AVG("t1"."x") OVER (ORDER BY NULL ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS _w | ||
FROM ( | ||
SELECT | ||
"t0"."x", | ||
SUM("t0"."x") OVER (ORDER BY NULL ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS "y" | ||
FROM "t" AS "t0" | ||
) AS "t1" | ||
WHERE | ||
"t1"."y" <= 37 | ||
) AS _t | ||
WHERE | ||
_w IS NOT NULL |
13 changes: 13 additions & 0 deletions
13
...ds/tests/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/flink/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
SELECT | ||
`t1`.`x`, | ||
`t1`.`y` | ||
FROM ( | ||
SELECT | ||
`t0`.`x`, | ||
SUM(`t0`.`x`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS `y` | ||
FROM `t` AS `t0` | ||
) AS `t1` | ||
WHERE | ||
`t1`.`y` <= 37 | ||
QUALIFY | ||
AVG(`t1`.`x`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) IS NOT NULL |
19 changes: 19 additions & 0 deletions
19
...s/tests/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/impala/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
SELECT | ||
`x`, | ||
`y` | ||
FROM ( | ||
SELECT | ||
`t1`.`x`, | ||
`t1`.`y`, | ||
AVG(`t1`.`x`) OVER (ORDER BY NULL ASC) AS _w | ||
FROM ( | ||
SELECT | ||
`t0`.`x`, | ||
SUM(`t0`.`x`) OVER (ORDER BY NULL ASC) AS `y` | ||
FROM `t` AS `t0` | ||
) AS `t1` | ||
WHERE | ||
`t1`.`y` <= 37 | ||
) AS _t | ||
WHERE | ||
_w IS NOT NULL |
19 changes: 19 additions & 0 deletions
19
...ds/tests/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/mssql/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
SELECT | ||
[x], | ||
[y] | ||
FROM ( | ||
SELECT | ||
[t1].[x] AS [x], | ||
[t1].[y] AS [y], | ||
AVG([t1].[x]) OVER (ORDER BY CASE WHEN [t1].[x] IS NULL THEN 1 ELSE 0 END, [t1].[x] ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS _w | ||
FROM ( | ||
SELECT | ||
[t0].[x], | ||
SUM([t0].[x]) OVER (ORDER BY CASE WHEN [t0].[x] IS NULL THEN 1 ELSE 0 END, [t0].[x] ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS [y] | ||
FROM [t] AS [t0] | ||
) AS [t1] | ||
WHERE | ||
[t1].[y] <= 37 | ||
) AS _t | ||
WHERE | ||
_w IS NOT NULL |
19 changes: 19 additions & 0 deletions
19
...ds/tests/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/mysql/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
SELECT | ||
`x`, | ||
`y` | ||
FROM ( | ||
SELECT | ||
`t1`.`x`, | ||
`t1`.`y`, | ||
AVG(`t1`.`x`) OVER (ORDER BY CASE WHEN NULL IS NULL THEN 1 ELSE 0 END, NULL ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS _w | ||
FROM ( | ||
SELECT | ||
`t0`.`x`, | ||
SUM(`t0`.`x`) OVER (ORDER BY CASE WHEN NULL IS NULL THEN 1 ELSE 0 END, NULL ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS `y` | ||
FROM `t` AS `t0` | ||
) AS `t1` | ||
WHERE | ||
`t1`.`y` <= 37 | ||
) AS _t | ||
WHERE | ||
_w IS NOT NULL |
19 changes: 19 additions & 0 deletions
19
...s/tests/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/oracle/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
SELECT | ||
"x", | ||
"y" | ||
FROM ( | ||
SELECT | ||
"t1"."x", | ||
"t1"."y", | ||
AVG("t1"."x") OVER (ORDER BY NULL ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS _w | ||
FROM ( | ||
SELECT | ||
"t0"."x", | ||
SUM("t0"."x") OVER (ORDER BY NULL ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS "y" | ||
FROM "t" "t0" | ||
) "t1" | ||
WHERE | ||
"t1"."y" <= 37 | ||
) _t | ||
WHERE | ||
_w IS NOT NULL |
19 changes: 19 additions & 0 deletions
19
...tests/snapshots/test_sql/test_mixed_qualified_and_unqualified_predicates/postgres/out.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
SELECT | ||
"x", | ||
"y" | ||
FROM ( | ||
SELECT | ||
"t1"."x", | ||
"t1"."y", | ||
AVG("t1"."x") OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS _w | ||
FROM ( | ||
SELECT | ||
"t0"."x", | ||
SUM("t0"."x") OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS "y" | ||
FROM "t" AS "t0" | ||
) AS "t1" | ||
WHERE | ||
"t1"."y" <= 37 | ||
) AS _t | ||
WHERE | ||
_w IS NOT NULL |
Oops, something went wrong.