LENGTH function supported data types
The data types supported by the LENGTH function in CDP differ from CDH. The behavioral difference presents a problem when using the absolute value function ABS.
Before Upgrade to CDP
In CDH, the LENGTH function supports double in addition to string, char, varchar or binary. For example, the following query is valid:
select length(abs('123.000'));
After Upgrade to CDP
In CDP, HIVE-15979 is implemented to follow the SQL standard. LENGTH
supports columns of data type string, char, varchar or binary. Double is not supported by
length() in CDP. For example, an error occurs when passing a double to the abs
function.
select length(abs('123.000'));
Error: Error while compiling statement: FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments ''123.000'': LENGTH() only takes STRING/CHAR/VARCHAR/BINARY types as first argument ...42000
For more information, see the Generic UDF Length definition.
Action Required
In CDP, use the workaround shown in the following example:
select length(cast(abs('123.000') as char(10)));