-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22413][SQL] Type coercion for IN is not coherent between Literals and subquery #19635
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
8fb9c9d
8481b59
c973bb7
2db7cf0
a8723c2
7656864
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 |
|---|---|---|
|
|
@@ -471,7 +471,7 @@ object TypeCoercion { | |
|
|
||
| val commonTypes = lhs.zip(rhs).flatMap { case (l, r) => | ||
| findCommonTypeForBinaryComparison(l.dataType, r.dataType, conf) | ||
| .orElse(findTightestCommonType(l.dataType, r.dataType)) | ||
| .orElse(findWiderTypeForTwo(l.dataType, r.dataType)) | ||
| } | ||
|
|
||
| // The number of columns/expressions must match between LHS and RHS of an | ||
|
|
@@ -493,7 +493,10 @@ object TypeCoercion { | |
| } | ||
|
|
||
| case i @ In(a, b) if b.exists(_.dataType != a.dataType) => | ||
| findWiderCommonType(i.children.map(_.dataType)) match { | ||
| findWiderCommonType(b.map(_.dataType)).flatMap { listDataType => | ||
| findCommonTypeForBinaryComparison(listDataType, a.dataType, conf) | ||
| .orElse(findWiderTypeForTwo(listDataType, a.dataType)) | ||
|
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. What is the reason we need to call
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. before this PR, we were calling always |
||
| } match { | ||
| case Some(finalDataType) => i.withNewChildren(i.children.map(Cast(_, finalDataType))) | ||
| case None => i | ||
| } | ||
|
|
||
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.
Why we make this change?
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.
To be coherent with what is done when there are literals instead of a subquery.