Referencing of columns of correlated subselects as local leads to a 'Feature not supported' error
Details
| Detail name | Value |
|---|---|
| Changelog Number | 4688 |
| Type | Bug |
| Status | Open |
| Affected Versions | EXASOL 6.0.0, EXASOL 6.0.1 |
Bug:
If a query contains a correlated subselect, i.e. a subselect that uses surrounding tables (t2 in the examples) and LOCAL inside the HAVING clause references this subselect, the query aborts with "Feature not supported".
How to identify:
If the query contains LOCAL in the HAVING clause that references a correlated subselect the following error appears:
Feature not supported: Correlated subselects in having clause
Example:
CREATE SCHEMA Test; CREATE OR REPLACE TABLE t1 (c1 int, c2 int); INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4); CREATE OR REPLACE TABLE t2 (c1 int, c2 int); INSERT INTO t2 VALUES (1,2),(2,3),(3,4),(4,5); SELECT SUM(( SELECT c2 FROM t1 WHERE t1.c1 = t2.c1 )) AS alias FROM t2 GROUP BY c1 HAVING LOCAL.alias > 2;
Workaround:
Avoid LOCAL in the HAVING clause for correlated subselects. For example:
SELECT * FROM
(
SELECT
SUM((
SELECT c2
FROM t1
WHERE t1.c1 = t2.c1
)) AS alias
FROM t2
GROUP BY c1
)
WHERE alias > 2;