Skip to content

Commit

Permalink
bug fixes and supporting try_Cast
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhawvipul committed May 15, 2024
1 parent 57dfe84 commit 63c0c14
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.apache.comet.serde

import scala.collection.JavaConverters._
import scala.reflect.macros.whitebox.Context

import org.apache.spark.internal.Logging
import org.apache.spark.sql.catalyst.expressions._
Expand Down Expand Up @@ -619,7 +618,7 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim
CometCast.isSupported(child.dataType, dt, timeZoneId, actualEvalModeStr)

def getIncompatMessage(reason: Option[String]): String =
s"Comet does not guarantee correct results for cast " +
"Comet does not guarantee correct results for cast " +
s"from ${child.dataType} to $dt " +
s"with timezone $timeZoneId and evalMode $actualEvalModeStr" +
reason.map(str => s" ($str)").getOrElse("")
Expand Down Expand Up @@ -664,8 +663,9 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim
val value = cast.eval()
exprToProtoInternal(Literal(value, dataType), inputs)

case TryCast(child, dt, timeZoneId) =>
handleCast(child, inputs, dt, timeZoneId, "TRY")
case UnaryExpression(child) if expr.prettyName == "trycast" =>
val timeZoneId = SQLConf.get.sessionLocalTimeZone
handleCast(child, inputs, expr.dataType, Some(timeZoneId), "TRY")

case Cast(child, dt, timeZoneId, evalMode) =>
val evalModeStr = if (evalMode.isInstanceOf[Boolean]) {
Expand Down

0 comments on commit 63c0c14

Please sign in to comment.