Dynamic partition cannot be the parent of a static partition '3'

独自空忆成欢 提交于 2019-11-28 01:52:52

问题


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;

Please explain the reason..


回答1:


The reason of this Exception is because partitions are hierarchical folders. course folder is upper level and year is nested folders for each year.

When you creating partitions dynamically, upper folder should be created first (course) then nested year=3 folder.

You are providing year=3 partition in advance (statically), before course is known yet.

Vice-versa is possible: Static parent partition and dynamic child partition.

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 does not exist yet.

Alternatively you can make year partition dynamic as well:

INSERT INTO TABLE student_partition PARTITION(course , year) 
SELECT name, id, course, 3 as year --or just simply year 
  FROM student1 WHERE year = 3;


来源:https://stackoverflow.com/questions/50219573/dynamic-partition-cannot-be-the-parent-of-a-static-partition-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!