WestCoastProjects
WestCoastProjects

Reputation: 63062

Comments not working in hive CLI

I have seen other posts saying that double hyphen -- should be a hive comment. But at least within the hive CLI that is not working properly;

hive> -- some comment;
FAILED: Parse Error: line 0:-1 cannot recognize input near '<EOF>' '<EOF>' '<EOF>'

Even in Eduardo Capriolo's book he says the same:

As of Hive v0.8.0, you can embed lines of comments that start with the string --,
for example:
-- Copyright (c) 2012 Megacorp, LLC.
-- This is the best Hive script evar!

The version is apparently 0.8.1 (I am using latest Amazon EMR)

hadoop@ip-10-114-113-44:~$ hive
bin is /home/hadoop/.versions/hive-0.8.1/bin

Upvotes: 16

Views: 13271

Answers (2)

WestCoastProjects
WestCoastProjects

Reputation: 63062

I found a middling workaround:

place semicolon after each comment line like thus:

-- some comment  ;

Then What happens - the CLI does issue an error (still!) but at least does not mangle the succeeding lines of code.

I am using this technique in a few hive scripts now, it allows me to cut and paste snippets into the CLI (with the mentioned caveat ).

Upvotes: 5

www
www

Reputation: 4391

Case is simple Hive accepts comments but not as a single line. If you try:

--comment
show tables;

or

show tables
--comment;

everything will be fine. GL with Hive struggle!

Upvotes: 10

Related Questions