allisonwang-db commented on a change in pull request #32787:
URL: https://github.com/apache/spark/pull/32787#discussion_r662017168



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisErrorSuite.scala
##########
@@ -807,4 +807,48 @@ class AnalysisErrorSuite extends AnalysisTest {
     // UnresolvedHint be removed by batch `Remove Unresolved Hints`
     assertAnalysisSuccess(plan, true)
   }
+
+  test("SPARK-35618: Resolve star expressions in subqueries") {
+    val a = AttributeReference("a", IntegerType)()
+    val b = AttributeReference("b", IntegerType)()
+    val t0 = OneRowRelation()
+    val t1 = LocalRelation(a, b).as("t1")
+
+    // t1.* in the subquery should be resolved into outer(t1.a) and 
outer(t1.b).
+    assertAnalysisError(
+      Project(ScalarSubquery(t0.select(star("t1"))).as("sub") :: Nil, t1),
+      "Scalar subquery must return only one column, but got 2" :: Nil)
+
+    // array(t1.*) in the subquery should be resolved into array(outer(t1.a), 
outer(t1.b))
+    val array = CreateArray(Seq(star("t1")))
+    assertAnalysisError(
+      Project(ScalarSubquery(t0.select(array)).as("sub") :: Nil, t1),
+      "Expressions referencing the outer query are not supported" :: Nil)

Review comment:
       Yes star in `CreateArray` is valid. I truncated this error message but 
the complete one is `"Expressions referencing the outer query are not supported 
outside of WHERE/HAVING clauses"`. Will update the message to be clearer.




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