Apache Hive:重命名类型为array <struct <>>的列

时间:2019-09-26 14:07:02

标签: hive hiveql

我有一个交易表说:

        CREATE TABLE Test(
         `name` string,
         `tracking_id` string,
          `actions`    array<struct<call:string,score:int,decision:string>>)
       PARTITIONED BY (
          `year` int,
          `month` int,
          `day` int)
       CLUSTERED BY (
           tracking_id)
       INTO 6 BUCKETS
       STORED AS ORC
       TBLPROPERTIES (
         'orc.compress'='ZLIB',
         'orc.compression.strategy'='SPEED',
         'orc.create.index'='true',
         'orc.encoding.strategy'='SPEED',
         'transactional'='true');

我表中有一堆数据

在做select * from test limit 1;

0: jdbc:hive2://hive-server-two:10000> select * from test;
+------------+-------------------+------------------------------------------------+------------+-------------+-----------+--+
| test.name  | test.tracking_id  |                  test.actions                  | test.year  | test.month  | test.day  |
+------------+-------------------+------------------------------------------------+------------+-------------+-----------+--+
| User25     | 25                | [{"call":"put","score":100,"decision":"win"}]  | 2019       | 9           | 26        |
+------------+-------------------+------------------------------------------------+------------+-------------+-----------+--+

我现在想将列actions重命名为play

alter table test change actions play array<struct<call:string,score:int,decision:string>>;

现在,如果我运行select play from test limit 1

+-------+--+
|  play |
+-------+--+
| NULL  |
+-------+--+

这是有原因的吗?如何简单地重命名列?

1 个答案:

答案 0 :(得分:0)

我们https://docs.docker.com/engine/api/v1.30/#operation/ContainerList更改具有复杂类型类型的列,例如,您共享的列具有复杂数据类型。

注意:复杂类型

arrays: ARRAY<data_type>
maps: MAP<primitive_type, data_type> 
structs: STRUCT<col_name : data_type >
union: UNIONTYPE<data_type, data_type, ...>