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 2022/12/20 01:45:31 UTC

[GitHub] [spark] allisonwang-db opened a new pull request, #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

allisonwang-db opened a new pull request, #39133:
URL: https://github.com/apache/spark/pull/39133

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   This PR supports using table-valued generator functions in the FROM clause of a query. A generator function can be registered in the table function registry and resolved as a table function during analysis.
   
   Note this PR only adds support for two built-in generator functions: `explode` and `explode_outer` with literal input values. We will support more generator functions and LATERAL references in separate PRs.
   
   ### Why are the changes needed?
   To make table-valued generator functions more user-friendly and consistent with Spark's built-in table function Range.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. Before this PR, the built-in generator function explode/explode_outer cannot be used in the FROM clause:
   ```
   select * from explode(array(1, 2))
   
   AnalysisException: could not resolve `explode` to a table-valued function;
   ```
   After this PR, we can support this usage:
   ```
   select * from explode(array(1, 2))
   
   +---+
   |col|
   +---+
   |  1|
   |  2|
   +---+
   ```
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   New SQL query tests.


-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1056874155


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreePatterns.scala:
##########
@@ -134,6 +134,7 @@ object TreePattern extends Enumeration  {
   val UNRESOLVED_WINDOW_EXPRESSION: Value = Value
 
   // Unresolved Plan patterns (Alphabetically ordered)
+  val TABLE_VALUED_FUNCTION_WITH_ALIAS: Value = Value

Review Comment:
   Since we already have `UNRESOLVED_TABLE_VALUED_FUNCTION`, according to the convention,
   `TABLE_VALUED_FUNCTION_WITH_ALIAS` -> `UNRESOLVED_TABLE_VALUED_FUNCTION_WITH_ALIAS`?



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreePatterns.scala:
##########
@@ -134,6 +134,7 @@ object TreePattern extends Enumeration  {
   val UNRESOLVED_WINDOW_EXPRESSION: Value = Value
 
   // Unresolved Plan patterns (Alphabetically ordered)
+  val TABLE_VALUED_FUNCTION_WITH_ALIAS: Value = Value

Review Comment:
   Since we already have `UNRESOLVED_TABLE_VALUED_FUNCTION`, according to the convention,
   `TABLE_VALUED_FUNCTION_WITH_ALIAS` -> `UNRESOLVED_TABLE_VALUED_FUNCTION_WITH_ALIAS`?



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] cloud-fan commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1063066073


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala:
##########
@@ -123,16 +117,59 @@ object UnresolvedTableValuedFunction {
 
   def apply(
       name: String,
-      functionArgs: Seq[Expression],
-      outputNames: Seq[String]): UnresolvedTableValuedFunction = {
-    UnresolvedTableValuedFunction(Seq(name), functionArgs, outputNames)
+      functionArgs: Seq[Expression]): UnresolvedTableValuedFunction = {
+    UnresolvedTableValuedFunction(Seq(name), functionArgs)
+  }
+
+  def apply(
+      name: FunctionIdentifier,
+      functionArgs: Seq[Expression]): UnresolvedTableValuedFunction = {
+    UnresolvedTableValuedFunction(name.asMultipart, functionArgs)
+  }
+}
+
+/**
+ * A table-valued function with output column aliases, e.g.
+ * {{{
+ *   // Assign alias names
+ *   select t.a from range(10) t(a);
+ * }}}
+ *
+ * @param name qualified name of the table-valued function

Review Comment:
   Is this really a qualified name? It seems this is the user-specified function name in the original SQL text.



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] cloud-fan commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1055027009


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala:
##########
@@ -960,8 +960,27 @@ object TableFunctionRegistry {
     (name, (info, (expressions: Seq[Expression]) => builder(expressions)))
   }
 
+  def generator[T <: Generator : ClassTag](name: String, outer: Boolean = false)
+      : (String, (ExpressionInfo, TableFunctionBuilder)) = {
+    val (info, builder) = FunctionRegistryBase.build[T](name, since = None)
+    val newBuilder = (expressions: Seq[Expression]) => {
+      val generator = builder(expressions)
+      assert(generator.isInstanceOf[Generator])
+      Generate(
+        generator,
+        unrequiredChildIndex = Nil,
+        outer = outer,
+        qualifier = None,
+        generatorOutput = Nil,

Review Comment:
   is it guaranteed that we will assign the `generatorOutput` later?



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] cloud-fan commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1054445140


##########
sql/core/src/test/resources/sql-tests/inputs/table-valued-functions.sql:
##########
@@ -27,3 +27,33 @@ select * from range(0, 5, 0);
 
 -- range call with a mixed-case function name
 select * from RaNgE(2);
+
+-- explode
+select * from explode(array(1, 2));
+select * from explode(map('a', 1, 'b', 2));
+
+-- explode with empty values
+select * from explode(array());
+select * from explode(map());
+
+-- explode with column aliases
+select * from explode(array(1, 2)) t(c1);
+select * from explode(map('a', 1, 'b', 2)) t(k, v);
+
+-- explode with erroneous input

Review Comment:
   can we also test invalid cases? e.g. when we use column as input (LATERAL subquery), not literals.



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] allisonwang-db commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
allisonwang-db commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1055061149


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala:
##########
@@ -960,8 +960,27 @@ object TableFunctionRegistry {
     (name, (info, (expressions: Seq[Expression]) => builder(expressions)))
   }
 
+  def generator[T <: Generator : ClassTag](name: String, outer: Boolean = false)
+      : (String, (ExpressionInfo, TableFunctionBuilder)) = {
+    val (info, builder) = FunctionRegistryBase.build[T](name, since = None)
+    val newBuilder = (expressions: Seq[Expression]) => {
+      val generator = builder(expressions)
+      assert(generator.isInstanceOf[Generator])
+      Generate(
+        generator,
+        unrequiredChildIndex = Nil,
+        outer = outer,
+        qualifier = None,
+        generatorOutput = Nil,

Review Comment:
   Yes. Generate is only resolved when its output length equals to the generator.elementSchema length.
   https://github.com/apache/spark/blob/6e537f30ac2b19617c6cc11dd4f7f92946988f7b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala#L267-L272
   The Generate created here will be resolved by `ResolveGenerate`.



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] cloud-fan commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1054443970


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala:
##########
@@ -960,8 +960,34 @@ object TableFunctionRegistry {
     (name, (info, (expressions: Seq[Expression]) => builder(expressions)))
   }
 
+  def generator[T <: Generator : ClassTag](name: String, outer: Boolean = false)
+      : (String, (ExpressionInfo, TableFunctionBuilder)) = {
+    val (info, builder) = FunctionRegistryBase.build[T](name, since = None)
+    val newBuilder = (expressions: Seq[Expression]) => {
+      val generator = builder(expressions)
+      assert(generator.isInstanceOf[Generator])
+      // Check nested generators.
+      if (expressions.exists(_.find(_.isInstanceOf[Generator]).nonEmpty)) {
+        throw QueryCompilationErrors.nestedGeneratorError(generator)
+      }
+      // If the generator is not resolved, leave the output empty and wait for CheckAnalysis
+      // to throw appropriate exceptions.

Review Comment:
   do we have tests for this case?



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] cloud-fan commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1054445140


##########
sql/core/src/test/resources/sql-tests/inputs/table-valued-functions.sql:
##########
@@ -27,3 +27,33 @@ select * from range(0, 5, 0);
 
 -- range call with a mixed-case function name
 select * from RaNgE(2);
+
+-- explode
+select * from explode(array(1, 2));
+select * from explode(map('a', 1, 'b', 2));
+
+-- explode with empty values
+select * from explode(array());
+select * from explode(map());
+
+-- explode with column aliases
+select * from explode(array(1, 2)) t(c1);
+select * from explode(map('a', 1, 'b', 2)) t(k, v);
+
+-- explode with erroneous input

Review Comment:
   can we also test invalid cases? e.g. when we use column as input, not literals.



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] allisonwang-db commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
allisonwang-db commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1057781800


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreePatterns.scala:
##########
@@ -134,6 +134,7 @@ object TreePattern extends Enumeration  {
   val UNRESOLVED_WINDOW_EXPRESSION: Value = Value
 
   // Unresolved Plan patterns (Alphabetically ordered)
+  val TABLE_VALUED_FUNCTION_WITH_ALIAS: Value = Value

Review Comment:
   I was thinking about using `UNRESOLVED_TABLE_VALUED_FUNCTION_WITH_ALIAS` but we need to distinguish between 
   1) an unresolved table-valued function with a string function name and 
   2) an unresolved table-valued function that has been looked up in the function registry, but its function body (logical plan) and output aliases have not been resolved yet.
   
   So if we use `UNRESOLVED_TABLE_VALUED_FUNCTION_WITH_ALIAS`, it can be confusing to make it a unary node vs a leaf node like `UNRESOLVED_TABLE_VALUED_FUNCTION`.
   
   Let me know what you think @dongjoon-hyun 



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] cloud-fan commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1054440985


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -2251,7 +2251,7 @@ class Analyzer(override val catalogManager: CatalogManager)
                 messageParameters = Map("name" -> u.name.quoted))
           }
           // If alias names assigned, add `Project` with the aliases
-          if (u.outputNames.nonEmpty) {
+          if (resolvedFunc.resolved && u.outputNames.nonEmpty) {

Review Comment:
   how can `resolvedFunc` be unresolved?



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] allisonwang-db commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
allisonwang-db commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1054612098


##########
sql/core/src/test/resources/sql-tests/inputs/table-valued-functions.sql:
##########
@@ -27,3 +27,33 @@ select * from range(0, 5, 0);
 
 -- range call with a mixed-case function name
 select * from RaNgE(2);
+
+-- explode
+select * from explode(array(1, 2));
+select * from explode(map('a', 1, 'b', 2));
+
+-- explode with empty values
+select * from explode(array());
+select * from explode(map());
+
+-- explode with column aliases
+select * from explode(array(1, 2)) t(c1);
+select * from explode(map('a', 1, 'b', 2)) t(k, v);
+
+-- explode with erroneous input

Review Comment:
   I will create another PR to support explode with LATERAL references. 



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -2251,7 +2251,7 @@ class Analyzer(override val catalogManager: CatalogManager)
                 messageParameters = Map("name" -> u.name.quoted))
           }
           // If alias names assigned, add `Project` with the aliases
-          if (u.outputNames.nonEmpty) {
+          if (resolvedFunc.resolved && u.outputNames.nonEmpty) {

Review Comment:
   The input arguments of the function may have incompatible data types. I will update this to make it more clear.



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] cloud-fan commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1057233265


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreePatterns.scala:
##########
@@ -134,6 +134,7 @@ object TreePattern extends Enumeration  {
   val UNRESOLVED_WINDOW_EXPRESSION: Value = Value
 
   // Unresolved Plan patterns (Alphabetically ordered)
+  val TABLE_VALUED_FUNCTION_WITH_ALIAS: Value = Value

Review Comment:
   It contains resolved TVF, but the column alias is not resolved yet.



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1056874276


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreePatterns.scala:
##########
@@ -134,6 +134,7 @@ object TreePattern extends Enumeration  {
   val UNRESOLVED_WINDOW_EXPRESSION: Value = Value
 
   // Unresolved Plan patterns (Alphabetically ordered)
+  val TABLE_VALUED_FUNCTION_WITH_ALIAS: Value = Value

Review Comment:
   If we change this, we also need to rename the case class `TableValuedFunctionWithAlias` too.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreePatterns.scala:
##########
@@ -134,6 +134,7 @@ object TreePattern extends Enumeration  {
   val UNRESOLVED_WINDOW_EXPRESSION: Value = Value
 
   // Unresolved Plan patterns (Alphabetically ordered)
+  val TABLE_VALUED_FUNCTION_WITH_ALIAS: Value = Value

Review Comment:
   If we change this, we also had better rename the case class `TableValuedFunctionWithAlias` too.



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1059224075


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala:
##########
@@ -136,6 +136,30 @@ object UnresolvedTableValuedFunction {
   }
 }
 
+/**
+ * A table-valued function with output column aliases. The table function has been
+ * looked up and turned into a logical plan.
+ *
+ * @param name qualified name of the table-valued function
+ * @param child logical plan of the table-valued function
+ * @param outputNames alias names of function output columns. The analyzer adds [[Project]]
+ *                    to rename the output columns.
+ */
+case class TableValuedFunctionWithAlias(

Review Comment:
   +1 for @cloud-fan 's suggestion.



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] cloud-fan commented on pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on PR #39133:
URL: https://github.com/apache/spark/pull/39133#issuecomment-1376778232

   The failed python ml tests are definitely unrelated, merging to master, thanks!


-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] allisonwang-db commented on pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
allisonwang-db commented on PR #39133:
URL: https://github.com/apache/spark/pull/39133#issuecomment-1359554909

   cc @cloud-fan 


