Incorrect transformation in PushJoinsIntoUnions causes unexpected exceptions

Details

Detail name Value
Changelog Number 30712
Type Bug
Status Resolved
Affected Versions Exasol 2026.1.0
Fix Versions Exasol 2026.1.1
Resolution Date 2026-08-06

Description

Valid queries with UNION ALL and an INNER JOIN may throw an unexpected exception or crash with an internal server error under specific circumstances.
A query needs the following properties:

  • The query contains a UNION ALL.
  • The query contains an INNER JOIN.
  • The query is eligible for PushJoinsIntoUnions optimization.
  • There is a join between the pushed table and NOT the UNION ALL which contains a predicate with a column lookup to the pushed table.

Example

-- Preparation
create table A (A1 int);
insert into A values (1);
create table A_ (A1 bigint);
insert into A_ values (10000000001), (10000000002);
create table B (B1 int, B2 int);
insert into B values (1, 1);
create table C (C1 int);
insert into C values (1);

-- Expected: query runs without errors
-- Observed: "invalid identifier in join predicate"
select A1 from
(
select A1 from A
union all
select A1 from A_
) U
inner join (select B1, B2 from B order by false) B
on U.A1 = B.B1 and B.B2 = 1
inner join C
on B.B1 = C.C1;

-- Expected: query runs without errors
-- Observed crash: "Successfully reconnected after internal server error, transaction was rolled back."
with myview as
(select B1, B2 from B order by false)
select A1 from
(
select A1 from A
union all
select B1 from myview
) U
inner join (select B1, B2 from B order by false) B
on U.A1 = B.B1 and B.B2 = 1
left join C
on B.B1 = C.C1;

-- Expected: query runs without errors
-- Observed: "Feature not supported: Unexpected node during execution graph creation: QEPreMatQueryTermBasis"
with myview as
(select B1, B2 from B order by false)
select A1 from
(
select A1 from A
union all
select B1 from myview
) U
inner join myview B
on U.A1 = B.B1 and B.B2 = 1
left join C
on B.B1 = C.C1;

Workaround

Disable PushJoinsIntoUnions optimization by adding ORDER BY FALSE to the UNION ALL. For example:

select A1 from
(
select A1 from A
union all
select A1 from A_
order by false
) U
inner join (select B1, B2 from B order by false) B
on U.A1 = B.B1 and B.B2 = 1
inner join C
on B.B1 = C.C1;

Fix

Queries run as expected.