gpt4 book ai didi

database - 如何创建从一个 impala 表到另一个表的分区

转载 作者:搜寻专家 更新时间:2023-10-30 20:08:31 25 4
gpt4 key购买 nike

我想在我们的数据库中克隆一个名为“blah”的 impala 表以用于测试目的(这样我就不会意外删除我不应该删除的内容)。但是,表“blah”有分区,而且我正在运行的命令似乎并没有起到作用。有人可以告诉我在新表中自动创建/模拟分区的任何技巧,还是我需要在新表中手动创建分区?

我使用的命令是:

CREATE TABLE blah_copy LIKE blah
INSERT INTO TABLE blah_copy SELECT * FROM blah

它看起来在我运行时为我创建表,因为它们具有相同的列数

desc blah
desc blah_copy

但是,当我尝试复制数据时(上面的插入语句),它告诉我

ERROR: AnalysisException: Not enough partition columns mentioned in query. Missing columns are: www, xxx, yyy, zzz.

查看 cloudera documentation ,它说:

If the original table is partitioned, the new table inherits the same partition key columns. Because the new table is initially empty, it does not inherit the actual partitions that exist in the original one. To create partitions in the new table, insert data or issue ALTER TABLE ... ADD PARTITION statements.

这就是我现在所处的位置。提前感谢您能给我的任何帮助。

最佳答案

如果你有最新的 impala 版本你可以做

create table blah_copy partitioned by (column_x, column_y, column_z) as select * from blah;

关于database - 如何创建从一个 impala 表到另一个表的分区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37311896/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com