-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28441][SQL][Python] Fix error when non-foldable expression is used in correlated scalar subquery #25204
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 all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
725304c
Fix error when PythonUDF is used in outer plan.
viirya 7972d7c
Address comment.
viirya 33441a3
Fix non-foldable expression other than PythonUDF.
viirya 110a39e
Add a common method.
viirya a7803f5
Rename method and variable.
viirya 0158d85
Use Expression instead of Option[Expression].
viirya 2dd29c1
Try to only remove attribute-only projects in removeProjectBeforeFilter.
viirya 9aea844
Cleanup.
viirya 1f6b717
Better to check result.
viirya d7d023d
Fix style.
viirya fd29677
Fix few styles.
viirya 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 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
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
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
Oops, something went wrong.
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.
I am not sure about this change. This may cause serious perf regression
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.
How can we remove project that's not attribute-only?
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'd say it was wrong previously, but if a project's output has same expr IDs with its child, it's usually attribute-only.
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.
Mmmmh... I may be missing something, but I'd imagine a case like this:
Before this change, would be optimized as:
while after it is not. Am I wrong?
Uh oh!
There was an error while loading. Please reload this page.
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.
In above case, it has a Alias in project list, so it's not an attribute-only project. And I think it also create new attr c, so
p2.outputSet.subsetOf(child.outputSet)is not met too.I think the rules in
ColumnPruningwill trimvery_expensive_operationin the end.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 see now, sorry. Why do we need this? Seems an unrelated change to the fix in this PR, isn't 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.
oh, the issue was seen in previous comment 33441a3. It was overwritten now.
We added a column for count bug. The column checks a always-true leading column
alwaysTrueExpr, returns special value ifalwaysTrueExpris null, to simulate empty input case.This column reuses expr id of original output in the subquery. In non-foldable expression case, the added column in a potential Project-Filter-Project, will be trimmed by
removeProjectBeforeFilter, because the second project meetsp2.outputSet.subsetOf(child.outputSet).My original fix is to create an expr id. Replace original expr id with new one in the subquery. Looks complicated. This seems a simple fix, and looks reasonable.