【问题标题】:Dynamic partition cannot be the parent of a static partition '3'动态分区不能是静态分区“3”的父级
【发布时间】:2018-10-17 13:50:30
【问题描述】:

在将数据插入表配置单元时,使用以下查询引发错误“动态分区不能是静态分区 '3' 的父级”

插入表 student_partition 分区(课程,年 = 3) SELECT name, id, course FROM student1 WHERE year = 3;

请解释原因..

【问题讨论】:

    标签: hive hiveql partition hive-partitions


    【解决方案1】:

    这个异常的原因是因为分区是分层文件夹。 course 文件夹是上层文件夹,year 是每年的嵌套文件夹。

    动态创建分区时,应先创建上层文件夹(当然),然后嵌套year=3文件夹。

    您提前(静态)提供year=3 分区,甚至在course 已知之前。

    反之亦然:静态父分区和动态子分区:

    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 分区中的文件夹是这样的:

    /student_table/course=chemistry/year=3
    /student_table/course=chemistry/year=4
    /student_table/course=philosophy/year=3
    

    应该存在静态分区。但是如果还没有定义父级,它就不能存在。

    或者,您也可以使year 分区动态化:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-06
      • 1970-01-01
      • 1970-01-01
      • 2011-02-20
      • 2020-10-28
      • 1970-01-01
      相关资源
      最近更新 更多