在json serde中选择查询返回json文件

时间:2015-06-02 09:34:13

标签: json hadoop hive

我添加了cloudera的jar文件 添加JAR hive-serdes-1.0-SNAPSHOT。

示例数据

{
    "_id" : "0000540a-e28c-44e3-a2bf-d579af4d43f4",
    "CreatedDate" : ISODate("2014-12-22T18:22:30.250Z"),
    "UpdatedDate" : ISODate("2015-02-12T04:23:53.326Z"),
    "AccountId" : "73f98922-c1a9-4fd9-bcbf-bcb24ea50009",
    "Url" : "https://mail.google.com/mail/u/1/#search/paul+roberts",
    "Host" : "mail.google.com",
    "VisitTime" : ISODate("2014-12-22T17:59:51.225Z"),
    "Transition" : "link",
    "LifeTime" : 3267.0000000000000000,
    "Status" : "closed",
    "LocalTime" : ISODate("2014-12-22T17:59:51.225Z"),
    "referrer" : "",
    "tabId" : "409",
    "SiteType" : "Mail"
}

我创建了表格 创建外部表pof.TestForJson(id字符串,CreatedDate STRUCT,UpdatedDate STRUCT,AccountId字符串,Url字符串,主机字符串,VisitTime STRUCT,转换字符串,LifeTime字符串,状态字符串,LocalTime STRUCT,DeviceId字符串,SubSiteType字符串,SiteType字符串,标志字符串)行格式serde' com.cloudera.hive.serde.JSONSerDe' 与

serdeproperties("id"="_id" , "CreatedDate.date"="$.date" , "UpdatedDate.date"="$.date" , "VisitTime.date"="$.date" , "LocalTime.date"="$.date") location '/user/hive/warehouse/pof.db/testdata';

当我运行select query时得到null值。

请帮忙!

0 个答案:

没有答案