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..
The reason is because partitions folders are hierarchical.
course
folder is upper level andyear
is nested folders foe each year. When you creating partitions dynamically, upper folder should be created first (course) then nestedyear=3
folder. You are providingyear=3
partition in advance (statically), beforecourse
is known yet. Vice-versa is possible: Static parent partition and dynamic child partition.In the HDFS partitions folders are like this:
Static partition should exist. But it cannot exist if parent does not exist yet.
Alternatively you can make
year
partition dynamic as well: