Hive 配置单元“show partitions”命令不显示正确的分区

Hive 配置单元“show partitions”命令不显示正确的分区,hive,partition,Hive,Partition,我有一个带有动态分区的分区表, 划分字段为国籍和出生日期 当我使用emp_new where National='China'中的select*时,我得到以下三条记录: +---------------+--------------+--------------+------------------+----------------------+--------------------+--+ | emp_new.name | emp_new.sex | emp_new.age | e

我有一个带有动态分区的分区表, 划分字段为国籍和出生日期

当我使用emp_new where National='China'中的select*时,我得到以下三条记录:

+---------------+--------------+--------------+------------------+----------------------+--------------------+--+
| emp_new.name  | emp_new.sex  | emp_new.age  |   emp_new.job    | emp_new.nationality  | emp_new.birthdate  |
+---------------+--------------+--------------+------------------+----------------------+--------------------+--+
| Tony          | M            | 34           | IT specialist    | China                | 198202             |
| Katrina       | F            | 33           | IT specialist    | China                | 198408             |
| Cathy         | F            | 30           | IT specialist    | China                | 198704             |
但是,当我运行show partitions emp_new partitionnational='China'时,我得到以下结果:

+-------------------------------------+--+
|              partition              |
+-------------------------------------+--+
| nationality=China/birthdate=198408  |
| nationality=China/birthdate=198202  |
| nationality=China/birthdate=198704  |
| nationality=China/birthdate=197509  |
| nationality=China/birthdate=196704  |
| nationality=China/birthdate=197805  |
| nationality=China/birthdate=198201  |
| nationality=China/birthdate=197701  |
| nationality=China/birthdate=196708  |
+-------------------------------------+--+
事实上,我先用静态和动态分区National='China',birthdate将数据加载到此表中,然后截断该表并用动态分区National,birthdate重新加载

我不明白为什么旧分区仍然存在。

Truncate删除表的数据文件。 它不会从元存储中删除分区定义。 它不会删除文件系统目录

演示

我知道原因, 我需要在截断表后删除分区,
谢谢

使用ctrl+k将图片替换为文本格式并添加表谢谢,那么如何截断表,同时从元存储中删除分区定义并删除文件系统目录?首先。你看到我对你的帖子的评论了吗?@tonyibm,table DDL?创建表emp_newname string,sex string,age int,按国籍划分的工作字符串,生日行格式分隔的字段以“|”结尾,集合项以“,”@tonyibm-不,这不是工作代码。也可以将其添加到原始帖子中,而不是作为评论。
hive> create table mytable (i int) partitioned by (p int);
OK

hive> insert into mytable partition (p) values (1,10),(2,10),(3,20),(4,30),(5,30),(6,30);
OK
hive> select * from mytable;
OK
mytable.i   mytable.p
1   10
2   10
3   20
4   30
5   30
6   30


hive> show partitions mytable;
OK
partition
p=10
p=20
p=30

hive> !tree ../local_db/mytable;
../local_db/mytable
├── p=10
│   └── 000000_0
├── p=20
│   └── 000000_0
└── p=30
    └── 000000_0

3 directories, 3 files
hive> truncate table mytable;
OK
hive> select * from mytable;
OK
mytable.i   mytable.p

hive> show partitions mytable;
OK
partition
p=10
p=20
p=30

hive> !tree ../local_db/mytable;
../local_db/mytable
├── p=10
├── p=20
└── p=30

3 directories, 0 files