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/13 18:47:48 UTC

[GitHub] [spark] anchovYu commented on a diff in pull request #39040: [SPARK-27561][SQL] Support implicit lateral column alias resolution on Aggregate

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