异常java.io.IOException失败:org.apache.avro.AvroTypeException:发现很长,期待在hive中联合
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了异常java.io.IOException失败:org.apache.avro.AvroTypeException:发现很长,期待在hive中联合,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3430字,纯文字阅读大概需要5分钟。
内容图文
需要帮忙!!!
我正在使用flume将twitter feed传输到hdfs并将其加载到hive中进行分析.
步骤如下:
hdfs中的数据:
我在avsc文件中描述了avro架构并将其放在hadoop中:
{"type":"record",
"name":"Doc",
"doc":"adoc",
"fields":[{"name":"id","type":"string"},
{"name":"user_friends_count","type":["int","null"]},
{"name":"user_location","type":["string","null"]},
{"name":"user_description","type":["string","null"]},
{"name":"user_statuses_count","type":["int","null"]},
{"name":"user_followers_count","type":["int","null"]},
{"name":"user_name","type":["string","null"]},
{"name":"user_screen_name","type":["string","null"]},
{"name":"created_at","type":["string","null"]},
{"name":"text","type":["string","null"]},
{"name":"retweet_count","type":["boolean","null"]},
{"name":"retweeted","type":["boolean","null"]},
{"name":"in_reply_to_user_id","type":["long","null"]},
{"name":"source","type":["string","null"]},
{"name":"in_reply_to_status_id","type":["long","null"]},
{"name":"media_url_https","type":["string","null"]},
{"name":"expanded_url","type":["string","null"]}]}
我编写了一个.hql文件来创建一个表并在其中加载数据:
create table tweetsavro
row format serde
'org.apache.hadoop.hive.serde2.avro.AvroSerDe'
stored as inputformat
'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
outputformat
'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
tblproperties ('avro.schema.url'='hdfs:///avro_schema/AvroSchemaFile.avsc');
load data inpath '/test/twitter_data/FlumeData.*' overwrite into table tweetsavro;
我已成功运行.hql文件,但是当我运行select * from< tablename>命令在hive中显示以下错误:
tweetsavro的输出是:
hive> desc tweetsavro;
OK
id string
user_friends_count int
user_location string
user_description string
user_statuses_count int
user_followers_count int
user_name string
user_screen_name string
created_at string
text string
retweet_count boolean
retweeted boolean
in_reply_to_user_id bigint
source string
in_reply_to_status_id bigint
media_url_https string
expanded_url string
Time taken: 0.697 seconds, Fetched: 17 row(s)
解决方法:
我面临着同样的问题.问题存在于timestamp字段(在您的情况下为“created_at”列),我试图将其作为字符串插入到我的新表中.我的假设是这个数据在我的源代码中是[“null”,“string”]格式.我分析了从sqoop import –as-avrodatafile进程生成的源avro架构.从导入生成的avro架构具有以下时间戳列的签名.
{
“name”:“order_date”,
“type”:[“null”,“long”],
“default”:null,
“columnName”:“order_date”,
“sqlType”:“93”
},
SqlType 93代表Timestamp数据类型.所以在我的目标表Avro Schema文件中,我将数据类型更改为“long”,这解决了这个问题.我的猜测可能是你的一个列中数据类型的不匹配.
内容总结
以上是互联网集市为您收集整理的异常java.io.IOException失败:org.apache.avro.AvroTypeException:发现很长,期待在hive中联合全部内容,希望文章能够帮你解决异常java.io.IOException失败:org.apache.avro.AvroTypeException:发现很长,期待在hive中联合所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。