Peng-Lei commented on a change in pull request #33056: URL: https://github.com/apache/spark/pull/33056#discussion_r657762610
########## 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: how about: ```scala val duration = Duration.ofSeconds(86400 + 3600 + 60 + 1) DataTypeTestUtils.dayTimeIntervalTypes.foreach { dt => { checkEvaluation(Literal.create(duration, dt), durationToMicros(duration, dt.endField)) } ``` -- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org