Hive查询出错

时间:2017-11-23 07:18:16

标签: hadoop hive

我正在尝试使用以下查询运行Map Reduce Job

SELECT  b.userId, a.movieId, a.title, a.genre, b.rating
FROM streaming.movies a JOIN streaming.ratings b
ON a.movieId = b.movieId
WHERE a.genre LIKE '%Adventure%' OR a.genre LIKE '%Children% OR a.genre LIKE '%Action%' OR a.genre LIKE '%Fantasy%' OR a.genre LIKE '%Mystery%' OR a.genre LIKE '%Thriller%' OR a.genre LIKE '%Drama%' OR a.genre LIKE '%Romance%' OR a.genre LIKE '%Sci-Fi%' OR a.genre LIKE '%Comedy%' OR a.genre LIKE '%Horror%'
LIMIT 10;

Hive抛出错误,

Error: Error while compiling statement: FAILED: ParseException line 5:6 cannot recognize input near 'LIMIT' '10' '<EOF>' in expression specification (state=42000,code=40000)

任何人都可以帮助我吗?提前谢谢。

注意:我使用'RLIKE'成功完成了我的工作。我想用'喜欢'锻炼。我的'RLIKE'版代码是,

WHERE a.genre RLIKE '.*(Adventure|Children|Action|Fantasy|Mystery|Thriller|Drama|Romance|Sci-Fi|Comedy|Horror).*'

1 个答案:

答案 0 :(得分:0)

尝试运行此查询

SELECT  b.userId, a.movieId, a.title, a.genre, b.rating
FROM streaming.movies a JOIN streaming.ratings b
ON a.movieId = b.movieId
WHERE a.genre LIKE '%Adventure%' OR a.genre LIKE '%Children%' OR a.genre LIKE '%Action%' OR a.genre LIKE '%Fantasy%' OR a.genre LIKE '%Mystery%' OR a.genre LIKE '%Thriller%' OR a.genre LIKE '%Drama%' OR a.genre LIKE '%Romance%' OR a.genre LIKE '%Sci-Fi%' OR a.genre LIKE '%Comedy%' OR a.genre LIKE '%Horror%'
LIMIT 10;

您在'

中遗失了LIKE '%Children%