代码之家  ›  专栏  ›  技术社区  ›  Yifu Yan

当更改配置单元中的表列位置时遇到“错误无法更改表”

  •  0
  • Yifu Yan  · 技术社区  · 7 年前

    我有一张简单的桌子 fiction_movie :

    hive>describe fiction_movie;
    OK
    title string
    actors array<string>
    genre string
    rating int
    4 rows selected (0.03 seconds)
    

    表中的内容:

    hive> select * from fiction_movie;
    OK
    avatar  ["zoe saldana","Sam worthington"]   science fiction  7
    logan  ["hugh jackman","Patrick stewart"]   science fiction  8
    2 rows selected (0.352 seconds)
    

    我想做的是重新排列列位置并将标题按流派排列:

    #I tried
    hive>alter table fiction_movie change column title title string after genre;
    

    但它给了我以下错误:

    错误:处理语句时出错:失败:执行错误,从org.apache.hadoop.hive.ql.exec.ddltask返回代码1。无法更改表。以下列的类型与各自位置中的现有列不兼容:
    演员,类型(状态=08s01,代码=1)

    有人知道为什么吗?谢谢您!

    1 回复  |  直到 7 年前
        1
  •  1
  •   Vishal Jadiya    7 年前

    这个代码在我的机器上运行得很好。

    hive> create table fiction_movie(
        > title string,
        > actors array<string>,
        > genre string,
        > rating int);
    OK
    Time taken: 0.155 seconds
    hive> alter table fiction_movie change column title title string after genre;
    OK
    Time taken: 0.4 seconds
    hive> describe  fiction_movie;
    OK
    actors                  array<string>
    genre                   string
    title                   string
    rating                  int
    Time taken: 0.37 seconds, Fetched: 4 row(s)
    

    或者尝试设置此属性。 您可以使用以下命令强制配置单元允许您对其进行更改:

    `SET hive.metastore.disallow.invalid.col.type.changes=true;` 
    

    也不会改变你的桌子。