-
Notifications
You must be signed in to change notification settings - Fork 29.1k
[SPARK-35932][SQL] Support extracting hour/minute/second from timestamp without time zone #33136
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
| case (StringType, target: NumericType) => target | ||
| case (StringType, DateType) => DateType | ||
| case (StringType, TimestampType) => TimestampType | ||
| case (StringType, AnyTimestampType) => TimestampType |
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.
We need this for the default implicit cast from string to timestamp type. This regression is found on running extract.sql.
|
Test build #140356 has finished for PR 33136 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
| @@ -189,6 +189,7 @@ object AnsiTypeCoercion extends TypeCoercionBase { | |||
| } | |||
|
|
|||
| case (DateType, TimestampType) => Some(TimestampType) | |||
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.
shall we support Date -> Timestamp NTZ? in case we have such functions in the future.
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.
Well we can have it but it is not related to this PR and there is no test case for the change
| } | ||
|
|
||
| case (DateType, TimestampType) => Some(TimestampType) | ||
| case (DateType, AnyTimestampType) => Some(TimestampType) |
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.
shall we use AnyTimestampType.defaultConcreteType?
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 default concrete type is TimestampWithoutTZType. The current code is not ready for that yet.
There will be a new flag for the default timestamp type in SQL. Let's revisit this 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 just change the default concrete type of AnyTimestampType to TimestampType, which makes more sense.
|
Test build #140426 has finished for PR 33136 at commit
|
| if s.left.dataType != s.right.dataType => | ||
| val newLeft = castIfNotSameType(s.left, AnyTimestampType.defaultConcreteType) | ||
| val newRight = castIfNotSameType(s.right, AnyTimestampType.defaultConcreteType) | ||
| val newLeft = castIfNotSameType(s.left, TimestampWithoutTZType) |
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.
Here the result is the same if casting both to TimestampWithoutTZType or TimestampType. Casting to TimestampWithoutTZType is more straightforward.
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Merging to master |
|
|
||
| // Implicit cast between date time types | ||
| case (DateType, TimestampType) => TimestampType | ||
| case (DateType, AnyTimestampType) => TimestampType |
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.
here should be AnyTimestampType.defaultConcreteType as well
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 will address this in the PR for extracting date fields.
|
Test build #140437 has finished for PR 33136 at commit
|
What changes were proposed in this pull request?
Support extracting hour/minute/second fields from timestamp without time zone values. In details, the following syntaxes are supported:
Why are the changes needed?
Support basic operations for the new timestamp type.
Does this PR introduce any user-facing change?
No, the timestamp without time zone type is not release yet.
How was this patch tested?
Unit test