Incorrect "tables are not allowed" error from correlated subquery used in outer join table

Details

Detail name Value
Changelog Number 31208
Type Bug
Status Resolved
Affected Versions Exasol 8.0.0, Exasol 2025.1.0, Exasol 2025.2.0, Exasol 2026.1.0
Fix Versions Exasol 2026.1.1, Exasol 2025.1.14
Resolution Date 2026-08-06

Description

A query will give the error “tables are not allowed in this context” for a query with the following conditions, when it should succeed.

  • There is an outer join with a subselect on the “inner” (NULL-generating) side.
  • The subselect projects an expression containing a correlated scalar subquery.
  • The correlated scalar subquery is within a CASE expression or a similar conditional expression (such as COALESCE, DECODE, IFNULL or NULLIF).

For example, see Q1 below.

-- Setup
CREATE TABLE a (a1 INT);
INSERT INTO a VALUES (1);
CREATE TABLE b (b1 INT, b2 INT);
INSERT INTO b VALUES (2, 1);
CREATE TABLE c (c1 INT, c2 INT);
INSERT INTO c VALUES (100, 1);

-- Expected: 1 row, values (1, NULL, NULL)
-- Observed: Error "tables are not allowed in this context"
SELECT a1, b1, x
FROM a
     LEFT JOIN (SELECT b1, CASE WHEN b1 IS NULL THEN NULL ELSE (SELECT MAX(c1) FROM c WHERE c2 = b2) END AS x FROM b)
     ON a1 = b1;

-- Expected: 1 row, values (1, NULL, NULL)
-- Observed: Error "tables are not allowed in this context"
SELECT a1, b1, x
FROM a
     LEFT JOIN (SELECT b1, COALESCE((SELECT MAX(c1) FROM c WHERE c2 = b2), 0) AS x FROM b)
     ON a1 = b1;

Workaround

There is no workaround.

Fix

The query succeeds.