如何使用nifi puthive3streaming处理器将嵌套的json插入配置单元

cuxqih21  于 2021-06-24  发布在  Hive
关注(0)|答案(0)|浏览(282)

我有一个简单的nifi流程:
nifi流
此nifi流生成嵌套的json:

{"ts":"10000000000","struct1":{"id1":1, "name1":"test1", "struct2":{"id2":2, "name2":"test2"}}}

之后,我尝试将此json插入到配置单元表中,使用具有以下设置的puthive3streaming处理器:  Puthive3流属性
jsontreReader属性:jsontreReader属性
架构文本是avro架构:

{
 "type" : "record",
 "name" : "test",
 "fields" : [ 
    { "name" : "ts", "type" : "string"},
    { "name" : "struct1",
      "type" : { 
        "type" : "record",
        "name" : "struct1",
        "fields" : [ 
            { "name" : "id1", "type" : "int" },
            { "name" : "name1", "type" : "string"},
            { "name" : "struct2", "type" : { 
                "type" : "record",
                "name" : "struct2",
                "fields" : [ 
                    { "name" : "id2", "type" : "int"},
                    { "name" : "name2", "type" : "string"}
                    ]
                  }
            }
         ] 
        }
    }
  ] 
}

配置单元表ddl:

create table default.struct_issue (
ts string,
struct1 struct<id1:int, name1:string, struct2:struct<id2:int, name2:string>>);

当puthive3streaming尝试插入数据时,我遇到了下一个错误:puthive3streaming error
看起来nifi在json中看不到“struct2”字段,但是这个字段出现在其中。 
更新!nifi(v1.8.0)也有同样的问题,看起来已经解决了(https://issues.apache.org/jira/browse/nifi-5491 ),但这个问题仍然存在于nifi(v1.9.0)中
p、 作为解决方法,我在hive中成功地创建了带有json serde属性的外部表,并将这个json放在hdfs目录中 它与外部表目录匹配。我的任务是使用nifi处理器将这个json插入到内部配置单元表中。  堆栈和版本:堆栈和版本
提前谢谢! 

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题