【问题标题】:Partitions are still showing in hive even though they are dropped for an external table即使为外部表删除了分区,它们仍会显示在配置单元中
【发布时间】:2017-09-17 10:57:10
【问题描述】:

我在 hive 中有一个按年、月、日分区的外部表。所以我删除了一个分区,但我仍然在显示分区中看到它。

>use test_raw_tables;
>show partitions test1_raw;
[year=2016/month=01/day=01]
[year=2017/month=03/day=24]

> alter table test1_raw drop partition (year=2016, month=01, day=01);
> refresh test1_raw;
> show partitions test1_raw;
[year=2016/month=01/day=01]
[year=2017/month=03/day=24]     ---Still see the dropped partition here----

> msck repair table test1_raw;
> show partitions test1_raw;
[year=2016/month=01/day=01]
[year=2017/month=03/day=24]    ---Still see the dropped partition here----

以 hive 作为引擎从 impala 运行。

描述 test1_raw col_name,data_type,comment ('amount_hold', 'int', '') ('id', 'int', '') ('transaction_id', 'string', '') ('recipient_id', 'string', '') ('year', 'string', '') ('month', 'string', '') ('day', 'string', '') ('', None, None) ('#分区信息', None, None) ('# col_name', 'data_type', 'comment') ('', None, None) ('year', 'string', '') ('month', 'string' , '') ('day', 'string', '') 位置 'hdfs://localhost/sys/datalake/testing/test1_raw'

这里有什么问题? 删除该分区后,该分区的 hdfs 中的数据将被删除。无法解决问题。

【问题讨论】:

  • (1) 请添加表定义 (2) 您从哪里运行代码?黑斑羚壳?蜂巢?直线?
  • @DuduMarkovitz 表是一个外部表。从 hive shell 运行查询。
  • refresh 是 Impala 命令,而不是 hive。我需要知道你在哪里执行什么以及表定义,包括相关的分区定义。还请告诉我他们的路径在文件系统中的样子。
  • 请把这个以及相关分区的路径添加到帖子中

标签: hadoop hive hiveql impala


【解决方案1】:

在您的表定义列中,年、月和日采用字符串格式。 请尝试使用“2016”、“01”和“01”。 我使用了下面的代码,它可以工作。

alter table test1_raw drop partition (year='2016', month='01', day='01');

【讨论】:

  • 如果对您有用,请确保答案正确
  • 我猜这是 Hive 的一个错误,即 msck repair 不会自行删除已删除的分区(表是外部的,意味着 Hive 确实没有该所有权,但它仍然不起作用) .但是通过 alter table 命令删除分区是可行的。
【解决方案2】:

这不再重要,但您更改了表的定义。你没有改变数据。 Hive 的独特之处在于它可以让您在读取时定义模式,更改定义只是更改定义,它不会更改数据,仅更改表定义。您可以将多个表放在相同的数据之上而不会出现问题,这并不意味着一个表定义的更改会影响另一个。 (好吧,我说的是 On READ ……)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-13
    • 1970-01-01
    • 1970-01-01
    • 2019-03-16
    • 2017-09-15
    • 2015-04-06
    • 2018-04-30
    相关资源
    最近更新 更多