0

I would like to pass a hive arg that contains a single quote in a string. This causes the EMR Job to fail with the following error:

sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
Command exiting with ret '255'

Desired Variable:

-hiveconf "myvar=Today's a great day for a test!"

Any ideas? Thanks.

user922295
  • 83
  • 1
  • 7

1 Answers1

0

try:

SET myvar="Today's a great day for a test!";

then call it:

SELECT * FROM myTable WHERE test_today=${hiveconf:myvar}

That worked for me when I tried it, but when I try:

SET myvar=Today's a great day for a test! (withoutquotes)

I get an error. Hope this helps

Engineiro
  • 1,146
  • 7
  • 10
  • I tried adding double quotes around the string and unfortunately it didn't work, received the following error: sh: -c: line 0: unexpected EOF while looking for matching `"' sh: -c: line 1: syntax error: unexpected end of file Also I'm passing the string in through an EMR Job, so I cannot set the variable directly in the hive console. Thanks. Command exiting with ret '255' – user922295 Apr 18 '13 at 21:16
  • Could you provide the exact command and error you are using and receiving? You are passing this in through an EMR job, so you are putting this at the terminal, right? – Engineiro Apr 18 '13 at 23:52
  • So I can't pass the exact command, but here is a very cleaned up version of what I"m passing to the EMR Job, this is a step in the process: `s3n://us-east-1.elasticmapreduce/libs/hive/hive-script --base-path s3n://us-east-1.elasticmapreduce/libs/hive/ --hive-versions latest --run-hive-script --args -f s3://bucket/myscript.hql -hiveconf "my_var=\"Today's a great day!\"" ` – user922295 Apr 18 '13 at 23:56
  • have you tried `"my_var=\"Today\'s a great day!\""` This should make it equivalent to the statement above since it allowed you to escape the (") – Engineiro Apr 19 '13 at 01:41
  • I decide to just url encode the string and decode it later in a transform step. Thanks. – user922295 Apr 19 '13 at 15:35