-
Notifications
You must be signed in to change notification settings - Fork 29.1k
[SPARK-34476][SQL] Duplicate referenceNames are given for ambiguousReferences #31613
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 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 |
|---|---|---|
|
|
@@ -3225,7 +3225,7 @@ select * from | |
| struct<> | ||
| -- !query output | ||
| org.apache.spark.sql.AnalysisException | ||
| Reference 'f1' is ambiguous, could be: j.f1, j.f1.; line 2 pos 63 | ||
| Reference 'f1' is ambiguous, could be: j.f1#x, j.f1#x.; line 2 pos 63 | ||
|
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. Adding the attr ID doesn't seem to help much. Users still don't know how to fix the query (is it un-fixable?).
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. For json path expression case, one expression is from filter and the other is from projection. get_json_string produces the json path expression. See innerResolve() of sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala: I am willing to get input from people who are familiar with the analyzer.
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 have the same feeling with @cloud-fan. I think the other databases show a message message with the same granularity in the case, e.g.,
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 above example from postgres doesn't apply to the json path case because there is only one table.
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. Does https://github.com/apache/spark/pull/31613/files#r581342459 answer @cloud-fan's question? So with the attr ID added, how it helps the case you show? I think it is the point we care about. BTW, what is
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. Considering snippet of physical plan: multiple json path expressions would be accompanied by ExprId.id. It would be easier to match the reference (with exprId.id) given in the AnalysisException with the expression. w.r.t. get_json_string, it is a function which is interpreted by Spark extension, translating arguments to json path expression.
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. It doesn't help because end-users can't specify attr id when referring to the column. If a table/relation has duplicated column names, I think the only way out is to get the column by position, e.g. |
||
|
|
||
|
|
||
| -- !query | ||
|
|
||
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 you add a test?
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.
Also,
SQLQueryTestSuiteis failing, so you many want to check.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 have updated relevant out files under sql/core/src/test/resources/sql-tests/results/postgreSQL