The combination of ORDER BY and EMITS in UDF calls leads to an Error
Details
| Detail name | Value |
|---|---|
| Changelog Number | 6574 |
| Type | Bug |
| Status | Resolved |
| Affected Versions | EXASOL 6.0.0, Exasol 6.1.beta1, Exasol 6.0.11 |
| Fix Versions | Exasol 6.1.0, Exasol 6.0.12 |
| Resolution Date | 2018-08-27 |
Problem
The combination of ORDER BY and EMITS in a UDF call leads to a syntax error. Using only the ORDER BY or the EMITS works.
Example:
CREATE TABLE T(val int);
INSERT INTO T VALUES (1), (2), (3);
CREATE OR REPLACE JAVA SET SCRIPT testscript(...)
EMITS (...)
AS
class TESTSCRIPT {
static void run(ExaMetadata exa, ExaIterator ctx) throws Exception {
do {
Object[] row = new Object[1];
row[0] = ctx.getLong(0) + 1;
ctx.emit(row);
} while (ctx.next());
}
}
/
SELECT testscript(val ORDER BY val DESC) EMITS(val int) FROM T;
Workaround
Use of a temporary table with a column definition that matches the column definition in emits.
Example:
CREATE TABLE tmp (val int); INSERT INTO tmp SELECT testscript(val ORDER BY val DESC) FROM T;