【问题标题】:Droped and recreated hive external table, but no data shown删除并重新创建配置单元外部表,但未显示数据
【发布时间】:2018-04-30 09:42:08
【问题描述】:

首先创建一个 hive 外部表:

create external table user_tables.test
(col1 string, col2 string)
partitioned by (date_partition date);

记录被插入:

INSERT INTO TABLE user_tables.test
PARTITION (date_partition='2017-11-16') VALUES ('abc', 'xyz'), ('abc1', 'xyz1');

现在,该表被删除并使用相同的脚本重新创建。 当我尝试-

SELECT * FROM user_tables.test WHERE date_partition='2017-11-16';`

我收到Done. 0 results.

【问题讨论】:

    标签: hive create-table select-query external-tables


    【解决方案1】:

    这是因为您创建的表是分区表。您运行的插入将为 date_partition='2017-11-16' 创建一个分区。当您删除并重新创建表时,Hive 会丢失有关分区的信息,它只知道表。

    运行下面的命令让 hive 根据数据重新创建分区。

    MSCK REPAIR TABLE user_tables.test;
    

    现在您将在运行 SELECT 时看到数据。

    如果您想知道表中的分区,请运行以下语句:

    SHOW PARTITIONS user_tables.test; 
    

    在MSCK前后运行这个看看效果。

    【讨论】:

      猜你喜欢
      • 2019-03-16
      • 2017-10-10
      • 2013-08-08
      • 2021-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多