-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-52617][SQL] Cast TIME to/from TIMESTAMP_NTZ #51381
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
base: master
Are you sure you want to change the base?
[SPARK-52617][SQL] Cast TIME to/from TIMESTAMP_NTZ #51381
Conversation
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
Outdated
Show resolved
Hide resolved
4167bf1
to
828d214
Compare
...st/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteTimeCastToTimestampNTZ.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuiteBase.scala
Outdated
Show resolved
Hide resolved
...in/scala/org/apache/spark/sql/catalyst/analysis/resolver/RewriteTimeCastToTimestampNTZ.scala
Outdated
Show resolved
Hide resolved
.../scala/org/apache/spark/sql/catalyst/analysis/resolver/TimezoneAwareExpressionResolver.scala
Outdated
Show resolved
Hide resolved
fa1daa9
to
fd1aef3
Compare
…ysis/RewriteTimeCastToTimestampNTZ.scala Co-authored-by: Mihailo Timotic <mihailo.timotic@databricks.com>
…/DateTimeUtils.scala Co-authored-by: Mihailo Timotic <mihailo.timotic@databricks.com>
@mihailotim-db Should I make |
f7d1226
to
fd5e76e
Compare
.../scala/org/apache/spark/sql/catalyst/analysis/resolver/TimezoneAwareExpressionResolver.scala
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
Outdated
Show resolved
Hide resolved
@SubhamSinghal Could you resolve conflicts, please. |
case Cast(child, TimestampNTZType, _, _) if child.dataType.isInstanceOf[TimeType] => | ||
MakeTimestampNTZ(CurrentDate(), child) |
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 is no need to have this if we have a type coercion rule. Type coercion rules run implicitly in single-pass
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.
@mihailotim-db are you suggesting to revert all change in TimeZoneAwareExpressionResolver class and type coercion rule will take care of single pass and fixed point analyzer?
@@ -93,6 +93,7 @@ object AnsiTypeCoercion extends TypeCoercionBase { | |||
StackCoercion :: | |||
Division :: | |||
IntegralDivision :: | |||
RewriteTimeCastToTimestampNTZ :: |
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 is this a separate rule? I think we should be able to make it part of one of the existing rule, maybe DateTimeOperations
@MaxGekk ?
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.
Actually is this Cast coming from internal type coercion or user specified casts? If former, we should perform this change in the place where we add a cast. If latter, we should have an analysis rule for rewrite and not a type coercion one, since there is no coercion going on here
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.
@MaxGekk Can you help here?
e15a217
to
68dc4a9
Compare
What changes were proposed in this pull request?
This PR adds support for casting TIME to/from TIMESTAMP_NTZ type
Why are the changes needed?
Adds casting support between 2 types.
Does this PR introduce any user-facing change?
yes
How was this patch tested?
By running the related test suites: CastSuiteBase
By manual tests:
Was this patch authored or co-authored using generative AI tooling?
yes
Generated / corrected with AI assistance: chatGPT