Hive 无法运行配置单元查询
我在Cloudera VM中使用配置单元查询创建了一个Hive 无法运行配置单元查询,hive,hiveql,cloudera-quickstart-vm,Hive,Hiveql,Cloudera Quickstart Vm,我在Cloudera VM中使用配置单元查询创建了一个表,下面是我的DDL,用于创建名为incremental\u tweets的表 CREATE EXTERNAL TABLE incremental_tweets ( id BIGINT, created_at STRING, source STRING, favorited BOOLEAN, retweet_count INT, retweeted_status STRUCT< text:STRING, user:STRUCT&
表
,下面是我的DDL
,用于创建名为incremental\u tweets
的表
CREATE EXTERNAL TABLE incremental_tweets (
id BIGINT,
created_at STRING,
source STRING,
favorited BOOLEAN,
retweet_count INT,
retweeted_status STRUCT<
text:STRING,
user:STRUCT<screen_name:STRING,name:STRING>>,
entities STRUCT<
urls:ARRAY<STRUCT<expanded_url:STRING>>,
user_mentions:ARRAY<STRUCT<screen_name:STRING,name:STRING>>,
hashtags:ARRAY<STRUCT<text:STRING>>>,
text STRING,
user STRUCT<
screen_name:STRING,
name:STRING,
friends_count:INT,
followers_count:INT,
statuses_count:INT,
verified:BOOLEAN,
utc_offset:INT,
time_zone:STRING>,
in_reply_to_screen_name STRING
)
ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe'
LOCATION '/twitteranalytics/incremental/';
错误
Error while processing statement: FAILED: Execution Error, return code 2
from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
Error while compiling statement: FAILED: RuntimeException cannot find field
,user_mentions(lowercase form: ,user_mentions) in [urls, user_mentions,
hashtags]
另外,由于HUE editor
提供了自动完成功能,下面是它给出的语句和错误
语句
Select id, entities.user_mentions.name FROM incremental_tweets;
Select id, entities.`,user_mentions`.name FROM incremental_tweets;
错误
Error while processing statement: FAILED: Execution Error, return code 2
from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
Error while compiling statement: FAILED: RuntimeException cannot find field
,user_mentions(lowercase form: ,user_mentions) in [urls, user_mentions,
hashtags]
什么是正确的
SELECT语句
?我是否遗漏了语法 用户所提到的
是一个结构数组。只能通过指定数组索引来寻址内部结构元素:
entities.user_mentions[0].name --get name from first array element
如果要选择所有阵列元素,请使用explode()
select id, user_mention.name
from incremental_tweets
lateral view outer explode(entities.user_mentions) s as user_mention
;
感谢您的回复,我尝试了explode()
+横向视图
,但最终还是出现了相同的错误<代码>处理语句时出错:失败:执行错误,从org.apache.hadoop.hive.ql.exec.mr.MapRedTask返回代码2。它在控制台上打印的此异常不是informative@ANmike语法正确,我已经检查过了。最可能的问题在于数据。请提供数据示例和工作跟踪日志。