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/04/06 01:10:56 UTC

[GitHub] [spark] maropu commented on a change in pull request #31887: [SPARK-34794][SQL] fix nested transform issue

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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/functions.scala
##########
@@ -3799,23 +3801,26 @@ object functions {
     ArrayExcept(col1.expr, col2.expr)
   }
 
+  // counter to ensure lambda variable names are unique
+  private val lambdaVarNameCounter = new AtomicInteger(0)

Review comment:
       How about defining a companion object for UnresolvedNamedLambdaVariable like this?
   ```
   
   object UnresolvedNamedLambdaVariable {
   
     // counter to ensure lambda variable names are unique
     private val lambdaVarNameCounter = new AtomicInteger(0)
   
     def apply(args: Seq[String]): UnresolvedNamedLambdaVariable = {
       // add a counter number in the suffix
     }
   }
   ```

##########
File path: sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala
##########
@@ -2261,6 +2261,32 @@ class DataFrameFunctionsSuite extends QueryTest with SharedSparkSession {
     assert(ex3.getMessage.contains("cannot resolve 'a'"))
   }
 
+  test("nested transform (DSL)") {

Review comment:
       nit: `nested transform (DSL)` -> `SPARK-34794: nested transform`

##########
File path: sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala
##########
@@ -2261,6 +2261,32 @@ class DataFrameFunctionsSuite extends QueryTest with SharedSparkSession {
     assert(ex3.getMessage.contains("cannot resolve 'a'"))
   }
 
+  test("nested transform (DSL)") {
+    val df = Seq(
+        (Seq(1, 2, 3), Seq("a", "b", "c"))
+    ).toDF("numbers", "letters")
+
+    checkAnswer(
+        df.select(
+          flatten(
+            transform(
+              $"numbers",
+              (number: Column) => transform(

Review comment:
       I think we need exhaustive tests for this issue, e.g., two/three argument cases and their combination cases.




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