-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-25769][SQL]make UnresolvedAttribute.sql escape nested columns correctly #22788
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
Changes from 2 commits
2aa4ad9
e941acd
99bfd00
458f77a
566d5f9
7ff2696
693c512
05688f5
3c81840
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 |
|---|---|---|
|
|
@@ -81,7 +81,7 @@ SELECT t1.i1 FROM t1, mydb1.t1 | |
| struct<> | ||
| -- !query 9 output | ||
| org.apache.spark.sql.AnalysisException | ||
| Reference 't1.i1' is ambiguous, could be: mydb1.t1.i1, mydb1.t1.i1.; line 1 pos 7 | ||
| Reference '`t1`.`i1`' is ambiguous, could be: mydb1.t1.i1, mydb1.t1.i1.; line 1 pos 7 | ||
|
Contributor
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. why is the new format better? it's more verbose, isn't it?
Member
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 thought some examples in the above.
Contributor
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. These examples only make sense when we have the outer backticks. e.g. |
||
|
|
||
|
|
||
| -- !query 10 | ||
|
|
@@ -90,7 +90,7 @@ SELECT mydb1.t1.i1 FROM t1, mydb1.t1 | |
| struct<> | ||
| -- !query 10 output | ||
| org.apache.spark.sql.AnalysisException | ||
| Reference 'mydb1.t1.i1' is ambiguous, could be: mydb1.t1.i1, mydb1.t1.i1.; line 1 pos 7 | ||
| Reference '`mydb1`.`t1`.`i1`' is ambiguous, could be: mydb1.t1.i1, mydb1.t1.i1.; line 1 pos 7 | ||
|
|
||
|
|
||
| -- !query 11 | ||
|
|
@@ -108,7 +108,7 @@ SELECT t1.i1 FROM t1, mydb2.t1 | |
| struct<> | ||
| -- !query 12 output | ||
| org.apache.spark.sql.AnalysisException | ||
| Reference 't1.i1' is ambiguous, could be: mydb1.t1.i1, mydb2.t1.i1.; line 1 pos 7 | ||
| Reference '`t1`.`i1`' is ambiguous, could be: mydb1.t1.i1, mydb2.t1.i1.; line 1 pos 7 | ||
|
|
||
|
|
||
| -- !query 13 | ||
|
|
@@ -134,7 +134,7 @@ SELECT t1.i1 FROM t1, mydb1.t1 | |
| struct<> | ||
| -- !query 15 output | ||
| org.apache.spark.sql.AnalysisException | ||
| Reference 't1.i1' is ambiguous, could be: mydb2.t1.i1, mydb1.t1.i1.; line 1 pos 7 | ||
| Reference '`t1`.`i1`' is ambiguous, could be: mydb2.t1.i1, mydb1.t1.i1.; line 1 pos 7 | ||
|
|
||
|
|
||
| -- !query 16 | ||
|
|
@@ -152,7 +152,7 @@ SELECT t1.i1 FROM t1, mydb2.t1 | |
| struct<> | ||
| -- !query 17 output | ||
| org.apache.spark.sql.AnalysisException | ||
| Reference 't1.i1' is ambiguous, could be: mydb2.t1.i1, mydb2.t1.i1.; line 1 pos 7 | ||
| Reference '`t1`.`i1`' is ambiguous, could be: mydb2.t1.i1, mydb2.t1.i1.; line 1 pos 7 | ||
|
|
||
|
|
||
| -- !query 18 | ||
|
|
@@ -161,7 +161,7 @@ SELECT db1.t1.i1 FROM t1, mydb2.t1 | |
| struct<> | ||
| -- !query 18 output | ||
| org.apache.spark.sql.AnalysisException | ||
| cannot resolve '`db1.t1.i1`' given input columns: [mydb2.t1.i1, mydb2.t1.i1]; line 1 pos 7 | ||
| cannot resolve '`db1`.`t1`.`i1`' given input columns: [mydb2.t1.i1, mydb2.t1.i1]; line 1 pos 7 | ||
|
Contributor
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. do you think we should just make
Contributor
Author
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. Yes. I agree. For the four examples, we will have the following results: with my previous fix: make sql same as name: with my previous fix: make sql same as name: with my previous fix: make sql same as name: with my previous fix: make sql same as name: Does this look good to everybody?
Contributor
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. LGTM
Contributor
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. @huaxingao Were you planning to make a change to make
Contributor
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. @cloud-fan I had a question, the 3rd example from huaxin, wanted to confirm again if the output looks okay to you. from huaxin with my previous fix: make sql same as name: Is it okay to drop the backtick from the first identifier ?
Contributor
Author
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. @dilipbiswal
Contributor
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.
AFAIK both
Contributor
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. @cloud-fan Makes sense. Thanks for clarification... |
||
|
|
||
|
|
||
| -- !query 19 | ||
|
|
@@ -186,7 +186,7 @@ SELECT mydb1.t1 FROM t1 | |
| struct<> | ||
| -- !query 21 output | ||
| org.apache.spark.sql.AnalysisException | ||
| cannot resolve '`mydb1.t1`' given input columns: [mydb1.t1.i1]; line 1 pos 7 | ||
| cannot resolve '`mydb1`.`t1`' given input columns: [mydb1.t1.i1]; line 1 pos 7 | ||
|
|
||
|
|
||
| -- !query 22 | ||
|
|
@@ -221,7 +221,7 @@ SELECT mydb1.t1.i1 FROM t1 | |
| struct<> | ||
| -- !query 25 output | ||
| org.apache.spark.sql.AnalysisException | ||
| cannot resolve '`mydb1.t1.i1`' given input columns: [mydb2.t1.i1]; line 1 pos 7 | ||
| cannot resolve '`mydb1`.`t1`.`i1`' given input columns: [mydb2.t1.i1]; line 1 pos 7 | ||
|
|
||
|
|
||
| -- !query 26 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1143,7 +1143,7 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext { | |
| |order by struct.a, struct.b | ||
| |""".stripMargin) | ||
| } | ||
| assert(error.message contains "cannot resolve '`struct.a`' given input columns: [a, b]") | ||
| assert(error.message contains "cannot resolve '`struct`.`a`' given input columns: [a, b]") | ||
|
|
||
| } | ||
|
|
||
|
|
@@ -2702,7 +2702,7 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext { | |
|
|
||
| val e = intercept[AnalysisException](sql("SELECT v.i from (SELECT i FROM v)")) | ||
| assert(e.message == | ||
| "cannot resolve '`v.i`' given input columns: [__auto_generated_subquery_name.i]") | ||
|
Contributor
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 the problem here is the out-most backticks, do you know where we add it?
Contributor
Author
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. The out-most backticks is added in the |
||
| "cannot resolve '`v`.`i`' given input columns: [__auto_generated_subquery_name.i]") | ||
|
|
||
| checkAnswer(sql("SELECT __auto_generated_subquery_name.i from (SELECT i FROM v)"), Row(1)) | ||
| } | ||
|
|
||
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 don't think this is better for
name, we should updatesqlthough.