使用ALIAS和CAST with coalesce

时间:2018-02-12 14:46:11

标签: casting alias hiveql coalesce

我是Hive的新手,所以如果我使用任何错误的条款,请原谅。我基本上想要转换/转换

的输出
SELECT to_date(EXPOSURE.ETL_START_DATE) as EXPOSURE_Date_Key

成一个字符串,也

coalesce(EXPOSURE_OPEN.open,0) as open,coalesce(EXPOSURE_CLOSED.closed,0) as closed

也成了一个字符串。

请帮忙。我已经在这方面努力了2天,但无法解决它。提前谢谢!

1 个答案:

答案 0 :(得分:0)

你可以像这样使用演员陈述

SELECT cast(to_date(EXPOSURE.ETL_START_DATE) as string) as EXPOSURE_Date_Key

SELECT cast(coalesce(EXPOSURE_OPEN.open,0) as open,coalesce(EXPOSURE_CLOSED.closed,0) as string) as closed