anchovYu commented on code in PR #39040:
URL: https://github.com/apache/spark/pull/39040#discussion_r1047597647


##########
sql/core/src/test/scala/org/apache/spark/sql/LateralColumnAliasSuite.scala:
##########
@@ -268,46 +507,87 @@ class LateralColumnAliasSuite extends QueryTest with 
SharedSparkSession {
   }
   // TODO: more tests on LCA in subquery
 
-  test("Lateral alias of a complex type - Project") {
-    checkAnswer(
-      sql("SELECT named_struct('a', 1) AS foo, foo.a + 1 AS bar, bar + 1"),
-      Row(Row(1), 2, 3))
-
-    checkAnswer(
-      sql("SELECT named_struct('a', named_struct('b', 1)) AS foo, foo.a.b + 1 
AS bar"),
-      Row(Row(Row(1)), 2)
-    )
+  test("Lateral alias conflicts with OuterReference - Aggregate") {
+    // test if lca rule strips the OuterReference and resolves to lateral alias
+    val query =

Review Comment:
   @cloud-fan  As we discussed yesterday, I tried to just plainly substitute 
the id with the expression, and yes it no longer throws exception during 
analysis, but during execution.
   
   * When LCA is off, the id is resolved to outer reference, it throws 
exception during analysis:
     
[UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY.NON_CORRELATED_COLUMNS_IN_GROUP_BY] 
Unsupported subquery expression: A GROUP BY clause in a scalar correlated 
subquery cannot contain non-correlated columns
   * When LCA is on, or when LCA is off but just replace the id with the 
expression, it throws exception during execution:
     [SCALAR_SUBQUERY_TOO_MANY_ROWS] More than one row returned by a subquery 
used as an expression.



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