配置单元:在子查询中添加分区列数据

时间:2019-04-30 04:15:41

标签: hive hiveql

我有2个配置单元表,它们具有完全相同的架构,但日期列除外。其中一个具有date列,这是它的分区依据,而另一个则没有date列,也没有任何分区。

这两个表是:

staging (no date column and not partitioned)  
main (date column present and is partitioned by date)

我想从暂存到主复制数据。我正在尝试查询

INSERT OVERWRITE TABLE main
        PARTITION (dt='2019-04-30')
                SELECT col_a,
                col_b,
                col_c,
                col_d,
                col_e,
                '2019-04-30' FROM staging

登台表和主表都具有col_a,col_b,col_c,col_d和col_e。 dt是仅主表具有的字段。但这会引发此错误:

main requires that the data to be inserted have the same number of columns as the target table: target table has 6 column(s) but the inserted data has 7 column(s), including 1 partition column(s) having constant value(s).;'

有什么主意我可以解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

好吧,原来我要做的就是-

INSERT OVERWRITE TABLE main
        PARTITION (dt='2019-04-30')

                SELECT * FROM staging