jinchengchenghh commented on code in PR #8671:
URL: https://github.com/apache/incubator-gluten/pull/8671#discussion_r1960014392


##########
gluten-ut/spark35/src/test/scala/org/apache/spark/sql/hive/execution/GlutenHiveUDFSuite.scala:
##########
@@ -97,43 +49,50 @@ class GlutenHiveUDFSuite
     tableDF.createOrReplaceTempView(table)
   }
 
-  override protected def afterAll(): Unit = {
-    try {
-      hiveContext.reset()
-    } finally {
-      super.afterAll()
-    }
-  }
-
-  override protected def shouldRun(testName: String): Boolean = {
-    false
+  override def afterAll(): Unit = {
+    super.afterAll()
   }
 
   test("customer udf") {
-    sql(s"CREATE TEMPORARY FUNCTION testUDF AS 
'${classOf[CustomerUDF].getName}'")
-    val df = spark.sql("""select testUDF(l_comment)
-                         | from   lineitem""".stripMargin)
-    df.show()
-    print(df.queryExecution.executedPlan)
-    sql("DROP TEMPORARY FUNCTION IF EXISTS testUDF")
-    hiveContext.reset()
+    withTempFunction("testUDF") {
+      sql(s"CREATE TEMPORARY FUNCTION testUDF AS 
'${classOf[CustomerUDF].getName}'")
+      val df = sql("select l_partkey, testUDF(l_comment) from lineitem")
+      df.show()

Review Comment:
   ditto



##########
gluten-ut/spark35/src/test/scala/org/apache/spark/sql/hive/execution/GlutenHiveUDFSuite.scala:
##########
@@ -97,43 +49,50 @@ class GlutenHiveUDFSuite
     tableDF.createOrReplaceTempView(table)
   }
 
-  override protected def afterAll(): Unit = {
-    try {
-      hiveContext.reset()
-    } finally {
-      super.afterAll()
-    }
-  }
-
-  override protected def shouldRun(testName: String): Boolean = {
-    false
+  override def afterAll(): Unit = {

Review Comment:
   Do we need this function?



##########
gluten-ut/spark35/src/test/scala/org/apache/spark/sql/hive/execution/GlutenHiveUDFSuite.scala:
##########
@@ -97,43 +49,50 @@ class GlutenHiveUDFSuite
     tableDF.createOrReplaceTempView(table)
   }
 
-  override protected def afterAll(): Unit = {
-    try {
-      hiveContext.reset()
-    } finally {
-      super.afterAll()
-    }
-  }
-
-  override protected def shouldRun(testName: String): Boolean = {
-    false
+  override def afterAll(): Unit = {
+    super.afterAll()
   }
 
   test("customer udf") {
-    sql(s"CREATE TEMPORARY FUNCTION testUDF AS 
'${classOf[CustomerUDF].getName}'")
-    val df = spark.sql("""select testUDF(l_comment)
-                         | from   lineitem""".stripMargin)
-    df.show()
-    print(df.queryExecution.executedPlan)
-    sql("DROP TEMPORARY FUNCTION IF EXISTS testUDF")
-    hiveContext.reset()
+    withTempFunction("testUDF") {
+      sql(s"CREATE TEMPORARY FUNCTION testUDF AS 
'${classOf[CustomerUDF].getName}'")
+      val df = sql("select l_partkey, testUDF(l_comment) from lineitem")
+      df.show()
+      checkOperatorMatch[ColumnarPartialProjectExec](df)
+    }
   }
 
   test("customer udf wrapped in function") {
-    sql(s"CREATE TEMPORARY FUNCTION testUDF AS 
'${classOf[CustomerUDF].getName}'")
-    val df = spark.sql("""select hash(testUDF(l_comment))
-                         | from   lineitem""".stripMargin)
-    df.show()
-    print(df.queryExecution.executedPlan)
-    sql("DROP TEMPORARY FUNCTION IF EXISTS testUDF")
-    hiveContext.reset()
+    withTempFunction("testUDF") {
+      sql(s"CREATE TEMPORARY FUNCTION testUDF AS 
'${classOf[CustomerUDF].getName}'")
+      val df = sql("select l_partkey, hash(testUDF(l_comment)) from lineitem")
+      df.show()

Review Comment:
   Please drop df.show()



##########
gluten-ut/spark35/src/test/scala/org/apache/spark/sql/hive/execution/GlutenHiveUDFSuite.scala:
##########
@@ -97,43 +49,50 @@ class GlutenHiveUDFSuite
     tableDF.createOrReplaceTempView(table)
   }
 
-  override protected def afterAll(): Unit = {
-    try {
-      hiveContext.reset()
-    } finally {
-      super.afterAll()
-    }
-  }
-
-  override protected def shouldRun(testName: String): Boolean = {
-    false
+  override def afterAll(): Unit = {
+    super.afterAll()
   }
 
   test("customer udf") {
-    sql(s"CREATE TEMPORARY FUNCTION testUDF AS 
'${classOf[CustomerUDF].getName}'")
-    val df = spark.sql("""select testUDF(l_comment)
-                         | from   lineitem""".stripMargin)
-    df.show()
-    print(df.queryExecution.executedPlan)
-    sql("DROP TEMPORARY FUNCTION IF EXISTS testUDF")
-    hiveContext.reset()
+    withTempFunction("testUDF") {
+      sql(s"CREATE TEMPORARY FUNCTION testUDF AS 
'${classOf[CustomerUDF].getName}'")
+      val df = sql("select l_partkey, testUDF(l_comment) from lineitem")
+      df.show()
+      checkOperatorMatch[ColumnarPartialProjectExec](df)
+    }
   }
 
   test("customer udf wrapped in function") {
-    sql(s"CREATE TEMPORARY FUNCTION testUDF AS 
'${classOf[CustomerUDF].getName}'")
-    val df = spark.sql("""select hash(testUDF(l_comment))
-                         | from   lineitem""".stripMargin)
-    df.show()
-    print(df.queryExecution.executedPlan)
-    sql("DROP TEMPORARY FUNCTION IF EXISTS testUDF")
-    hiveContext.reset()
+    withTempFunction("testUDF") {
+      sql(s"CREATE TEMPORARY FUNCTION testUDF AS 
'${classOf[CustomerUDF].getName}'")
+      val df = sql("select l_partkey, hash(testUDF(l_comment)) from lineitem")
+      df.show()
+      checkOperatorMatch[ColumnarPartialProjectExec](df)
+    }
   }
 
   test("example") {
-    spark.sql("CREATE TEMPORARY FUNCTION testUDF AS 
'org.apache.hadoop.hive.ql.udf.UDFSubstr';")
-    spark.sql("select testUDF('l_commen', 1, 5)").show()
-    sql("DROP TEMPORARY FUNCTION IF EXISTS testUDF")
-    hiveContext.reset()
+    withTempFunction("testUDF") {
+      sql("CREATE TEMPORARY FUNCTION testUDF AS 
'org.apache.hadoop.hive.ql.udf.UDFSubstr';")
+      val df = sql("select testUDF('l_commen', 1, 5)")
+      df.show()

Review Comment:
   ditto



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