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 2021/04/07 05:21:17 UTC

[GitHub] [spark] MaxGekk commented on a change in pull request #32070: [SPARK-34668][SQL] Support casting of day-time intervals to strings

MaxGekk commented on a change in pull request #32070:
URL: https://github.com/apache/spark/pull/32070#discussion_r608347206



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala
##########
@@ -818,6 +818,31 @@ abstract class CastSuiteBase extends SparkFunSuite with ExpressionEvalHelper {
     checkConsistencyBetweenInterpretedAndCodegen(
       (child: Expression) => Cast(child, StringType), YearMonthIntervalType)
   }
+
+  test("SPARK-34668: cast day-time interval to string") {
+    Seq(
+      Duration.ZERO -> "0 0:0:0",
+      Duration.of(1, ChronoUnit.MICROS) -> "0 0:0:0.000001",
+      Duration.ofMillis(-1) -> "-0 0:0:0.001",
+      Duration.ofMillis(1234) -> "0 0:0:1.234",
+      Duration.ofSeconds(-59).minus(999999, ChronoUnit.MICROS) -> "-0 0:0:59.999999",
+      Duration.ofMinutes(30).plusMillis(10) -> "0 0:30:0.01",
+      Duration.ofHours(-23).minusSeconds(59) -> "-0 23:0:59",

Review comment:
       > Have we checked with other databases?
   
   For example, Oracle doesn't prepend zero for hours, see the [doc](https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/Literals.html#GUID-49FADC66-794D-4763-88C7-B81BB4F26D9E):
   ```
   INTERVAL '4 5:12:10.222' DAY TO SECOND
   ```




-- 
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