cloud-fan commented on a change in pull request #33056:
URL: https://github.com/apache/spark/pull/33056#discussion_r657747329



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/LiteralExpressionSuite.scala
##########
@@ -432,4 +434,27 @@ class LiteralExpressionSuite extends SparkFunSuite with 
ExpressionEvalHelper {
       assert(literal.toString === expected)
     }
   }
+
+  test("SPARK-35871: Literal.create(value, dataType) should support fields") {
+    val period = Period.ofMonths(13)
+    Seq(YearMonthIntervalType(YEAR, MONTH) -> 13,
+      YearMonthIntervalType(YEAR) -> 12,
+      YearMonthIntervalType(MONTH) -> 13).foreach { case (dt, result) =>
+      checkEvaluation(Literal.create(period, dt), result)
+    }
+
+    val duration = Duration.ofSeconds(86400 + 3600 + 60 + 1)
+    Seq(DayTimeIntervalType(DAY) -> 86400000000L,
+      DayTimeIntervalType(DAY, HOUR) -> 90000000000L,
+      DayTimeIntervalType(DAY, MINUTE) -> 90060000000L,
+      DayTimeIntervalType(DAY, SECOND) -> 90061000000L,
+      DayTimeIntervalType(HOUR) -> 90000000000L,
+      DayTimeIntervalType(HOUR, MINUTE) -> 90060000000L,
+      DayTimeIntervalType(HOUR, SECOND) -> 90061000000L,
+      DayTimeIntervalType(MINUTE) -> 90060000000L,
+      DayTimeIntervalType(MINUTE, SECOND) -> 90061000000L,
+      DayTimeIntervalType(SECOND) -> 90061000000L).foreach { case (dt, result) 
=>

Review comment:
       This is still hard to read as I don't know if all the types are listed. 
I'd prefer `DataTypeTestUtils.dayTimeIntervalTypes`




-- 
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to