我正在开发一个Hive演示,我想对包含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演示。我知道Hive-JSON-Serde。但是我怎么告诉Hive忽略log4j前导码?
答案 0 :(得分:0)
您可以使用get_json_object函数从记录中提取json数据并从其中构建。这个博客可以提供帮助。 http://thornydev.blogspot.in/2013/07/querying-json-records-via-hive.html