【问题标题】:Hive alter statement on a partitioned table分区表上的 Hive alter 语句
【发布时间】:2017-08-05 00:06:32
【问题描述】:

我在 Hive 中有一个空的分区表,我正在尝试命名一个列以及表中列的顺序:

    > describe formatted test_hive;

col_name 数据类型注释

col1 日期 col2 字符串 col3 字符串 abc 十进制(11,2)

分区信息

col_name 数据类型注释

mth_year 字符串

尝试将 abc 重命名为 xyz 并将其移动到 col1 之后,但是当我运行时

alter table test_hive partition(mth_year)  CHANGE abc  xyz DECIMAL(11,2) AFTER col1;

但出现错误:

FAILED: SemanticException [Error 10006]: Partition not found {proc_mth_year=null}

我们可以对空的分区表进行更改吗?

【问题讨论】:

    标签: hadoop hive hiveql


    【解决方案1】:

    您必须记下特定的分区,例如-

    alter table test_hive partition (mth_year='03_2017') 
    change abc xyz decimal(11,2) after col1
    ;
    

    或在表格级别进行 -

    alter table test_hive
    change abc xyz decimal(11,2) after col1
    cascade
    ;
    

    【讨论】:

    • 感谢您的回答,它成功了。由于我们在表级别进行更改,因此添加 CASCADE 是否更明智?
    • 如果它用于整个表而不仅仅是新分区,那么'是'
    猜你喜欢
    • 2021-04-01
    • 2017-01-26
    • 2020-02-04
    • 2017-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-29
    相关资源
    最近更新 更多