你如何用 JSON 数据制作一个 HIVE 表?

编程入门 行业动态 更新时间:2024-10-26 16:34:45
本文介绍了你如何用 JSON 数据制作一个 HIVE 表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想从一些 JSON 数据(嵌套)中创建一个 Hive 表并对其运行查询?这甚至可能吗?

I want to create a Hive table out of some JSON data (nested) and run queries on it? Is this even possible?

我已经将 JSON 文件上传到 S3 并启动了一个 EMR 实例,但我不知道在 hive 控制台中输入什么才能使 JSON 文件成为 Hive 表?

I've gotten as far as uploading the JSON file to S3 and launching an EMR instance but I don't know what to type in the hive console to get the JSON file to be a Hive table?

有没有人有一些示例命令可以帮助我入门,我在 Google 上找不到任何有用的东西...

Does anyone have some example command to get me started, I can't find anything useful with Google ...

推荐答案

您需要使用 JSON serde 以便 Hive 将您的 JSON 映射到表中的列.

You'll need to use a JSON serde in order for Hive to map your JSON to the columns in your table.

一个很好的例子,向您展示这里的情况:

A really good example showing you how is here:

aws.amazon/articles/2855

不幸的是,提供的 JSON serde 不能很好地处理嵌套的 JSON,因此您可能需要展平 JSON 才能使用它.

Unfortunately the JSON serde supplied doesn't handle nested JSON very well so you might need to flatten your JSON in order to use it.

以下是文章中正确语法的示例:

Here's an example of the correct syntax from the article:

create external table impressions ( requestBeginTime string, requestEndTime string, hostname string ) partitioned by ( dt string ) row format serde 'com.amazon.elasticmapreduce.JsonSerde' with serdeproperties ( 'paths'='requestBeginTime, requestEndTime, hostname' ) location 's3://my.bucket/' ;

更多推荐

你如何用 JSON 数据制作一个 HIVE 表?

本文发布于:2023-07-10 08:27:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1089839.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何用   数据   JSON   HIVE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!