Hive CREATE TABLE LIKE另一个表集分区键

时间:2017-10-18 00:00:33

标签: hadoop hive

我有table1没有分区键,我想创建一个table2,使用与table1相同的架构,但设置一列" datestr& #34;作为分区键。如何编写CREATE TABLE LIKE查询来执行此操作?

table1:

datestr, userID, transaction, balance




table2 (set datestr as partition key):

datestr, userID, transaction, balance

1 个答案:

答案 0 :(得分:0)

CREATE TABLE LIKE DDL不支持设置分区

我相信你可以像这样执行CTAS查询

Create table table2 (userID INT, transaction STRING, balance DECIMAL) 
Partitioned by (datestr STRING) 
as 
select userID, transaction, balance, datestr 
From table1;

当然,相应地添加列类型