You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Mihailo Aleksic (Jira)" <ji...@apache.org> on 2025/05/13 10:52:00 UTC

[jira] [Updated] (SPARK-52102) Normalize correlated aggregate function names in HAVING condition

     [ https://issues.apache.org/jira/browse/SPARK-52102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mihailo Aleksic updated SPARK-52102:
------------------------------------
    Description: 
In the following query we would have `min(outer(t2.t2a))` as a name for `min(t2a)` expression.

{code:java}
SELECT t1a 
FROM   t1
WHERE  t1a IN (SELECT t2a 
               FROM   t2
               WHERE  EXISTS (SELECT min(t2a) 
                              FROM   t3))
{code}

This is a problem in compatibility between single-pass resolver and fixed-point analyzer because names in single-pass are generated after we finish resolution of aggregate expression `min(t2a)` (bottom-up manner) and at that point we have `OuterReference` wrapped around aggregate expression (name looks like `outer(min(t2a))`).
I propose that we fix it by normalizing `Alias` names for correlated aggregate functions in HAVING condition.

  was:
In the following query we would have `min(outer(t2.t2a))` as a name for `min(t2a)` expression.
```
SELECT t1a 
FROM   t1
WHERE  t1a IN (SELECT t2a 
               FROM   t2
               WHERE  EXISTS (SELECT min(t2a) 
                              FROM   t3))
```
This is a problem in compatibility between single-pass resolver and fixed-point analyzer because names in single-pass are generated after we finish resolution of aggregate expression `min(t2a)` (bottom-up manner) and at that point we have `OuterReference` wrapped around aggregate expression (name looks like `outer(min(t2a))`).
I propose that we fix it by normalizing `Alias` names for correlated aggregate functions in HAVING condition.


> Normalize correlated aggregate function names in HAVING condition
> -----------------------------------------------------------------
>
>                 Key: SPARK-52102
>                 URL: https://issues.apache.org/jira/browse/SPARK-52102
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 4.1.0
>            Reporter: Mihailo Aleksic
>            Priority: Major
>
> In the following query we would have `min(outer(t2.t2a))` as a name for `min(t2a)` expression.
> {code:java}
> SELECT t1a 
> FROM   t1
> WHERE  t1a IN (SELECT t2a 
>                FROM   t2
>                WHERE  EXISTS (SELECT min(t2a) 
>                               FROM   t3))
> {code}
> This is a problem in compatibility between single-pass resolver and fixed-point analyzer because names in single-pass are generated after we finish resolution of aggregate expression `min(t2a)` (bottom-up manner) and at that point we have `OuterReference` wrapped around aggregate expression (name looks like `outer(min(t2a))`).
> I propose that we fix it by normalizing `Alias` names for correlated aggregate functions in HAVING condition.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org