AngersZhuuuu commented on a change in pull request #32940:
URL: https://github.com/apache/spark/pull/32940#discussion_r656759755



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala
##########
@@ -654,6 +654,33 @@ class CastSuite extends CastSuiteBase {
       }
   }
 
+  test("SPARK-35768: Take into account year-month interval fields in cast") {
+    Seq(("1-1", YearMonthIntervalType(YEAR, YEAR), 12, 12, 12),
+      ("1-1", YearMonthIntervalType(YEAR, MONTH), 13, 12, 13),
+      ("1-1", YearMonthIntervalType(MONTH, MONTH), 13, 12, 13),
+      ("-1-1", YearMonthIntervalType(YEAR, YEAR), -12, -12, -12),
+      ("-1-1", YearMonthIntervalType(YEAR, MONTH), -13, -12, -13),
+      ("-1-1", YearMonthIntervalType(MONTH, MONTH), -13, -12, -13))
+      .foreach { case (str, dataType, ym, year, month) =>
+        checkEvaluation(cast(Literal.create(str), dataType), ym)
+        checkEvaluation(cast(Literal.create(s"INTERVAL '$str' YEAR TO MONTH"), 
dataType), ym)
+        checkEvaluation(cast(Literal.create(s"INTERVAL -'$str' YEAR TO 
MONTH"), dataType), -ym)
+        checkEvaluation(cast(Literal.create(s"INTERVAL '$str' YEAR"), 
dataType), year)

Review comment:
       Done




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

Reply via email to