Infinite loop when predicates on constant columns are pushed into grouped UNION ALL or UNION branches

Details

Detail name Value
Changelog Number 30771
Type Bug
Status Open
Affected Versions Exasol 2026.1.0

Description

Valid queries containing predicates on grouped UNION or UNION ALL results may become stuck in an optimization loop during compilation. The query does not produce a result and must eventually be terminated by a timeout.

The issue occurs when:

  • A query joins against or filters the result of a UNION or a UNION ALL followed by a GROUP BY.
  • A JOIN condition or WHERE predicate references a column produced by that UNION.
  • The UNION operands produce constants for the column referenced by the outer predicate.

Example:

SELECT 1
FROM
(SELECT 1 c) t1
    JOIN
    (SELECT 1 c UNION SELECT 2 c) t2
        ON t1.c = t2.c;

Workaround

Add “ORDER BY FALSE” into the UNION / UNION ALL subquery.

SELECT 1
FROM
(SELECT 1 c) t1
    JOIN
    (SELECT 1 c UNION SELECT 2 c order by false) t2
        ON t1.c = t2.c;

Fix

Affected queries execute and produce results instead of infinite loop in the optimization.