简体   繁体   English

配置单元-如何使用原始表中的分区“将表创建为select ..”?

[英]Hive- how do I “create table as select..” with partitions from original table?

I need to create a "work table" from our hive dlk. 我需要从我们的蜂巢dlk创建一个“工作表”。 While I can use: 虽然我可以使用:

create table my_table as
select *
from dlk.big_table

just fine, I have problem with carrying over partitions (attributes day , month and year ) from original "big_table" or just creating new ones from these attributes. 很好,我在从原始“ big_table”继承分区(属性daymonthyear )或仅从这些属性创建新分区时遇到问题。 Searching the web did not really helped me answer this question- all "tutorials" or solutions deal either with create as select OR creating partitions, never both. 搜索网络并没有真正帮助我回答这个问题-所有“教程”或解决方案要么处理“ create as select创建”,要么创建分区,但绝不会两者兼有。 Can anybody here please help? 请问有人可以帮忙吗?

Creating partitioned table as select is not supported. 不支持将分区表创建为select。 You can do it in two steps: 您可以分两个步骤进行操作:

  1. create table my_table like dlk.big_table; This will create table with the same schema. 这将创建具有相同架构的表。

  2. Load data. 加载数据。

    set hive.exec.dynamic.partition=true; set hive.exec.dynamic.partition.mode=nonstrict;

    insert overwrite table my_table partition (day, month, year) select * from dlk.big_table;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM