Lua UDF with EMIT returns unknown Lua error in complex scenarios with large data sets
Details
| Detail name | Value |
|---|---|
| Changelog Number | 12958 |
| Type | Bug |
| Status | Resolved |
| Affected Versions | Exasol 7.0.0, Exasol 7.1.0, Exasol 8.0.0, Exasol 8.1.0 |
| Fix Versions | Exasol 8.2.0 |
| Resolution Date | 2022-08-12 |
Description
This is the same bug as EXASOL-2634 but for larger data sets (i.e., more than 2047 input rows) which was not covered by that fix.
An 'Unknown Lua error' is thrown if the following conditions are met:
- The query contains a Lua SCALAR EMIT UDF.
- The UDF processes more than 2047 input rows.
- The query sets an outer limit that is smaller than the number of input rows to the SCALAR EMIT UDF. Note that also some clients (e.g., DbVisualizer) set such a limit automatically.
Preparation:
CREATE SCHEMA test; --/ CREATE OR REPLACE LUA SCALAR SCRIPT return_string_lua(input_str int) EMITS(output_str VARCHAR(2000000)) AS function run(ctx) ctx.emit(1) end / CREATE OR REPLACE TABLE ten AS VALUES 0,1,2,3,4,5,6,7,8,9 as p(x); CREATE OR REPLACE TABLE t1 as SELECT 1 x FROM ten,ten,ten,ten;
Example
SELECT return_string_lua(x) FROM t1 LIMIT 10;
Workaround
Use ORDER BY LIMIT syntax:
SELECT return_string_lua(x) FROM t1 ORDER BY 1 LIMIT 10;
Fix
The query will run as expected.