我正在尝试使用CREATE AS和HiveCLI上的动态分区从另一个表创建一个新表。我从Hive官方wiki那里学到了以下例子:
CREATE TABLE T (key int, value string)
PARTITIONED BY (ds string, hr int) AS
SELECT key, value, ds, hr+1 hr1
FROM srcpart
WHERE ds is not null
And hr>10;但是我收到了这个错误:
失败: SemanticException错误10065: 创建表,因为SELECT命令不能为目标表指定列列表
来源:https://cwiki.apache.org/confluence/display/Hive/DynamicPartitions#DynamicPartitions-Syntax
发布于 2014-02-01 19:31:51
既然您已经知道目标表的完整架构,请尝试先创建它并使用LOAD DATA命令填充它:
SET hive.exec.dynamic.partition.mode=nonstrict;
CREATE TABLE T (key int, value string)
PARTITIONED BY (ds string, hr int);
INSERT OVERWRITE TABLE T PARTITION(ds, hr)
SELECT key, value, ds, hr+1 AS hr
FROM srcpart
WHERE ds is not null
And hr>10;注意:由于要执行完整的动态分区插入,所以需要set命令。
发布于 2015-11-24 09:49:01
SET hive.exec.dynamic.partition.mode=nonstrict;
CREATE TABLE T (key int, value string)
PARTITIONED BY (ds string, hr int);
INSERT OVERWRITE TABLE T PARTITION(ds, hr)
SELECT key, value, ds, hr+1 AS hr
FROM srcpart
WHERE ds is not null
And hr>10;在上面的代码中,不用Create语句使用:CREATE TABLE T like srcpart;
在分区类似的情况下。
https://stackoverflow.com/questions/21477855
复制相似问题