【问题标题】:Hive: Ignore field in create tableHive:忽略创建表中的字段
【发布时间】:2019-08-19 04:28:49
【问题描述】:

我必须将 json 格式的数据加载到配置单元中。问题是存在一个字段,该字段是每条记录不同的日期,导致各种问题。一条记录的 DDL 如下所示:

CREATE EXTERNAL TABLE `not_really_awesome_table` (
  `super_wtf`         struct<
    `10-02-2019`:        string
  >
  `super_blah`        struct <
    `bleh`:             string,
    `blah`:             string,
    `sub_blah`:         struct <
      `blah_field`:       string,
      `bleh_field`:       string
    >
  >
)
ROW FORMAT  serde 'org.openx.data.jsonserde.JsonSerDe'
with serdeproperties ( 'ignore.malformed.json' = 'true' )
LOCATION
  's3://wtf/is/this/lol'
TBLPROPERTIES (
  'has_encrypted_data'='false',
  'transient_lastDdlTime'='1539066055')
;

有没有办法忽略super-wtf 字段或将其转换为某种类型以避免进一步解析它?

【问题讨论】:

    标签: json hive hiveql presto amazon-athena


    【解决方案1】:

    您可以跳过 DDL 中的 super-wtf 列并添加其他所有内容:

    CREATE EXTERNAL TABLE `not_really_awesome_table` (
      `super_blah`        struct <
        `bleh`:             string,
        `blah`:             string,
        `sub_blah`:         struct <
          `blah_field`:       string,
          `bleh_field`:       string
        >
      >
    )
    

    在这种情况下,它不会从 JSON 中解析出来。

    或者在 DDL 中将super-wtf 列定义为map&lt;string, string&gt;

    【讨论】:

    • 已确认,无论如何我将super-wtf 定义为地图 并且它有效。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2014-02-12
    • 2020-01-16
    • 2020-10-26
    • 1970-01-01
    • 2015-03-19
    • 2016-07-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多