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


##########
spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala:
##########
@@ -2806,6 +2806,26 @@ class CometExpressionSuite extends CometTestBase with 
AdaptiveSparkPlanHelper {
       }
   }
 
+  test("rand expression with random parameters") {
+    val partitionsNumber = Random.nextInt(10) + 1
+    val rowsNumber = Random.nextInt(500)
+    val seed = Random.nextLong()
+    // use this value to have both single-batch and multi-batch partitions
+    val cometBatchSize = math.max(1, math.ceil(rowsNumber.toDouble / 
partitionsNumber).toInt)
+    withSQLConf("spark.comet.batchSize" -> cometBatchSize.toString) {
+      withParquetDataFrame((0 until rowsNumber).map(Tuple1.apply)) { df =>
+        val dfWithRandParameters = 
df.repartition(partitionsNumber).withColumn("rnd", rand(seed))
+        checkSparkAnswer(dfWithRandParameters)
+        val dfWithOverflowSeed =
+          df.repartition(partitionsNumber).withColumn("rnd", 
rand(Long.MaxValue))
+        checkSparkAnswer(dfWithOverflowSeed)
+        val dfWithNullSeed =
+          df.repartition(partitionsNumber).selectExpr("_1", "rand(null) as 
rnd")
+        checkSparkAnswer(dfWithNullSeed)

Review Comment:
   We should check that the query is actually running natively when Comet is 
enabled:
   
   ```suggestion
           checkSparkAnswerAndOperator(dfWithRandParameters)
           val dfWithOverflowSeed =
             df.repartition(partitionsNumber).withColumn("rnd", 
rand(Long.MaxValue))
           checkSparkAnswerAndOperator(dfWithOverflowSeed)
           val dfWithNullSeed =
             df.repartition(partitionsNumber).selectExpr("_1", "rand(null) as 
rnd")
           checkSparkAnswerAndOperator(dfWithNullSeed)
   ```



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