简体   繁体   English

我可以将已加载数据的非分区表更改为具有动态分区吗?

[英]Can i alter non-Partitioned table with already loaded data to have dynamic partitions?

I have tried with using hive command我尝试使用 hive 命令

insert into table partitioned_table_name partition(partition_col) select * from non-Partitioned table; insert into table partitioned_table_name partition(partition_col) select * 来自非分区表;

Yes, of course you can do it.是的,你当然可以做到。 But you need to select correct sequence of columns while inserting.但是您需要 select 插入时正确的列顺序。 for example, if your table structure is like this -例如,如果您的表结构是这样的 -

create table mytable_patitioned (c1 int, c2 string) partition by c3 int;

Then your insert statement should be like below - partition column should be last column in select statement.那么您的插入语句应该如下所示 - 分区列应该是 select 语句中的最后一列。

insert into mytable_patitioned partition(c3) select c1,c2,c3 from non_part_table;

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

相关问题 非分区表对蜂巢的优势? - Advantages of non-partitioned table on hive? 如何在Hive上对未分区的表进行分区? - How to partition a non-partitioned table on Hive? PySpark 数据从非分区 hive 表加载到分区 hive 表的性能调整 - Performance tuning for PySpark data load from a non-partitioned hive table to a partitioned hive table 查询整个 Hive 外部表上的非分区列 - Query non-partitioned column on Entire Hive external Table SPARK 1.6插入现有的Hive表(未分区) - SPARK 1.6 Insert into existing Hive table (non-partitioned) hive 中的动态分区表未更新最近的分区 - Dynamic partitioned table in hive not updating the recent partitions 外部非分区 Hive 表显示 0 条记录,即使 parquet 文件有数据,当使用 spark.read.parquet 读取时,它显示正确的数据 - External non-partitioned Hive table shows 0 records even if parquet file has data, when read using spark.read.parquet it shows correct data 使用 ALTER 添加新列后,数据错误地加载到 Hive 分区表中 - Data Loaded wrongly into Hive Partitioned table after adding a new column using ALTER 将数据从分区表加载到非分区表 - Loading data from partitioned to non partitioned table 数据未加载到 Hive 中的分区表中 - Data not getting loaded into Partitioned Table in Hive
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM