【问题标题】:Unable to remove Null Values and receive output无法删除空值并接收输出
【发布时间】:2019-11-24 04:13:25
【问题描述】:

我在 Hive 中工作并尝试查询将从另一个具有 NULL 值的表中提取的表。查询运行良好,但最终,新表完全空白。

hive> select * from makemodelpricenn limit 10;

给出如下所示的输出:

但是,删除 NULL 的查询不会给出任何结果:

select * from makemodelpricenn where fuel_type != "NULL";

输出:

如何查询不包含 NULL 值且数据干净的表?

【问题讨论】:

  • 你试过IS NOT NULL而不是!= NULL吗?
  • 是的。事实上,我只是在尝试 IS NOT NULL 之后才尝试过 != NULL

标签: sql hadoop hive


【解决方案1】:

首先,试试

select * from makemodelpricenn where fuel_type != 'NULL';

如果它不起作用,请尝试以下 DDL

ALTER TABLE makemodelpricenn SET TBLPROPERTIES ('serialization.null.format' = 'NULL');

然后使用

select * from makemodelpricenn where fuel_type is not  NULL;

【讨论】:

  • 您好,我使用了以下代码:hive> kaustubhmulay2907@hadoopcluster-1-m:~$ create table makemodelpricenn select * from makemodelprice where maker is not NULL and model is not NULL and fuel_type is not NULL;但是,当我查询前 20 行时,没有结果。有什么想法吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-01
  • 1970-01-01
  • 2022-01-19
  • 2019-02-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多