andygrove commented on code in PR #1073:
URL: https://github.com/apache/datafusion-comet/pull/1073#discussion_r1847400001


##########
spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala:
##########
@@ -2337,4 +2337,35 @@ class CometExpressionSuite extends CometTestBase with 
AdaptiveSparkPlanHelper {
 
     }
   }
+
+  test("ArrayInsert") {
+    assume(isSpark34Plus)
+    Seq(true, false).foreach(dictionaryEnabled =>
+      withTempDir { dir =>
+        val path = new Path(dir.toURI.toString, "test.parquet")
+        makeParquetFileAllTypes(path, dictionaryEnabled, 10000)
+        val df = spark.read
+          .parquet(path.toString)
+          .withColumn("arr", array(col("_4"), lit(null), col("_4")))
+          .withColumn("arrInsertResult", expr("array_insert(arr, 1, 1)"))
+          .withColumn("arrInsertNegativeIndexResult", expr("array_insert(arr, 
-1, 1)"))
+        checkSparkAnswerAndOperator(df.select("arrInsertResult"))
+        checkSparkAnswerAndOperator(df.select("arrInsertNegativeIndexResult"))
+      })
+  }
+
+  test("ArrayInsertUnsupportedArgs") {
+    // This test checks that the else branch in ArrayInsert
+    // mapping to the comet is valid and fallback to spark is working fine.
+    assume(isSpark34Plus)
+    withTempDir { dir =>
+      val path = new Path(dir.toURI.toString, "test.parquet")
+      makeParquetFileAllTypes(path, dictionaryEnabled = false, 10000)
+      spark.read
+        .parquet(path.toString)
+        .withColumn("arr", array(col("_4"), lit(null), col("_4")))
+        .withColumn("idx", udf((x: Int) => x).apply(col("_4")))
+        .withColumn("arrUnsupportedArgs", expr("array_insert(arr, idx, 1)"))

Review Comment:
   This code appears to construct a DataFrame but does not actually execute a 
query? Also there are not any assertions to check for expected behavior, so 
this looks like it needs some more work.



-- 
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