Wrong results for GROUP BY on column with index combined with column from UDF script emitting multiple rows

Details

Detail name Value
Changelog Number 31090
Type Bug
Status Resolved
Affected Versions Exasol 8.0.0, Exasol 8.29.0, Exasol 2025.1.0, Exasol 2025.2.0, Exasol 2026.1.0
Fix Versions Exasol 2026.1.1, Exasol 2025.1.12
Resolution Date 2026-07-02

Description

A query returns wrong results if it uses GROUP BY on a column for which an index exists and a column returned by a SCALAR EMITS UDF script call emitting more than one row. This also affects the function JSON_EXTRACT.

Example

CREATE OR REPLACE TABLE t(col_with_index CHAR(1) ASCII);
INSERT INTO t VALUES ('a');
ENFORCE GLOBAL INDEX ON t(col_with_index);

--/
CREATE OR REPLACE LUA SCALAR SCRIPT emit_two_rows() EMITS(emitted_col DOUBLE) AS 
function run(ctx)
    ctx.emit(11)
    ctx.emit(22)
end
/

-- Bug: This query returns one instead of the expected two rows.
SELECT *
FROM (SELECT col_with_index, emit_two_rows() FROM t)
GROUP BY 1, 2;

Workarounds

  1. Drop the index before running the affected query:
  2. If the index is needed, store the intermediate result in a table before applying the GROUP BY:
  3. Wrap the unique column with IFNULL or CAST to prevent GROUP BY Key Reduction:
DROP GLOBAL INDEX ON t(col_with_index);

SELECT *
FROM (SELECT col_with_index, emit_two_rows() FROM t)
GROUP BY 1, 2;
CREATE OR REPLACE TABLE temp_workaround AS
    SELECT col_with_index, emit_two_rows() FROM t;
SELECT * FROM temp_workaround GROUP BY 1, 2;
DROP TABLE temp_workaround;
SELECT *
FROM (SELECT ifnull(col_with_index, null) as col_with_index, emit_two_rows() FROM t)
GROUP BY 1, 2;

SELECT *
FROM (SELECT CAST(col_with_index AS VARCHAR(2000000)) AS col_no_index, emit_two_rows() FROM t)
GROUP BY 1, 2;

Fix

Affected queries return the correct results.