-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-32052][SQL] Extract common code from date-time field expressions #28894
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 #124365 has finished for PR 28894 at commit
|
| case class Hour(child: Expression, timeZoneId: Option[String] = None) | ||
| extends UnaryExpression with TimeZoneAwareExpression with ImplicitCastInputTypes | ||
| with NullIntolerant { | ||
| trait GetTimeField extends UnaryExpression |
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.
When I made it as abstract class with 2 args func and funcName, I got the following exception on tests from DateExpressionsSuite:
org.apache.spark.sql.catalyst.expressions.Second; no valid constructor
java.io.InvalidClassException: org.apache.spark.sql.catalyst.expressions.Second; no valid constructor
at java.io.ObjectStreamClass$ExceptionInfo.newInvalidClassException(ObjectStreamClass.java:169)
at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:885)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2100)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1625)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:465)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:423)
at org.apache.spark.serializer.JavaDeserializationStream.readObject(JavaSerializer.scala:76)
at org.apache.spark.serializer.JavaSerializerInstance.deserialize(JavaSerializer.scala:109)
at org.apache.spark.sql.catalyst.expressions.ExpressionEvalHelper.prepareEvaluation(ExpressionEvalHelper.scala:75)
I decided to leave it as a trait.
|
@cloud-fan @srowen @dongjoon-hyun @HyukjinKwon Could you review the refactoring, please. |
Fokko
left a comment
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.
Nice one
|
thanks, merging to master! |
|
late LGTM too |
What changes were proposed in this pull request?
Extract common code from the expressions that get date or time fields from input dates/timestamps to new expressions
GetDateFieldandGetTimeField, and re-use the common traits from the affected classes.Why are the changes needed?
Code deduplication improves maintainability.
Does this PR introduce any user-facing change?
No
How was this patch tested?
By
DateExpressionsSuite