解决elasticsearch -在Hive external table 无法读取 date 字段

来源:互联网 发布:leetcode python 编辑:程序博客网 时间:2024/06/13 00:47

1.问题描述

   对于@timestamp字段,在es中类型为date,创建hive外表时如果使用类型仍为date,操作时会报如下错误

 Failed with exception java.io.IOException:org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.ClassCastException: org.apache.hadoop.hive.serde2.io.TimestampWritable cannot be cast to org.apache.hadoop.hive.serde2.io.DateWritable

  

2.解决办法

 将date类型改为timestamp即可,例如:
 CREATE EXTERNAL TABLE ext3 (run_date timestamp) ROW FORMAT SERDE 'org.elasticsearch.hadoop.hive.EsSerDe' STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' TBLPROPERTIES('es.resource' = 'dfs/ext3', 'es.field.read.empty.as.null' = 'true','es.nodes'=);

  

 参考:http://www.itkeyword.com/doc/6573413286728074561/unable-to-query-date-field-in-hive-external-table

             https://www.iteblog.com/archives/892.html

0 0
原创粉丝点击