-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] cloud-fan commented on a diff in pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39133:
URL: https://github.com/apache/spark/pull/39133#discussion_r1058032279


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala:
##########
@@ -136,6 +136,30 @@ object UnresolvedTableValuedFunction {
   }
 }
 
+/**
+ * A table-valued function with output column aliases. The table function has been
+ * looked up and turned into a logical plan.
+ *
+ * @param name qualified name of the table-valued function
+ * @param child logical plan of the table-valued function
+ * @param outputNames alias names of function output columns. The analyzer adds [[Project]]
+ *                    to rename the output columns.
+ */
+case class TableValuedFunctionWithAlias(

Review Comment:
   I think the confusing part is, `UnresolvedTableValuedFunction` contains alias as well. If we add a new node `UnresolvedTVFAlias`, this could be clearer:
   - parser creates `UnresolvedTVFAlias(UnresolvedTableValuedFunction)`
   - analyzer turns `UnresolvedTableValuedFunction` into resolved TVF plan
   - analyzer turns `UnresolvedTVFAlias` into `Project` if its child is resolved.



-- 
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: reviews-unsubscribe@spark.apache.org

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


[GitHub] [spark] cloud-fan closed pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause

Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #39133: [SPARK-41595][SQL] Support generator function explode/explode_outer in the FROM clause
URL: https://github.com/apache/spark/pull/39133


-- 
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: reviews-unsubscribe@spark.apache.org

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