我想在配置单元中创建一个分区表。我知道先用“createtable…”来创建一个表结构。。。使用“insert into table”命令将数据插入表中
但是我要做的是将这两个命令组合成一个单一的查询,如下面所示,但它会抛出错误。
CREATE TABLE test_extract AS
SELECT
*
FROM master_extract
PARTITION BY (year string
,month string)
;
年和月都是主表中两个独立的列。
有什么办法可以达到这样的目的吗?
2条答案
按热度按时间vom3gejh1#
不,这是不可能的,因为create table as select(ctas)有限制:
您可以单独创建表,然后插入或覆盖它。
vmdwslir2#
自从最初提出和回答这个问题以来,已经有了一些发展。根据hive文档:
Starting with Hive 3.2.0, CTAS statements can define a partitioning specification for the target table (HIVE-20241).
你也可以在这里看到相关的机票。早在2018年7月就已经解决了。因此,如果你的Hive是3.2.0或更高,那么你可以简单地做