我有没有分区键的table1,我想创建一个table2,其架构与table1相同,但是将一列“datestr”设置为分区键。我该如何写CREATE TABLE LIKE查询呢?

table1:

datestr, userID, transaction, balance




table2 (set datestr as partition key):

datestr, userID, transaction, balance

最佳答案

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;

当然要相应地添加列类型

10-02 11:56