Wrong result for emitting UDF with GROUP BY columns sharing an expression
Details
| Detail name | Value |
|---|---|
| Changelog Number | 8254 |
| Type | Bug |
| Status | Resolved |
| Affected Versions | Exasol 6.1.0, Exasol 6.2.0 |
| Fix Versions | Exasol 6.2.0, Exasol 7.0.0, Exasol 6.1.5 |
| Resolution Date | 2019-07-18 |
Bug
A SELECT query sometimes returns a wrong result if it matches all of the following conditions:
- The FROM clause contains a subquery selecting values from an emitting UDF.
- There is no WHERE clause.
- The GROUP BY clause refers to two or more columns sharing a common expression.
Example
Here the common expression is MOD(VAL, 10).
SELECT DIV(MOD(VAL, 10), 4), DIV(MOD(VAL, 10), 5), MAX(VAL) FROM
(
SELECT EMITTING_UDF(COL)
FROM TAB
)
GROUP BY 1, 2;
Workarounds
- Either add a WHERE clause which is more complex than WHERE TRUE but does not change the result, e.g. WHERE VAL IS NULL OR VAL IS NOT NULL,
- or use the database parameter -noshortcuts=1 (not recommended because it might affect other queries).