动态分区不能是静态分区"3"的父级 [英] Dynamic partition cannot be the parent of a static partition '3'
问题描述
在将数据插入表配置单元中时,使用以下查询引发错误动态分区不能是静态分区'3'的父级"
While inserting data into table hive threw the error "Dynamic partition cannot be the parent of a static partition '3'" using below query
INSERT INTO TABLE student_partition PARTITION(course,year = 3) SELECT name,id,course FROM student1 WHERE year = 3;
INSERT INTO TABLE student_partition PARTITION(course , year = 3) SELECT name, id, course FROM student1 WHERE year = 3;
请说明原因.
推荐答案
此异常的原因是因为分区是分层文件夹. course
文件夹是较高级别,而year
是每年的嵌套文件夹.
The reason of this Exception is because partitions are hierarchical folders. course
folder is upper level and year
is nested folders for each year.
动态创建分区时,应首先创建上层文件夹(课程),然后再嵌套year=3
文件夹.
When you creating partitions dynamically, upper folder should be created first (course) then nested year=3
folder.
您正在(静态地)预先提供year=3
分区,甚至在不知道course
之前.
You are providing year=3
partition in advance (statically), even before course
is known.
反之亦然:静态父分区和动态子分区:
Vice-versa is possible: Static parent partition and dynamic child partition:
INSERT INTO TABLE student_partition PARTITION(course='chemistry' , year) --static course partition
SELECT name, id, 3 as year --or just simply year
FROM student1 WHERE year = 3;
在HDFS分区中,文件夹如下:
In the HDFS partitions folders are like this:
/student_partition/course=chemistry/year=3
/student_partition/course=chemistry/year=4
/student_partition/course=philosophy/year=3
静态分区应该存在.但是,如果尚未定义父对象,则它不存在.
Static partition should exist. But it cannot exist if parent is not defined yet.
或者,您也可以使year
分区以及过程动态化:
Alternatively you can make year
partition dynamic as well as course:
INSERT INTO TABLE student_partition PARTITION(course , year)
SELECT name, id, course, 3 as year --or just simply year
FROM student1 WHERE year = 3;
这篇关于动态分区不能是静态分区"3"的父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!