假设一个表包含3列,我呈现如下查询:
SELECT col1, col2, col3, null as col4 from table;在这种情况下,空值没有得到正确的反映。我在UNION操作中遇到错误,声明为“运行时空异常”。请帮帮忙
发布于 2013-09-16 16:01:27
您使用的是Hadoop的哪个发行版/版本。我在IDH上试过了,它工作得很好。您还可以粘贴完整的错误消息吗
配置单元(默认)> describe table4;
好的
fld1字符串
fld2字符串
配置单元(默认)> select fld1,fld2,null as fld3 from table4;
A 1为空
B 1为空
C 1 NULL
根据提问者的评论,添加如下:
我试过这个造型,它现在描述为字符串。你可以根据你的需要进行选型
create table table6 as select fld1,fld2,cast(null as string) fld3 from table4;
配置单元(默认)> describe table6;确定
fld1 string fld2 string fld3 string
发布于 2014-09-26 21:35:22
我在一些示例表上尝试了一下,它对我来说是有效的,没有任何错误。查询示例:
select * from
(select col1, NULL as col2 from table1 LIMIT 10
UNION ALL
select col1, col2 from table2LIMIT 10) q1https://stackoverflow.com/questions/18821344
复制相似问题