-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-53733][SQL] Delay resolveColsLastResort
until all previous UnresolvedAlias
es are resolved
#52471
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
base: master
Are you sure you want to change the base?
[SPARK-53733][SQL] Delay resolveColsLastResort
until all previous UnresolvedAlias
es are resolved
#52471
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
-- Automatically generated by SQLQueryTestSuite | ||
-- !query | ||
DECLARE a = "aa" | ||
-- !query analysis | ||
CreateVariable defaultvalueexpression(aa, "aa"), false | ||
+- ResolvedIdentifier org.apache.spark.sql.catalyst.analysis.FakeSystemCatalog$@xxxxxxxx, session.a | ||
|
||
|
||
-- !query | ||
SELECT 'a', a | ||
-- !query analysis | ||
Project [a AS a#x, variablereference(system.session.a='aa') AS a#x] | ||
+- OneRowRelation | ||
|
||
|
||
-- !query | ||
SELECT 'a' AS a, a | ||
-- !query analysis | ||
Project [a#x, a#x] | ||
+- Project [a AS a#x] | ||
+- OneRowRelation | ||
|
||
|
||
-- !query | ||
SELECT 'a', a FROM VALUES(1) AS t(a) | ||
-- !query analysis | ||
Project [a AS a#x, a#x] | ||
+- SubqueryAlias t | ||
+- LocalRelation [a#x] | ||
|
||
|
||
-- !query | ||
SELECT 'a' AS a, a FROM VALUES(1) AS t(a) | ||
-- !query analysis | ||
Project [a AS a#x, a#x] | ||
+- SubqueryAlias t | ||
+- LocalRelation [a#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1', col1) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [col1#x] | ||
: +- Project [col1 AS col1#x, outer(col1#x)] | ||
: +- OneRowRelation | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT col1 AS col1, col1) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [col1#x] | ||
: +- Project [col1#x, col1#x] | ||
: +- Project [outer(col1#x) AS col1#x] | ||
: +- OneRowRelation | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1' AS col1, col1) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [] | ||
: +- Project [col1#x, col1#x] | ||
: +- Project [col1 AS col1#x] | ||
: +- OneRowRelation | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1', col1 FROM VALUES(1)) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [] | ||
: +- Project [col1 AS col1#x, col1#x] | ||
: +- LocalRelation [col1#x] | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT col1 AS col1, col1 FROM VALUES(1)) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [] | ||
: +- Project [col1#x AS col1#x, col1#x] | ||
: +- LocalRelation [col1#x] | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1' AS col1, col1 FROM VALUES(1)) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [] | ||
: +- Project [col1 AS col1#x, col1#x] | ||
: +- LocalRelation [col1#x] | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT 'col1', col1) | ||
-- !query analysis | ||
Filter exists#x [col1#x] | ||
: +- Project [col1 AS col1#x, outer(col1#x)] | ||
: +- OneRowRelation | ||
+- Aggregate [col1#x], [col1#x] | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT col1 AS col1, col1) | ||
-- !query analysis | ||
Filter exists#x [col1#x] | ||
: +- Project [col1#x, col1#x] | ||
: +- Project [outer(col1#x) AS col1#x] | ||
: +- OneRowRelation | ||
+- Aggregate [col1#x], [col1#x] | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT 'col1' AS col1, col1) | ||
-- !query analysis | ||
Filter exists#x [] | ||
: +- Project [col1#x, col1#x] | ||
: +- Project [col1 AS col1#x] | ||
: +- OneRowRelation | ||
+- Aggregate [col1#x], [col1#x] | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT 'col1', col1 FROM VALUES(1)) | ||
-- !query analysis | ||
Filter exists#x [] | ||
: +- Project [col1 AS col1#x, col1#x] | ||
: +- LocalRelation [col1#x] | ||
+- Aggregate [col1#x], [col1#x] | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT col1 AS col1, col1 FROM VALUES(1)) | ||
-- !query analysis | ||
Filter exists#x [] | ||
: +- Project [col1#x AS col1#x, col1#x] | ||
: +- LocalRelation [col1#x] | ||
+- Aggregate [col1#x], [col1#x] | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT 'col1' AS col1, col1 FROM VALUES(1)) | ||
-- !query analysis | ||
Filter exists#x [] | ||
: +- Project [col1 AS col1#x, col1#x] | ||
: +- LocalRelation [col1#x] | ||
+- Aggregate [col1#x], [col1#x] | ||
+- LocalRelation [col1#x] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
-- Automatically generated by SQLQueryTestSuite | ||
-- !query | ||
DECLARE a = "aa" | ||
-- !query analysis | ||
CreateVariable defaultvalueexpression(aa, "aa"), false | ||
+- ResolvedIdentifier org.apache.spark.sql.catalyst.analysis.FakeSystemCatalog$@xxxxxxxx, session.a | ||
|
||
|
||
-- !query | ||
SELECT 'a', a | ||
-- !query analysis | ||
Project [a#x, a#x] | ||
+- Project [a AS a#x] | ||
+- OneRowRelation | ||
|
||
|
||
-- !query | ||
SELECT 'a' AS a, a | ||
-- !query analysis | ||
Project [a#x, a#x] | ||
+- Project [a AS a#x] | ||
+- OneRowRelation | ||
|
||
|
||
-- !query | ||
SELECT 'a', a FROM VALUES(1) AS t(a) | ||
-- !query analysis | ||
Project [a AS a#x, a#x] | ||
+- SubqueryAlias t | ||
+- LocalRelation [a#x] | ||
|
||
|
||
-- !query | ||
SELECT 'a' AS a, a FROM VALUES(1) AS t(a) | ||
-- !query analysis | ||
Project [a AS a#x, a#x] | ||
+- SubqueryAlias t | ||
+- LocalRelation [a#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1', col1) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [] | ||
: +- Project [col1#x, col1#x] | ||
: +- Project [col1 AS col1#x] | ||
: +- OneRowRelation | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT col1 AS col1, col1) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [col1#x] | ||
: +- Project [col1#x, col1#x] | ||
: +- Project [outer(col1#x) AS col1#x] | ||
: +- OneRowRelation | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1' AS col1, col1) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [] | ||
: +- Project [col1#x, col1#x] | ||
: +- Project [col1 AS col1#x] | ||
: +- OneRowRelation | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1', col1 FROM VALUES(1)) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [] | ||
: +- Project [col1 AS col1#x, col1#x] | ||
: +- LocalRelation [col1#x] | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT col1 AS col1, col1 FROM VALUES(1)) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [] | ||
: +- Project [col1#x AS col1#x, col1#x] | ||
: +- LocalRelation [col1#x] | ||
+- LocalRelation [col1#x] | ||
|
||
|
||
-- !query | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1' AS col1, col1 FROM VALUES(1)) | ||
-- !query analysis | ||
Project [col1#x] | ||
+- Filter exists#x [] | ||
: +- Project [col1 AS col1#x, col1#x] | ||
: +- LocalRelation [col1#x] | ||
+- LocalRelation [col1#x] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- This is a legacy test for last resort column resolution that has a correctness issue. | ||
-- For more information, see SPARK-53733. | ||
|
||
--IMPORT column-last-resort-resolution-precedence.sql | ||
|
||
--SET spark.sql.analyzer.delayLastResortColumnResolution = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
DECLARE a = "aa"; | ||
|
||
SELECT 'a', a; | ||
SELECT 'a' AS a, a; | ||
|
||
SELECT 'a', a FROM VALUES(1) AS t(a); | ||
SELECT 'a' AS a, a FROM VALUES(1) AS t(a); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please use a view instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think arguments for |
||
|
||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1', col1); | ||
mihailotim-db marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have the logic for We need the same tests with with |
||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT col1 AS col1, col1); | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1' AS col1, col1); | ||
|
||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1', col1 FROM VALUES(1)); | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT col1 AS col1, col1 FROM VALUES(1)); | ||
SELECT col1 FROM VALUES(1) WHERE EXISTS (SELECT 'col1' AS col1, col1 FROM VALUES(1)); | ||
|
||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT 'col1', col1); | ||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT col1 AS col1, col1); | ||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT 'col1' AS col1, col1); | ||
|
||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT 'col1', col1 FROM VALUES(1)); | ||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT col1 AS col1, col1 FROM VALUES(1)); | ||
SELECT col1 FROM VALUES(1) GROUP BY col1 HAVING EXISTS (SELECT 'col1' AS col1, col1 FROM VALUES(1)); |
Uh oh!
There was an error while loading. Please reload this page.