IMPALA: 在未分区的 table 的基础上创建新的分区 table

IMPALA: Create new partitioned table based on unpartitioned table

我想基于另一个未分区的 table 创建一个新的分区 table。 新的 table 应该被旧的 table 的列分隔。然后我想在新的 table.

中加载所有旧数据
CREATE TABLE new_table PARTITIONED BY (id) STORED AS PARQUET AS SELECT * FROM old_table

here* 所述,id 应该是最后一列,但它是 old_table 中的第一列。 old_table 包含很多列,所以我不想列出所有列。我能做什么?

    *-- We expect this CTAS to fail because non-key column S
-- comes after key columns YEAR and MONTH in the select list.
create table partitions_maybe partitioned by (year, month)
  as select year, month, s from partitions_no;
ERROR: AnalysisException: Partition column name mismatch: year != month

如果您不介意在记录级别复制列信息,您可以这样做

CREATE TABLE new_table PARTITIONED BY (id_partition) STORED AS PARQUET AS SELECT *, id as id_partition FROM old_table

您将无法在 Impala 中以不同的方式进行操作。在 Hive 中,您可以选择 select 所有列,但其他列使用正则表达式。