我正在做一个配置单元演示,我想对一个包含json消息的文件执行和聚合查询,每个日志行的开头都有一个log4j样式的消息:
20:49:07.962 [main] INFO com.example.application - {"DocId":"ABC","User":{"Id":1236,"Username":"larry1234","Name":"Larry","ShippingAddress":{"Address1":"789 Main St.","Address2":"","City":"Durham","State":"NC","PostalCode":"27713"},"Orders":[{"ItemId":1111,"OrderDate":"11/11/2012"},{"ItemId":2222,"OrderDate":"12/12/2012"}]}}
我有大量这样的记录,并在一个Hive演示工作。我知道Hivejson serde。但是我该如何告诉hive忽略log4j的前导呢?
1条答案
按热度按时间w41d8nur1#
您可以使用get_json_object函数从记录中提取json数据,并从其上构建。这个博客会有帮助的。http://thornydev.blogspot.in/2013/07/querying-json-records-via-hive.html