Skip to content

Commit

Permalink
improve reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed May 2, 2024
1 parent 7c39b05 commit 787d17b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
20 changes: 11 additions & 9 deletions spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
Original file line number Diff line number Diff line change
Expand Up @@ -588,23 +588,25 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde {
}
val castSupport =
CometCast.isSupported(cast, child.dataType, dt, timeZoneId, evalModeStr)

def getIncompatMessage(reason: Option[String]) =
s"Comet does not guarantee correct results for cast " +
s"from ${child.dataType} to $dt " +
s"with timezone $timeZoneId and evalMode $evalModeStr" +
reason.map(str => s" ($str)").getOrElse("")

castSupport match {
case Compatible =>
castToProto(timeZoneId, dt, childExpr, evalModeStr)
case Incompatible(reason) =>
if (CometConf.COMET_CAST_ALLOW_INCOMPATIBLE.get()){
logWarning(s"Calling incompatible CAST expression: $cast" +
reason.map(str => s" ($str)").getOrElse(""))
if (CometConf.COMET_CAST_ALLOW_INCOMPATIBLE.get()) {
logWarning(getIncompatMessage(reason))
castToProto(timeZoneId, dt, childExpr, evalModeStr)
} else {
withInfo(
expr,
s"Comet does not guarantee correct results for cast " +
s"from ${child.dataType} to $dt " +
s"with timezone $timeZoneId and evalMode $evalModeStr" +
reason.map(str => s" ($str)").getOrElse("") + "." +
s"To enable all incompatible casts, set " +
s"${CometConf.COMET_CAST_ALLOW_INCOMPATIBLE.key}=true"
s"${getIncompatMessage(reason)}. To enable all incompatible casts, set " +
s"${CometConf.COMET_CAST_ALLOW_INCOMPATIBLE.key}=true"
)
None
}
Expand Down
2 changes: 0 additions & 2 deletions spark/src/test/scala/org/apache/comet/CometCastSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package org.apache.comet

import org.apache.comet.expressions.{CometCast, Compatible}

import java.io.File
import scala.util.Random
import org.apache.spark.sql.{CometTestBase, DataFrame, SaveMode}
Expand Down
3 changes: 0 additions & 3 deletions spark/src/test/scala/org/apache/spark/sql/CometTestBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,10 @@ abstract class CometTestBase
withSQLConf(CometConf.COMET_ENABLED.key -> "false") {
val dfSpark = Dataset.ofRows(spark, df.logicalPlan)
expected = dfSpark.collect()
dfSpark.show()
sparkPlan = dfSpark.queryExecution.executedPlan
}
val dfComet = Dataset.ofRows(spark, df.logicalPlan)
checkAnswer(dfComet, expected)
dfComet.show()
println(dfComet.queryExecution.executedPlan)
(sparkPlan, dfComet.queryExecution.executedPlan)
}

Expand Down

0 comments on commit 787d17b

Please sign in to comment.