coderfender commented on code in PR #3083:
URL: https://github.com/apache/datafusion-comet/pull/3083#discussion_r2757405466
##########
spark/src/test/scala/org/apache/comet/CometCastSuite.scala:
##########
@@ -1342,28 +1357,32 @@ class CometCastSuite extends CometTestBase with
AdaptiveSparkPlanHelper {
input: DataFrame,
toType: DataType,
hasIncompatibleType: Boolean = false,
- testAnsi: Boolean = true): Unit = {
+ testAnsi: Boolean = true,
+ testTry: Boolean = true): Unit = {
withTempPath { dir =>
val data = roundtripParquet(input, dir).coalesce(1)
- data.createOrReplaceTempView("t")
withSQLConf((SQLConf.ANSI_ENABLED.key, "false")) {
// cast() should return null for invalid inputs when ansi mode is
disabled
- val df = spark.sql(s"select a, cast(a as ${toType.sql}) from t order
by a")
+ val df = data.select(col("a"), col("a").cast(toType)).orderBy(col("a"))
if (hasIncompatibleType) {
checkSparkAnswer(df)
} else {
checkSparkAnswerAndOperator(df)
}
- // try_cast() should always return null for invalid inputs
- val df2 =
- spark.sql(s"select a, try_cast(a as ${toType.sql}) from t order by
a")
- if (hasIncompatibleType) {
- checkSparkAnswer(df2)
- } else {
- checkSparkAnswerAndOperator(df2)
+ if (testTry) {
+ data.createOrReplaceTempView("t")
+ // try_cast() should always return null for invalid inputs
+// not using spark DSL since it `try_cast` is only available from
Spark 4x
Review Comment:
<img width="885" height="369" alt="image"
src="https://github.com/user-attachments/assets/cec8b2ed-cbea-4dd0-aaa7-c52fce7b03cb"
/>
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]