我试图从另一个表中创建一个新表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;
但是我收到了这个错误:
FAILED: SemanticException [Error 10065]:
CREATE TABLE AS SELECT command cannot specify the list of columns for the
target table
由于您已经了解了目标表的完整模式,因此
请先尝试创建它,然后使用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命令。