ODPS-0123091

更新时间:2024-08-02 09:01:41

本文为您介绍错误码ODPS-0123091:Illegal type cast的报错场景,并提供对应的解决方案。

错误:in function cast, value 'xx' cannot be casted from yy to zz

错误信息示例

ODPS-0123091:Illegal type cast - in function cast, value 'xx' cannot be casted from YY to ZZ

问题描述

执行数据类型转换的时候出错,大多数情况下是由输入的数据不合法导致的。关于MC的数据类型转换,可以参考如下文档:数据类型转换

解决方案

检查输入数据,必要时先对输入数据进行清洗处理。假如想忽略错误,可以将当前处理模式修改为非严格模式。

Query示例

--准备数据
CREATE TABLE mc_test
(
  a string
);
INSERT overwrite TABLE mc_test
VALUES ('100'), ('-');

--设置当前处理模式为严格模式,集团内部的flag是odps.sql.udf.strict.mode=true,中国公共云对应的flag是odps.function.strictmode
SET odps.sql.udf.strict.mode=true;
--错误,因为输入数据'-'不能cast成bigint而且当前工作在strict模式。
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
  • 本页导读 (1)
  • 错误:in function cast, value 'xx' cannot be casted from yy to zz
  • 错误信息示例
  • 问题描述
  • 解决方案
  • Query示例
AI助理

点击开启售前

在线咨询服务

你好,我是AI助理

可以解答问题、推荐解决方案等