viirya commented on code in PR #362:
URL: https://github.com/apache/datafusion-comet/pull/362#discussion_r1589422333


##########
spark/src/main/scala/org/apache/comet/expressions/CometCast.scala:
##########
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet.expressions
+
+import org.apache.spark.sql.types.{DataType, DataTypes, DecimalType}
+
+sealed trait SupportLevel
+
+/** We support this feature with full compatibility with Spark */
+object Compatible extends SupportLevel
+
+/** We support this feature but results can be different from Spark */
+case class Incompatible(reason: Option[String] = None) extends SupportLevel
+
+/** We do not support this feature */
+object Unsupported extends SupportLevel
+
+object CometCast {
+
+  def supportedTypes: Seq[DataType] =
+    Seq(
+      DataTypes.BooleanType,
+      DataTypes.ByteType,
+      DataTypes.ShortType,
+      DataTypes.IntegerType,
+      DataTypes.LongType,
+      DataTypes.FloatType,
+      DataTypes.DoubleType,
+      DataTypes.createDecimalType(10, 2),
+      DataTypes.StringType,
+      DataTypes.BinaryType,
+      DataTypes.DateType,
+      DataTypes.TimestampType)
+  // TODO add DataTypes.TimestampNTZType for Spark 3.4 and later
+  // https://github.com/apache/datafusion-comet/issues/378
+
+  def isSupported(
+      fromType: DataType,
+      toType: DataType,
+      timeZoneId: Option[String],
+      evalMode: String): SupportLevel = {

Review Comment:
   Thanks for adding this. One drawback of manually hardcoding if a cast is 
supported, might be it could be out-of-sync with actual situation.
   
   I think we probably can programatically verify the result is correct.
   
   For example, in arrow-rs, it runs through sample data of supported types, 
and the matrix of supported casts, then runs cast expression to verify if the 
compatibility info is correct.
   
   But for now this is okay.



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to