-
Notifications
You must be signed in to change notification settings - Fork 605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(sql): remove constants in order_by
calls during select merging
#10475
Merged
gforsyth
merged 1 commit into
ibis-project:main
from
cpcloud:remove-constants-in-order-by
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
`t0`.`a`, | ||
9 AS `i`, | ||
'foo' AS `s` | ||
FROM `test` AS `t0` | ||
ORDER BY | ||
`t0`.`a` ASC NULLS LAST |
7 changes: 7 additions & 0 deletions
7
.../backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
"t0"."a" AS "a", | ||
9 AS "i", | ||
'foo' AS "s" | ||
FROM "test" AS "t0" | ||
ORDER BY | ||
"t0"."a" ASC |
7 changes: 7 additions & 0 deletions
7
.../backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/databricks/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,7 @@ | ||
SELECT | ||
`t0`.`a`, | ||
9 AS `i`, | ||
'foo' AS `s` | ||
FROM `test` AS `t0` | ||
ORDER BY | ||
`t0`.`a` ASC NULLS LAST |
7 changes: 7 additions & 0 deletions
7
.../backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
"t0"."a", | ||
9 AS "i", | ||
'foo' AS "s" | ||
FROM "test" AS "t0" | ||
ORDER BY | ||
"t0"."a" ASC |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
"t0"."a", | ||
9 AS "i", | ||
'foo' AS "s" | ||
FROM "test" AS "t0" | ||
ORDER BY | ||
"t0"."a" ASC |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
"t0"."a", | ||
9 AS "i", | ||
'foo' AS "s" | ||
FROM "test" AS "t0" | ||
ORDER BY | ||
"t0"."a" ASC |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
"t0"."a", | ||
9 AS "i", | ||
'foo' AS "s" | ||
FROM "test" AS "t0" | ||
ORDER BY | ||
"t0"."a" ASC |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
`t0`.`a`, | ||
9 AS `i`, | ||
'foo' AS `s` | ||
FROM `test` AS `t0` | ||
ORDER BY | ||
`t0`.`a` ASC NULLS LAST |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
`t0`.`a`, | ||
9 AS `i`, | ||
'foo' AS `s` | ||
FROM `test` AS `t0` | ||
ORDER BY | ||
`t0`.`a` ASC |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
[t0].[a], | ||
9 AS [i], | ||
'foo' AS [s] | ||
FROM [test] AS [t0] | ||
ORDER BY | ||
CASE WHEN [t0].[a] IS NULL THEN 1 ELSE 0 END, [t0].[a] ASC |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
`t0`.`a`, | ||
9 AS `i`, | ||
'foo' AS `s` | ||
FROM `test` AS `t0` | ||
ORDER BY | ||
CASE WHEN `t0`.`a` IS NULL THEN 1 ELSE 0 END, `t0`.`a` ASC |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
"t0"."a", | ||
9 AS "i", | ||
'foo' AS "s" | ||
FROM "test" "t0" | ||
ORDER BY | ||
"t0"."a" ASC |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/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,7 @@ | ||
SELECT | ||
"t0"."a", | ||
9 AS "i", | ||
'foo' AS "s" | ||
FROM "test" AS "t0" | ||
ORDER BY | ||
"t0"."a" ASC |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/pyspark/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,7 @@ | ||
SELECT | ||
`t0`.`a`, | ||
9 AS `i`, | ||
'foo' AS `s` | ||
FROM `test` AS `t0` | ||
ORDER BY | ||
`t0`.`a` ASC NULLS LAST |
7 changes: 7 additions & 0 deletions
7
.../backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/risingwave/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,7 @@ | ||
SELECT | ||
"t0"."a", | ||
9 AS "i", | ||
'foo' AS "s" | ||
FROM "test" AS "t0" | ||
ORDER BY | ||
"t0"."a" ASC |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/snowflake/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,7 @@ | ||
SELECT | ||
"t0"."a", | ||
9 AS "i", | ||
'foo' AS "s" | ||
FROM "test" AS "t0" | ||
ORDER BY | ||
"t0"."a" ASC |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/sqlite/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,7 @@ | ||
SELECT | ||
"t0"."a", | ||
9 AS "i", | ||
'foo' AS "s" | ||
FROM "test" AS "t0" | ||
ORDER BY | ||
"t0"."a" ASC NULLS LAST |
7 changes: 7 additions & 0 deletions
7
ibis/backends/tests/snapshots/test_sql/test_order_by_no_deference_literals/trino/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,7 @@ | ||
SELECT | ||
"t0"."a", | ||
9 AS "i", | ||
'foo' AS "s" | ||
FROM "test" AS "t0" | ||
ORDER BY | ||
"t0"."a" ASC |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove all expressions which are constant across the relation? I am thinking of all pure scalar nodes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? We can't just start deleting anything that's a literal scalar. Expressions like
are 100% valid and useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only mean the order by expressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because it's possible to write things like 1 if x else 0, and use them in sort keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expr = 1 if x else 0
right, though we can identify that as well, like its.relations
attribute is not emptyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, it doesn't block this PR.