You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/06/22 12:28:32 UTC

[GitHub] [spark] MaxGekk opened a new pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

MaxGekk opened a new pull request #28894:
URL: https://github.com/apache/spark/pull/28894


   ### 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 `GetDateField` and `GetTimeField`, 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`


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28894:
URL: https://github.com/apache/spark/pull/28894#issuecomment-647672063






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan closed pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #28894:
URL: https://github.com/apache/spark/pull/28894


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28894:
URL: https://github.com/apache/spark/pull/28894#issuecomment-647488250






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28894:
URL: https://github.com/apache/spark/pull/28894#issuecomment-647672063






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28894:
URL: https://github.com/apache/spark/pull/28894#issuecomment-647670925


   **[Test build #124365 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/124365/testReport)** for PR 28894 at commit [`f2a278e`](https://github.com/apache/spark/commit/f2a278e90b2578552d960aba700e874c41f2bebe).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds the following public classes _(experimental)_:
     * `case class DayOfWeek(child: Expression) extends GetDateField `
     * `case class WeekDay(child: Expression) extends GetDateField `
     * `case class WeekOfYear(child: Expression) extends GetDateField `


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] MaxGekk commented on pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on pull request #28894:
URL: https://github.com/apache/spark/pull/28894#issuecomment-647672706


   @cloud-fan @srowen @dongjoon-hyun @HyukjinKwon Could you review the refactoring, please.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #28894:
URL: https://github.com/apache/spark/pull/28894#issuecomment-647941360


   late LGTM too


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] MaxGekk commented on a change in pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on a change in pull request #28894:
URL: https://github.com/apache/spark/pull/28894#discussion_r443718185



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -274,39 +274,43 @@ case class DateSub(startDate: Expression, days: Expression)
   override def prettyName: String = "date_sub"
 }
 
-@ExpressionDescription(
-  usage = "_FUNC_(timestamp) - Returns the hour component of the string/timestamp.",
-  examples = """
-    Examples:
-      > SELECT _FUNC_('2009-07-30 12:58:59');
-       12
-  """,
-  group = "datetime_funcs",
-  since = "1.5.0")
-case class Hour(child: Expression, timeZoneId: Option[String] = None)
-  extends UnaryExpression with TimeZoneAwareExpression with ImplicitCastInputTypes
-    with NullIntolerant {
+trait GetTimeField extends UnaryExpression

Review comment:
       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.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28894:
URL: https://github.com/apache/spark/pull/28894#issuecomment-647487574


   **[Test build #124365 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/124365/testReport)** for PR 28894 at commit [`f2a278e`](https://github.com/apache/spark/commit/f2a278e90b2578552d960aba700e874c41f2bebe).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA removed a comment on pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #28894:
URL: https://github.com/apache/spark/pull/28894#issuecomment-647487574


   **[Test build #124365 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/124365/testReport)** for PR 28894 at commit [`f2a278e`](https://github.com/apache/spark/commit/f2a278e90b2578552d960aba700e874c41f2bebe).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #28894:
URL: https://github.com/apache/spark/pull/28894#issuecomment-647931165


   thanks, merging to master!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28894:
URL: https://github.com/apache/spark/pull/28894#issuecomment-647488250






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] MaxGekk commented on a change in pull request #28894: [SPARK-32052][SQL] Extract common code from date-time field expressions

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on a change in pull request #28894:
URL: https://github.com/apache/spark/pull/28894#discussion_r443718185



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -274,39 +274,43 @@ case class DateSub(startDate: Expression, days: Expression)
   override def prettyName: String = "date_sub"
 }
 
-@ExpressionDescription(
-  usage = "_FUNC_(timestamp) - Returns the hour component of the string/timestamp.",
-  examples = """
-    Examples:
-      > SELECT _FUNC_('2009-07-30 12:58:59');
-       12
-  """,
-  group = "datetime_funcs",
-  since = "1.5.0")
-case class Hour(child: Expression, timeZoneId: Option[String] = None)
-  extends UnaryExpression with TimeZoneAwareExpression with ImplicitCastInputTypes
-    with NullIntolerant {
+trait GetTimeField extends UnaryExpression

Review comment:
       When I made it as `abstract class` with 2 args `func` and `funcName`, I got the following exception on tests from `DateExpressionsSuite`:
   ```
   
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org