gpt4 book ai didi

java - 失败,异常 java.io.IOException :org. apache.avro.AvroTypeException : Found long, 期望在配置单元中联合

转载 作者:可可西里 更新时间:2023-11-01 14:18:55 25 4
gpt4 key购买 nike

需要帮助!!!

我正在使用 flume 将 Twitter 提要流式传输到 hdfs 中并将其加载到 hive 中进行分析。

步骤如下:

hdfs 中的数据:

我已经描述了 avro schemaavsc文件并将其放入 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> 时配置单元中的命令显示以下错误:

error

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)

最佳答案

我遇到了完全相同的问题。该问题存在于时间戳字段(在您的案例中为“created_at”列),我试图将其作为字符串插入到我的新表中。我的假设是这些数据在我的源代码中将采用 [ "null","string"] 格式。我分析了从 sqoop import --as-avrodatafile 过程中生成的源 avro 模式。从导入生成的 avro 模式具有以下时间戳列的签名。
{
“名称”:“订单日期”,
“类型”:[“空”,“长”],
“默认”:空,
“列名”:“订单日期”,
“sqlType”:“93”
},

SqlType 93 代表时间戳数据类型。因此,在我的目标表 Avro 模式文件中,我将数据类型更改为“长”,这解决了问题。我的猜测可能是您的其中一列中的数据类型不匹配。

关于java - 失败,异常 java.io.IOException :org. apache.avro.AvroTypeException : Found long, 期望在配置单元中联合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35480155/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com