-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-17154][SQL] Wrong result can be returned or AnalysisException can be thrown after self-join or similar operations #14719
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
05872b7
Fixed the issue that self-join or similar join patterns can cause wro…
sarutak 91cb915
Fix ScriptTransformationSuite
sarutak dd0ddbc
Fixed further more test cases
sarutak 74eb4aa
Fixed analysis error in sorting
sarutak 48a0775
Refectored
sarutak 9ddc9d8
Fixed flatMapGroupsInR to ensure expressions for Deserializer is reso…
sarutak 148b6d5
Fixed style
sarutak 021977f
Implemented another idea
sarutak b09c0d7
Fixed conflict
sarutak ccf71fc
Modified error message
sarutak d458b79
Merge branch 'master' of git://git.apache.org/spark into SPARK-17154
sarutak 437ac99
Reverted the previous change which prohibitted self-join
sarutak 9ad2c85
Merge branch 'master' of git://git.apache.org/spark into SPARK-17154
sarutak 929f2a8
Resolved conflict
sarutak 15bf529
Fixed style
sarutak e91a24e
Merge branch 'master' of git://git.apache.org/spark into SPARK-17154
sarutak 5d1ff3e
Fix compile error
sarutak a3f32c4
Fixed conflicts
sarutak 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
Resolved conflict
- Loading branch information
commit 929f2a85a06795ce91f8aff588ab18ee4cb3d804
There are no files selected for viewing
This file contains hidden or 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
You are viewing a condensed version of this merge commit. You can view the full changes here.
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.
What happens when:
As there are two plans with the same plan id, the breadth-first search will get one plan among them. So df("col") will be resolved. However, I think in this case, we should have an ambiguous error message.
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.
this is a good question!
I'm also thinking about this. If a plan id matches more than one sub-tree in the logical plan, should we just fail the query instead of using BFS to pick the first one?
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.
Yeah, direct-self-join (means both child Datasets are same) is still ambiguous.
In this case,
df("colmn-name")will refers to a Dataset of the right side in the proposed implementation.I'm wondering a direct-self-join like df.join(df, , ) is similar to a query like as follows.
SELECT ... FROM my_table df join my_table df on ;
Those queries should not be valid so I also think we shouldn't allow users to join two same Datasets and warn to duplicate the Dataset if they intend to do direct-self-join.
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.
If logical-plan on the right side is copied by
dedupRight, there should be multiple logical-plans which have same planId so it maybe better to fail the query in case of direct-self-join.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.
Although I can't immediately think out the actual use case the self-join of two same Datasets, I am still wondering do we want to disallow it? Conceptually, it should work, even you can't select columns from it due to ambiguousness. But I think you can still save it or do other operators on it.
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 we should support a self-join of the same Dataset/DateFrame of the same name. That is,
df.join(df)should be blocked. We can ask the user to express it as
df.join(df.as("df2")), which is clearer. We certainly must not support
df.join(df, df("col1") === df("col2"), which blindly put
"col1"and"col2"to the firstdf. @sarutak 's solution does change the behaviour to an error.