Query with UNION, CTE and LIMIT fails due to "insertion limit"

Details

Detail name Value
Changelog Number 17644
Type Bug
Status Resolved
Affected Versions Exasol 7.1.0, Exasol 8.0.0, Exasol 8.29.0, Exasol 2025.1.0, Exasol 2025.2.0
Fix Versions Exasol 2026.1.0, Exasol 2025.2.1
Resolution Date 2026-03-20

Description

A query with the following conditions can crash:

  • There is a UNION or UNION ALL.
  • The first table operand has parentheses and a Common Table Expression (CTE, WITH clause).
  • The last table operand has a LIMIT clause.

Example

-- Observed: The query fails with "Internal server error"
(
  WITH cte AS ( SELECT 1 AS c )
  SELECT 1
)
UNION
SELECT 1 LIMIT 1;

Workaround

Wrap a select around the first table operand:

-- Observed: The query succeeds.
SELECT *
FROM ( WITH cte AS ( SELECT 1 AS c )
       SELECT 1 )
UNION
SELECT 1 LIMIT 1;

Fix

The query succeeds.