【问题标题】:Hadoop: querying/reading Avro filesHadoop:查询/读取 Avro 文件
【发布时间】:2017-05-14 12:43:54
【问题描述】:

我正在存储从复杂 JSON 对象导入到 Avro 格式的数据。

JSON 对象由具有嵌套对象和对象数组的对象表示。 Avro Schema 如下所示:

{
    "type" : "record",
    "name" : "userInfo",
    "namespace" : "my.example",
    "fields" : [{"name" : "username", 
                 "type" : "string", 
                 "default" : "NONE"},

                {"name" : "age", 
                 "type" : "int",
                 "default" : -1},

                 {"name" : "phone", 
                  "type" : "string", 
                  "default" : "NONE"},

                 {"name" : "housenum", 
                  "type" : "string", 
                  "default" : "NONE"},

                  {"name" : "address", 
                   "type" : {
                         "type" : "record",
                         "name" : "mailing_address",
                         "fields" : [
                            {"name" : "street", 
                             "type" : "string", 
                             "default" : "NONE"},

                            {"name" : "city", 
                             "type" : "string", 
                             "default" : "NONE"},

                            {"name" : "state_prov", 
                             "type" : "string", 
                             "default" : "NONE"},

                            {"name" : "country", 
                             "type" : "string", 
                             "default" : "NONE"},

                            {"name" : "zip", 
                             "type" : "string", 
                             "default" : "NONE"}
                          ]},
                          "default" : {}
                }
    ]
} 

我使用 NiFi 将 JSON 转换为 Avro 并将序列化文件存储在 Hadoop 中(目前我只使用纯 Hadoop):

我的问题:

出于测试目的,我想查询存储 HDFS(Avro 格式)的数据。

所以在这一点上我有点困惑,因为围绕 Hadoop 的工具和技术很多...... 我怎样才能以正确的方式做到这一点?什么工具和工作流程?

【问题讨论】:

    标签: java hadoop hdfs avro apache-nifi


    【解决方案1】:

    您应该能够在写入 Avro 数据的 HDFS 位置之上创建一个外部 Hive 表。

    这篇文章有例子:

    https://community.hortonworks.com/questions/22135/is-there-a-way-to-create-hive-table-based-on-avro.html

    https://cwiki.apache.org/confluence/display/Hive/AvroSerDe

    【讨论】:

      猜你喜欢
      • 2019-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多