阿里云首页

Dataphin使用from_unixtime报错“FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments ''yyyyMMdd'': No matching method for class org.apache.hadoop.hive.ql.udf.UDFFromUnixTime with (timestamp, string)”

产品名称

Dataphin

产品模块

开发、数据处理

概述

本文解决使用from_unixtime报错“FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments ''yyyyMMdd'': No matching method for class org.apache.hadoop.hive.ql.udf.UDFFromUnixTime with (timestamp, string)”

问题描述

字段tt是timestamp类型,执行这个sql:SELECT from_unixtime(tt,'yyyyMMdd') FROM a WHERE DS=20210808 报错如下:

Caused by: org.apache.hive.service.cli.HiveSQLException: Error while compiling statement: FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments ''yyyyMMdd'': No matching method for class org.apache.hadoop.hive.ql.udf.UDFFromUnixTime with (timestamp, string). Possible choices: _FUNC_(bigint)  _FUNC_(bigint, string)  _FUNC_(int)  _FUNC_(int, string)  
 at org.apache.hive.service.cli.operation.Operation.toSQLException(Operation.java:400)
 at org.apache.hive.service.cli.operation.SQLOperation.prepare(SQLOperation.java:187)
 at org.apache.hive.service.cli.operation.SQLOperation.runInternal(SQLOperation.java:271)
 at org.apache.hive.service.cli.operation.Operation.run(Operation.java:337)
 at org.apache.hive.service.cli.session.HiveSessionImpl.executeStatementInternal(HiveSessionImpl.java:439)

问题原因

解决方案

改造sql语句如下:

  SELECT from_unixtime(int(tt),'yyyyMMdd') FROM a WHERE DS=20210808

更多信息

相关文档

首页 Dataphin使用from_unixtime报错“FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments ''yyyyMMdd'': No matching method for class org.apache.hadoop.hive.ql.udf.UDFFromUnixTime with (timestamp, string)”