You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/02/18 05:00:14 UTC

[GitHub] [spark] maropu commented on a change in pull request #31550: [SPARK-34421][SQL] Resolve temporary functions and views in views with CTEs

maropu commented on a change in pull request #31550:
URL: https://github.com/apache/spark/pull/31550#discussion_r578132323



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -3943,6 +3943,43 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
       }
     }
   }
+
+  test("SPARK-34421: Resolve temporary functions and views in views with CTEs") {
+    val tempViewName = "temp_view"
+
+    withTempView(tempViewName) {
+      spark.udf.register("temp_func", identity[Int](_))

Review comment:
       Could you use `withUserDefinedFunction`?

##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -3943,6 +3943,43 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
       }
     }
   }
+
+  test("SPARK-34421: Resolve temporary functions and views in views with CTEs") {

Review comment:
       Is this issue only related to a temp function case? How about a permanent one?

##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
##########
@@ -557,23 +557,30 @@ object ViewHelper {
   private def collectTemporaryObjects(
       catalog: SessionCatalog, child: LogicalPlan): (Seq[Seq[String]], Seq[String]) = {
     def collectTempViews(child: LogicalPlan): Seq[Seq[String]] = {
-      child.collect {
+      child.flatMap {

Review comment:
       I have the same comment, too. IMO the previous one looks okay.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org