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

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

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

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

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

  1. {
  2. "type" : "record",
  3. "name" : "test",
  4. "fields" : [
  5. { "name" : "ts", "type" : "string"},
  6. { "name" : "struct1",
  7. "type" : {
  8. "type" : "record",
  9. "name" : "struct1",
  10. "fields" : [
  11. { "name" : "id1", "type" : "int" },
  12. { "name" : "name1", "type" : "string"},
  13. { "name" : "struct2", "type" : {
  14. "type" : "record",
  15. "name" : "struct2",
  16. "fields" : [
  17. { "name" : "id2", "type" : "int"},
  18. { "name" : "name2", "type" : "string"}
  19. ]
  20. }
  21. }
  22. ]
  23. }
  24. }
  25. ]
  26. }

配置单元表ddl:

  1. create table default.struct_issue (
  2. ts string,
  3. 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插入到内部配置单元表中。  堆栈和版本:堆栈和版本
提前谢谢! 

暂无答案!

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

相关问题