You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "mihailoale-db (via GitHub)" <gi...@apache.org> on 2025/06/16 09:54:22 UTC
[PR] [SPARK-52488] [SQL] Strip alias before wrapping outer references under HAVING [spark]
mihailoale-db opened a new pull request, #51186:
URL: https://github.com/apache/spark/pull/51186
### What changes were proposed in this pull request?
For the following query:
```
SELECT col1 AS alias
FROM values(named_struct('a', 1))
GROUP BY col1
HAVING (
SELECT col1.a = 1
);
```
this is the resulting analyzed plan:
```
Filter cast(scalar-subquery#8847 [alias#8846] as boolean)
: +- Project [(outer(alias#8846).a = 1) AS (outer(col1).a AS a = 1)#8867]
: +- OneRowRelation
+- Aggregate [col1#8865], [col1#8865 AS alias#8846]
+- LocalRelation [col1#8865]
```
As it can be seen, we have outer(col1).a AS a in the Alias name for col1.a = 1 which is redundant and should be removed. It doesn't affect the output schema so changing the Alias name here is safe.
After the change, plan looks like:
```
Filter cast(scalar-subquery#x [alias#x] as boolean)
: +- Project [(outer(alias#x).a = 1) AS (outer(col1).a = 1)#x]
: +- OneRowRelation
+- Aggregate [col1#x], [col1#x AS alias#x]
+- LocalRelation [col1#x]
```
### Why are the changes needed?
To keep the compatibility between fixed-point and single-pass implementations.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Tests added in this PR.
### Was this patch authored or co-authored using generative AI tooling?
No.
--
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
Re: [PR] [SPARK-52488] [SQL] Strip alias before wrapping outer references under HAVING [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #51186: [SPARK-52488] [SQL] Strip alias before wrapping outer references under HAVING
URL: https://github.com/apache/spark/pull/51186
--
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
Re: [PR] [SPARK-52488] [SQL] Strip alias before wrapping outer references under HAVING [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #51186:
URL: https://github.com/apache/spark/pull/51186#issuecomment-2982262778
thanks, merging to master!
--
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