Anton Lykov created SPARK-47070:
-----------------------------------
Summary: Subquery rewrite inside an aggregation makes an
aggregation invalid
Key: SPARK-47070
URL: https://issues.apache.org/jira/browse/SPARK-47070
Project: Spark
Issue Type: Bug
Components: Spark Core
Affects Versions: 3.5.0
Reporter: Anton Lykov
When an in/exists-subquery appears inside an aggregate expression within a
top-level GROUP BY, it gets rewritten and a new `exists` variable is
introduced. However, this variable is incorrectly handled in aggregation. For
example, consider the following query:
```
SELECT
CASE
WHEN t1.id IN (SELECT id FROM t2) THEN 10
ELSE -10
END AS v1
FROM t1
GROUP BY t1.id;
```
Executing it leads to the following error:
```
java.lang.IllegalArgumentException: Cannot find column index for attribute
'exists#844' in: Map()
```
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]