cloud-fan commented on code in PR #52546:
URL: https://github.com/apache/spark/pull/52546#discussion_r2420075650


##########
sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/DataFrameTableValuedFunctionsSuite.scala:
##########
@@ -23,6 +23,17 @@ import org.apache.spark.sql.functions._
 class DataFrameTableValuedFunctionsSuite extends QueryTest with 
RemoteSparkSession {
   import testImplicits._
 
+  test("preserve plan ID in ResolveSQLFunctions with UDF") {
+    // Create a simple SQL function / UDF for testing purposes.
+    spark.sql("""CREATE OR REPLACE FUNCTION funct(x INT) RETURNS STRING RETURN
+      CASE WHEN x >= 0 THEN 'foo' ELSE 'bar' END""")
+    val df = spark
+      .sql("SELECT * FROM VALUES (0, 1)")
+      .select(expr("funct(col1)").alias("col2"))
+    // Now use the UDF in a query that will initiate plan rewrite by 
ResolveSQLFunctions.
+    df.groupBy("col2").agg(count("*")).explain(true)

Review Comment:
   can we use `checkAnswer`?



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

Reply via email to