viirya commented on code in PR #107:
URL:
https://github.com/apache/arrow-datafusion-comet/pull/107#discussion_r1501687179
##########
spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala:
##########
@@ -1302,4 +1304,50 @@ class CometExpressionSuite extends CometTestBase with
AdaptiveSparkPlanHelper {
}
}
}
+
+ test("test cast utf8 to boolean as compatible with Spark") {
+ withSQLConf(
+ CometConf.COMET_ENABLED.key -> "true",
+ CometConf.COMET_EXEC_ALL_OPERATOR_ENABLED.key -> "true") {
+ withTable("test_table1", "test_table2", "test_table3", "test_table4") {
+ // Supported boolean values as true by both Arrow and Spark
+ val inputDF = Seq("t", "true", "y", "yes", "1", "T", "TrUe", "Y",
"YES").toDF("c1")
+ inputDF.write.format("parquet").saveAsTable("test_table1")
+ val resultDF = this.spark
+ .table("test_table1")
+ .withColumn("converted", col("c1").cast(DataTypes.BooleanType))
+ val resultArr = resultDF.collectAsList().toList
+ resultArr.foreach(x => assert(x.get(1) == true))
Review Comment:
Besides this, we can use `checkSparkAnswerAndOperator` to check if the
result is same as Spark.
--
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]