marin-ma commented on code in PR #13530:
URL: https://github.com/apache/gluten/pull/13530#discussion_r4536019834


##########
backends-velox/src/test/scala/org/apache/gluten/expression/VeloxUdfSuite.scala:
##########
@@ -297,56 +300,78 @@ abstract class VeloxUdfSuite extends GlutenQueryTest with 
SQLHelper {
     }
   }
 
-  test("native udf with a plain name is callable without a hive udf class") {
-    // No CREATE TEMPORARY FUNCTION and no Java class: the session extension 
put the name in
-    // Spark's registry via SparkInjector.injectFunction, which is the only 
writer for it.
-    assert(
-      spark.sessionState.functionRegistry
-        .lookupFunction(FunctionIdentifier("myudf_plus_one"))
-        .isDefined)
-
-    val df = spark.sql("SELECT myudf_plus_one(col1) FROM VALUES (1L), (2L), 
(3L) AS t(col1)")
-    checkGlutenPlan[ProjectExecTransformer](df)
-    checkAnswer(df, Seq(Row(2L), Row(3L), Row(4L)))
-  }
+  if (bypassRegistration) {
+    test("native udf with a plain name is callable without a hive udf class") {

Review Comment:
   It would be better to use a helper function `testBypassRegistration` for 
these tests rather than put them into a `if`. 



##########
backends-velox/src/test/scala/org/apache/gluten/expression/VeloxUdfSuite.scala:
##########
@@ -297,56 +300,78 @@ abstract class VeloxUdfSuite extends GlutenQueryTest with 
SQLHelper {
     }
   }
 
-  test("native udf with a plain name is callable without a hive udf class") {
-    // No CREATE TEMPORARY FUNCTION and no Java class: the session extension 
put the name in
-    // Spark's registry via SparkInjector.injectFunction, which is the only 
writer for it.
-    assert(
-      spark.sessionState.functionRegistry
-        .lookupFunction(FunctionIdentifier("myudf_plus_one"))
-        .isDefined)
-
-    val df = spark.sql("SELECT myudf_plus_one(col1) FROM VALUES (1L), (2L), 
(3L) AS t(col1)")
-    checkGlutenPlan[ProjectExecTransformer](df)
-    checkAnswer(df, Seq(Row(2L), Row(3L), Row(4L)))
-  }
+  if (bypassRegistration) {
+    test("native udf with a plain name is callable without a hive udf class") {
+      // No CREATE TEMPORARY FUNCTION and no Java class: the session extension 
put the name in
+      // Spark's registry via SparkInjector.injectFunction, which is the only 
writer for it.
+      assert(
+        spark.sessionState.functionRegistry
+          .lookupFunction(FunctionIdentifier("myudf_plus_one"))
+          .isDefined)
+
+      val df = spark.sql("SELECT myudf_plus_one(col1) FROM VALUES (1L), (2L), 
(3L) AS t(col1)")
+      checkGlutenPlan[ProjectExecTransformer](df)
+      checkAnswer(df, Seq(Row(2L), Row(3L), Row(4L)))
+    }
 
-  test("native udf with a plain name fails at analysis when gluten is 
disabled") {
-    withSQLConf(("spark.gluten.enabled", "false")) {
-      val e = intercept[Exception] {
-        spark.sql("SELECT myudf_plus_one(col1) FROM VALUES (1L) AS 
t(col1)").collect()
+    test("native udf with a plain name fails at analysis when gluten is 
disabled") {
+      withSQLConf(("spark.gluten.enabled", "false")) {
+        val e = intercept[Exception] {
+          spark.sql("SELECT myudf_plus_one(col1) FROM VALUES (1L) AS 
t(col1)").collect()
+        }
+        // The injected function has no JVM implementation to fall back to, so 
the call is
+        // rejected rather than silently returning a result from somewhere 
else.
+        assert(e.getMessage.contains("myudf_plus_one"))
       }
-      // The injected function has no JVM implementation to fall back to, so 
the call is
-      // rejected rather than silently returning a result from somewhere else.
-      assert(e.getMessage.contains("myudf_plus_one"))
     }
-  }
 
-  test("native udf with a named row argument is callable") {
-    // given
-    val query = "SELECT myudf_sum_row(named_struct('a', col1, 'b', col2)) " +
-      "FROM VALUES (1L, 2L), (3L, 4L) AS t(col1, col2)"
-    val expected = Seq(Row(3L), Row(7L))
+    test("native udf with a named row argument is callable") {
+      // given
+      val query = "SELECT myudf_sum_row(named_struct('a', col1, 'b', col2)) " +
+        "FROM VALUES (1L, 2L), (3L, 4L) AS t(col1, col2)"
+      val expected = Seq(Row(3L), Row(7L))
 
-    // when
-    val df = spark.sql(query)
+      // when
+      val df = spark.sql(query)
 
-    // then
-    checkGlutenPlan[ProjectExecTransformer](df)
-    checkAnswer(df, expected)
-  }
+      // then
+      checkGlutenPlan[ProjectExecTransformer](df)
+      checkAnswer(df, expected)
+    }
 
-  test("native udf returning a named row exposes its field names") {
-    // given
-    val query = "SELECT myudf_make_row(col1).b FROM VALUES (1L), (2L) AS 
t(col1)"
-    val expected = Seq(Row(2L), Row(3L))
+    test("native udf returning a named row exposes its field names") {
+      // given
+      val query = "SELECT myudf_make_row(col1).b FROM VALUES (1L), (2L) AS 
t(col1)"
+      val expected = Seq(Row(2L), Row(3L))
 
-    // when
-    val df = spark.sql(query)
+      // when
+      val df = spark.sql(query)
 
-    // then
-    checkGlutenPlan[ProjectExecTransformer](df)
-    checkAnswer(df, expected)
+      // then
+      checkGlutenPlan[ProjectExecTransformer](df)
+      checkAnswer(df, expected)
+    }
+  } else {
+    test("native udf names are not registered when bypass registration is 
disabled") {
+      val queries = Seq(

Review Comment:
   And add `if (!bypassRegistration)` only in this test.



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