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
最后
以上就是尊敬天空最近收集整理的关于解决elasticsearch -在Hive external table 无法读取 date 字段的全部内容,更多相关解决elasticsearch内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复