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

后端 未结 1 1984
情歌与酒
情歌与酒 2020-12-18 09:20

While inserting data into table hive threw the error \"Dynamic partition cannot be the parent of a static partition \'3\'\" using below query

INSERT I

相关标签:
1条回答
  • 2020-12-18 10:22

    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), 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;
    

    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.

    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;
    
    0 讨论(0)
提交回复
热议问题