将数据从一个表复制到另一分区表 [英] copy data from one table to another partitioning table
问题描述
%hive
INSERT INTO NEWPARTITIONING partition(year(L_SHIPDATE)) select * from LINEITEM;
我想将订单项中的数据复制到分区表 NEWPARTITIONING
中,但是出现以下错误:
I want to copy the data from line item to the partitioning table NEWPARTITIONING
but I got the following error:
1:54行无法识别语句中')''select''*'附近的输入.
line 1:54 cannot recognize input near ')' 'select' '*' in statement.
不明白为什么会发生此错误.谁能给我一些想法
Don't understand why this error occurs. Can anyone give me some ideas
推荐答案
Hive支持 DYNAMIC 或 STATIC 分区加载.
Hive supports DYNAMIC or STATIC partition loading.
分区规范仅允许使用列名或列列表(用于动态分区加载),如果需要功能,请在选择中进行计算,请参见以下示例:
Partition specification allows only column name or column list (for dynamic partition load), if you need function, then calculate it in the select, see example below:
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert into table NEWPARTITIONING partition (partition_column)
select i.col1,
...
i.colN,
year(L_SHIPDATE) as partition_column --Partition should be the last in column list
from LINEITEM i
或者您可以以 partition(partition_column ='value')
的形式指定静态分区,在这种情况下,您无需选择分区表达式:
Or you can specify static partition in the form partition(partition_column='value')
, in this case you do not need to select partition expression:
insert into table NEWPARTITIONING partition (partition_column='2020-01-01')
select i.col1,
...
i.colN
from LINEITEM i
where year(L_SHIPDATE) = '2020-01-01'
在STATIC和DYNAMIC两种情况下,Hive不支持分区规范中的功能.函数可以在查询中计算(动态负载),也可以在包装器外壳中计算,然后作为参数传递给脚本(用于静态分区).
In both cases - STATIC and DYNAMIC, Hive does not support functions in partition specification. Functions can be calculated in the query (dynamic load) or calculated in a wrapper shell and passed as a parameter to the script (for static partition).
这篇关于将数据从一个表复制到另一分区表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!