Peng-Lei commented on a change in pull request #34494:
URL: https://github.com/apache/spark/pull/34494#discussion_r750957056



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
##########
@@ -1580,6 +1647,59 @@ abstract class CastBase extends UnaryExpression with 
TimeZoneAwareExpression wit
     }
   }
 
+  private[this] def castDayTimeIntervalToIntegralTypeCode(
+      ctx: CodegenContext,
+      endFiled: Byte,
+      integralType: String,
+      catalogType: String): CastFunction = {

Review comment:
       done

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
##########
@@ -1580,6 +1647,59 @@ abstract class CastBase extends UnaryExpression with 
TimeZoneAwareExpression wit
     }
   }
 
+  private[this] def castDayTimeIntervalToIntegralTypeCode(
+      ctx: CodegenContext,
+      endFiled: Byte,
+      integralType: String,
+      catalogType: String): CastFunction = {
+    val util = IntervalUtils.getClass.getCanonicalName.stripSuffix("$")
+    integralType match {
+      case "long" =>
+        (c, evPrim, _) =>
+          code"""$evPrim = $util.dayTimeIntervalToLong($c, (byte)$endFiled);"""
+      case "int" =>
+        (c, evPrim, _) =>
+          code"""$evPrim = $util.dayTimeIntervalToInt($c, (byte)$endFiled);"""
+      case "short" =>
+        (c, evPrim, _) =>
+          code"""$evPrim = $util.dayTimeIntervalToShort($c, 
(byte)$endFiled);"""
+      case "byte" =>
+        (c, evPrim, _) =>
+          code"""$evPrim = $util.dayTimeIntervalToByte($c, (byte)$endFiled);"""
+    }
+  }
+
+  private[this] def castYearMonthIntervalToIntegralTypeCode(
+      ctx: CodegenContext,
+      endFiled: Byte,
+      integralType: String,
+      catalogType: String): CastFunction = {

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.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

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