cloud-fan commented on a change in pull request #33056: URL: https://github.com/apache/spark/pull/33056#discussion_r657704145
########## File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/LiteralExpressionSuite.scala ########## @@ -432,4 +432,22 @@ class LiteralExpressionSuite extends SparkFunSuite with ExpressionEvalHelper { assert(literal.toString === expected) } } + + test("SPARK-35871: Literal.create(value, dataType) should support fields") { + Seq((Period.ofMonths(13), Array(13, 12, 13))) + .foreach { case (period, expect) => + DataTypeTestUtils.yearMonthIntervalTypes.zip(expect).foreach { case (dt, result) => + checkEvaluation(Literal.create(period, dt), result) + } + } + + Seq((Duration.ofSeconds(86400 + 3600 + 60 + 1), + Array(86400000000L, 90000000000L, 90060000000L, 90061000000L, 90000000000L, + 90060000000L, 90061000000L, 90060000000L, 90061000000L, 90061000000L))) Review comment: This test is too hard to read, I don't know which value is for which type. How about ``` val duration = Duration.ofSeconds(86400 + 3600 + 60 + 1) DataTypeTestUtils.dayTimeIntervalTypes.foreach { dt => val result = dt.endField match { case SECOND => ... ... } checkEvaluation(Literal.create(duration, dt), result) } ``` -- 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