cloud-fan commented on code in PR #45652:
URL: https://github.com/apache/spark/pull/45652#discussion_r1538470659


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/ResolveSubquerySuite.scala:
##########
@@ -270,4 +271,32 @@ class ResolveSubquerySuite extends AnalysisTest {
       ), Seq(a, b)).as("sub") :: Nil, t1)
     )
   }
+
+  test("SPARK-47509: Incorrect results for subquery expressions in 
LambdaFunctions") {
+    val data = LocalRelation(Seq(
+      $"key".int,
+      $"values1".array(IntegerType),
+      $"values2".array(ArrayType(ArrayType(IntegerType)))))
+
+    def plan(e: Expression): LogicalPlan = data.select(e.as("res"))
+
+    def lv(s: Symbol): UnresolvedNamedLambdaVariable =
+      UnresolvedNamedLambdaVariable(Seq(s.name))
+
+    val lambdaPlanScanFromTable: LogicalPlan = plan(
+      LambdaFunction(
+        function = lv(Symbol("x")) + lv(Symbol("X")),
+        arguments = Alias(
+          child = ScalarSubquery(
+            plan(lv(Symbol("x")))),
+          name = "alias")()
+          :: lv(Symbol("X"))
+          :: Nil))
+
+    assertAnalysisErrorClass(
+      inputPlan = lambdaPlanScanFromTable,
+      expectedErrorClass =
+        
"UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY.LAMBDA_OR_HIGHER_ORDER_FUNCTION",

Review Comment:
   ```suggestion
           "UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY.HIGHER_ORDER_FUNCTION",
   ```



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