from_unixtime 认为数据是字符串,其中数据在 hadoop 配置单元中是 int/bigint
from_unixtime thinks data is string where data is int/bigint in hadoop hive
我的代码如下..
SELECT
to_date(from_unixtime(time_first_touch)) AS sDate
FROM (
SELECT
MIN(GET_JSON_OBJECT(swanviraw.textcol,'$.ev_time')) as time_first_touch,
COUNT(*) as number_of_events
FROM swanviraw
) v
它抛出错误 - 编译语句时出错:失败:SemanticException [错误 10014]:行 2:10 错误参数 'time_first_touch':class [=35= 没有匹配方法] 与(字符串)。可能的选择:FUNC(bigint) FUNC(bigint, string) FUNC(int) FUNC(int, string) [ERROR_STATUS]
现在,重点是以下查询工作正常。ev_time 具有 int/bigint 值,因为 MIN 在以下查询中完美运行..
SELECT
MIN(GET_JSON_OBJECT(swanviraw.textcol,'$.ev_time')) as time_first_touch,
COUNT(*) as number_of_events
FROM swanviraw
真诚感谢任何帮助..
谢谢
作为GET_JSON_OBJECT
returns json string,并且由于错误指示from_unixtime
期望int
或bigint
,您需要将time_first_touch
转换为bigint
:
SELECT
to_date(from_unixtime(time_first_touch)) AS sDate
FROM (
SELECT
MIN(cast(GET_JSON_OBJECT(swanviraw.textcol,'$.ev_time') as bigint)) as time_first_touch,
COUNT(*) as number_of_events
FROM swanviraw
) as v
或
SELECT
to_date(from_unixtime(time_first_touch)) AS sDate
FROM (
SELECT
MIN(unix_timestamp(GET_JSON_OBJECT(swanviraw.textcol,'$.ev_time'))) as time_first_touch,
COUNT(*) as number_of_events
FROM swanviraw
) as v
我的代码如下..
SELECT
to_date(from_unixtime(time_first_touch)) AS sDate
FROM (
SELECT
MIN(GET_JSON_OBJECT(swanviraw.textcol,'$.ev_time')) as time_first_touch,
COUNT(*) as number_of_events
FROM swanviraw
) v
它抛出错误 - 编译语句时出错:失败:SemanticException [错误 10014]:行 2:10 错误参数 'time_first_touch':class [=35= 没有匹配方法] 与(字符串)。可能的选择:FUNC(bigint) FUNC(bigint, string) FUNC(int) FUNC(int, string) [ERROR_STATUS]
现在,重点是以下查询工作正常。ev_time 具有 int/bigint 值,因为 MIN 在以下查询中完美运行..
SELECT
MIN(GET_JSON_OBJECT(swanviraw.textcol,'$.ev_time')) as time_first_touch,
COUNT(*) as number_of_events
FROM swanviraw
真诚感谢任何帮助..
谢谢
作为GET_JSON_OBJECT
returns json string,并且由于错误指示from_unixtime
期望int
或bigint
,您需要将time_first_touch
转换为bigint
:
SELECT
to_date(from_unixtime(time_first_touch)) AS sDate
FROM (
SELECT
MIN(cast(GET_JSON_OBJECT(swanviraw.textcol,'$.ev_time') as bigint)) as time_first_touch,
COUNT(*) as number_of_events
FROM swanviraw
) as v
或
SELECT
to_date(from_unixtime(time_first_touch)) AS sDate
FROM (
SELECT
MIN(unix_timestamp(GET_JSON_OBJECT(swanviraw.textcol,'$.ev_time'))) as time_first_touch,
COUNT(*) as number_of_events
FROM swanviraw
) as v