-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-10534][SQL] ORDER BY clause allows only columns that are present in the select projection list #9123
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
Conversation
… SELECT statement
|
@cloud-fan |
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.
the test case can be simplified to:
val a = testRelation2.output(0)
val c = testRelation2.output(2)
val plan = testRelation2.select('c).orderBy(Floor('a).asc)
val expected = testRelation2.select(c, a).orderBy(Floor(a.cast(DoubleType)).asc).select(c)
checkAnalysis(plan, expected)
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.
Thanks a LOT. I will make the change.
|
I wanna explain a bit more about this bug. When we resolve sort ordering, we will use a special method, which only resolves |
|
ok to 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.
how about
val requiredAttributes = AttributeSet(newOrdering).filter(_.resolved)
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.
Thanks. Much simpler :-). Will make the change and test..
|
@cloud-fan |
|
Test build #43776 has finished for PR 9123 at commit
|
|
Test build #43778 has finished for PR 9123 at commit
|
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.
remove these 2 extra blank lines please.
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.
use 'c and 'a instead of c and a. The plan will get analyzed in the method checkAnalysis, so we should give unresolved attributes, to simulate normal query plans. (FYI, in spark SQL DSL, the symbol 'a will be automatically turned into UnresolvedAttribute)
|
hi @dilipbiswal , can you update the PR title to make it a complete sentence(i.e. no ellipsis)? and can you also put my explaination of this bug in PR description? so that if someone look into the commit log in the future, they can easily understand what's going on here. |
|
Test build #43798 has finished for PR 9123 at commit
|
|
LGTM pending test. |
|
retest this please. |
|
Test build #43796 has finished for PR 9123 at commit
|
|
cc @marmbrus |
|
Test build #43802 has finished for PR 9123 at commit
|
|
ping @yhuai |
|
Thank you! Merging to master and 1.5 branch. |
…ent in the select projection list
Find out the missing attributes by recursively looking
at the sort order expression and rest of the code
takes care of projecting them out.
Added description from cloud-fan
I wanna explain a bit more about this bug.
When we resolve sort ordering, we will use a special method, which only resolves UnresolvedAttributes and UnresolvedExtractValue. However, for something like Floor('a), even the 'a is resolved, the floor expression may still being unresolved as data type mismatch(for example, 'a is string type and Floor need double type), thus can't pass this filter, and we can't push down this missing attribute 'a
Author: Dilip Biswal <dbiswal@us.ibm.com>
Closes #9123 from dilipbiswal/SPARK-10534.
(cherry picked from commit 49ea0e9)
Signed-off-by: Yin Huai <yhuai@databricks.com>
Find out the missing attributes by recursively looking
at the sort order expression and rest of the code
takes care of projecting them out.
Added description from @cloud-fan
I wanna explain a bit more about this bug.
When we resolve sort ordering, we will use a special method, which only resolves UnresolvedAttributes and UnresolvedExtractValue. However, for something like Floor('a), even the 'a is resolved, the floor expression may still being unresolved as data type mismatch(for example, 'a is string type and Floor need double type), thus can't pass this filter, and we can't push down this missing attribute 'a