Fix TYPEOF error for TRUNC, ROUND and SECOND where the precision argument is string or float

Details

Detail name Value
Changelog Number 19360
Type Bug
Status Resolved
Affected Versions Exasol 7.1.0, Exasol 8.0.0
Fix Versions Exasol 7.1.26, Exasol 8.26.0
Resolution Date 2024-03-15

Description

The TYPEOF() function gives an error for the functions numeric TRUNC(), numeric ROUND() and SECOND() where the precision argument is string or approximate numeric.

Examples

-- Expected: 1 row, values ('DECIMAL(2,0)')
-- Observed: Error "Feature not supported: Illegal type change in compiler from DECIMAL(11,9) to DECIMAL(2,0)"
select typeof(trunc(11.123456789, '0'));

-- Expected: 1 row, values ('DECIMAL(2,0)')
-- Observed: Error "Feature not supported: Illegal type change in compiler from DECIMAL(11,9) to DECIMAL(2,0)"
select typeof(trunc(11.123456789, cast(0 as double)));

-- Expected: 1 row, values ('DECIMAL(3,0)')
-- Observed: Error "Feature not supported: Illegal type change in compiler from DECIMAL(11,9) to DECIMAL(3,0)"
select typeof(round(11.123456789, '0'));

-- Expected: 1 row, values ('DECIMAL(3,0)')
-- Observed: Error "Feature not supported: Illegal type change in compiler from DECIMAL(11,9) to DECIMAL(3,0)"
select typeof(round(11.123456789, cast(0 as double)));

Workaround

Use an exact numeric type, or cast to an exact numeric type, for the precision argument.

-- Expected/Observed: 1 row, values ('DECIMAL(2,0)')
select typeof(trunc(11.123456789, 0));

-- Expected/Observed: 1 row, values ('DECIMAL(2,0)')
select typeof(trunc(11.123456789, cast('0' as integer)));

Fix

The problem is fixed.