-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-9068][SQL] refactor the implicit type cast code #7420
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
|
Test build #37365 has finished for PR 7420 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.
Why we need isSameType? I think the logic should be:
- first check whether the input type is acceptable(i.e.
expectedType.acceptsType(inType)returns true). If it is, do nothing here. - If input type is not acceptable, follow cast rules below to do implicit type cast.
It looks to me we only need acceptsType.
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.
there was a reason, but i can't remember why right now. let me think about it.
cc @marmbrus do you remember why?
|
cc @rxin |
|
Test build #37368 has finished for PR 7420 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.
I think it's better to generate a different error message for BinaryOperator, as 2 children have same type and same expected type, we don't need to follow ExpectsInputTypes to report type error for both left and right.
|
Test build #37376 has finished for PR 7420 at commit
|
|
Test build #37384 has finished for PR 7420 at commit
|
|
Test build #37392 has finished for PR 7420 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.
Is this correct? Imagine we have TypeCollection(LongType, StringType), and the input is StringType
Wouldn't this just cast input to a longtype?
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 first rule is: case _ if expectedType.acceptsType(inType) => e.
So when we reach here, input type is not acceptable for any types in this type collection. see the inline comments above.
|
LGTM - @marmbrus and I can't really think of why anymore we needed it - maybe we don't need it anymore. Going to merge this. |
based on #7348