intropro / prairie

Embedded Environment for Testing
Apache License 2.0
2 stars 5 forks source link

Hive scripts with "SET" #7

Closed ghost closed 8 years ago

ghost commented 8 years ago

When I'm running script that has "SET ..." in it I get an error like:

2015-11-10 15:22:54,433 INFO  [HiveServer2-Handler-Pool: Thread-425] mapred.FileInputFormat (FileInputFormat.java:listStatus(249)) - Total input paths to process : 1
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 100.578 sec <<< FAILURE! - in com.site.proj.tests.HiveTest
testDuplicates(com.site.proj.tests.HiveTest)  Time elapsed: 98.882 sec  <<< ERROR!
org.apache.hive.service.cli.HiveSQLException: 
Error while compiling statement: FAILED: ParseException line 2:4 missing KW_ROLE at 'hive' near 'hive'
line 2:8 missing EOF at '.' near 'hive'
    at com.site.proj.tests.HiveTest.runTestScript(HiveTest.java:105)
    at com.site.proj.tests.HiveTest.testDuplicates(HiveTest.java:150)
Caused by: org.apache.hive.service.cli.HiveSQLException: 
Error while compiling statement: FAILED: ParseException line 2:4 missing KW_ROLE at 'hive' near 'hive'
line 2:8 missing EOF at '.' near 'hive'
Caused by: java.lang.RuntimeException: 
org.apache.hadoop.hive.ql.parse.ParseException:line 2:4 missing KW_ROLE at 'hive' near 'hive'
line 2:8 missing EOF at '.' near 'hive'

When they are removed - all works fine.

SET hive.exec.scratchdir=/tmp/hive-${USERNAME};
SET hive.exec.parallel=true;
SET hive.exec.dynamic.partition=true;
-- Comment
SET hive.exec.dynamic.partition.mode=nonstrict;

USE ${DATABASE_NAME};

.....
presidentio commented 8 years ago

The problem was in comment, not in set keyword. According to this reply https://issues.apache.org/jira/browse/HIVE-1166?focusedCommentId=12833402&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12833402 comments can be used only before queries.