Internal server error for UNION of VIEW containing ordered UNION

Details

Detail name Value
Changelog Number 28425
Type Bug
Status Resolved
Affected Versions Exasol 7.1.0, Exasol 8.0.0, Exasol 2025.1.0, Exasol 2025.2.0
Fix Versions Exasol 2025.1.11
Resolution Date 2026-06-03

Description

A query fails with an internal server error, if all of the following conditions are met:

  • The query must use ORDER BY or LIMIT and must contain a UNION (not UNION ALL) with a VIEW (not a CTE) on the right-hand side.
  • The VIEW must use UNION or UNION ALL and must be ORDERED BY a column number bigger than the number of columns in the SELECT.

Example

CREATE VIEW example_view(col1, col2) AS
	SELECT 1, 2
	UNION ALL
	SELECT 1, 2
	ORDER BY 2;

SELECT 1
UNION
SELECT col1 FROM example_view
LIMIT 1;

Extended example

SELECT 1
UNION
SELECT col1 FROM example_view -- right-hand side of the first UNION
UNION
SELECT 1
LIMIT 1;

Workaround

Add an additional SELECT around the affected query and move the ORDER BY or LIMIT to it:

SELECT * FROM
(
	SELECT 1
	UNION
	SELECT col1 FROM example_view
)
LIMIT 1;

Fix

Queries of that type don’t fail.