This topic describes the possible causes of the error code ODPS-0123091: Illegal type cast and provides solutions.
Error message 1: in function cast, value 'xx' cannot be casted from yy to zz
Sample
ODPS-0123091:Illegal type cast - in function cast, value 'xx' cannot be casted from YY to ZZ
Description
An error occurs during the data type conversion. In most cases, this issue is caused by invalid input data. For more information about data type conversions in MaxCompute, see Type conversions.
Solution
Check the input data and cleanse the input data if necessary. If you want to ignore the error, change the current processing mode to the non-strict mode.
Examples of query statements
-- Prepare data.
CREATE TABLE mc_test
(
a string
);
INSERT overwrite TABLE mc_test
VALUES ('100'), ('-');
-- Set the current processing mode to the strict mode. The internal flag of Alibaba Group is odps.sql.udf.strict.mode=true, and the flag of the public cloud in the Chinese mainland is odps.function.strictmode.
SET odps.sql.udf.strict.mode=true;
-- An error is returned. This is because the input data '-' cannot be cast into the BIGINT type and the current processing mode is the strict mode.
SELECT cast(a AS bigint)
FROM mc_test;
FAILED: ODPS-0123091:Illegal type cast - in function cast, value '-' cannot be casted from String to Bigint