Empty results for IMPORT subquery with GROUP BY and LIMIT

Details

Detail name Value
Changelog Number 30756
Type Bug
Status Resolved
Affected Versions Exasol 2025.1.0, Exasol 2025.2.0, Exasol 2026.1.0
Fix Versions Exasol 2025.1.11, Exasol 2026.1.1
Resolution Date 2026-06-03

Description

It is possible that an import subquery does not return any rows and produces incorrect results when all of the following conditions are met:

  • The query contains an IMPORT subquery.
  • The query contains a GROUP BY.
  • The GROUP BY clause only contains columns from the IMPORT subquery.
  • The query contains an ORDER BY clause.
  • The query contains a LIMIT clause or a limit was given by the driver parameter RESULT_MAX_ROWS.
  • The GROUP BY, ORDER BY and LIMIT are on the same layer of the query.

Example

-- Bug: Result set is empty.
SELECT c1
FROM (IMPORT INTO (c1 INT) FROM EXA AT exa_connection STATEMENT 'VALUES (1), (2)')
GROUP BY 1
ORDER BY 1
LIMIT 200
;

Workarounds

Option 1: Add any non-IMPORT column to the GROUP BY:

SELECT c1
FROM (IMPORT INTO (c1 INT) FROM EXA AT exa_connection STATEMENT 'VALUES (1), (2)')
GROUP BY 1, NULL -- workaround
ORDER BY 1
LIMIT 200
;

Option 2: Move the LIMIT (and optionally the ORDER BY) to a wrapping SELECT:

SELECT * FROM (
    SELECT c1
    FROM (IMPORT INTO (c1 INT) FROM EXA AT exa_connection STATEMENT 'VALUES (1), (2)')
    GROUP BY 1
    ORDER BY 1
) -- workaround
LIMIT 200
;

Fix

The query returns the correct results.