1

I am trying to use Hive variable.

If I login to Hive and use :

hive > set a=test_table;
hive > describe ${hiveconf:a};

But Same command if try from Shell , it gives : Parse Error 1:1 cannot recognize input near ...

$> hive -e "set a=test_table; describe ${hiveconf:a};"
Parse Error 1:1 cannot recognize input near <EOF>
Pradeep Bhadani
  • 4,435
  • 6
  • 29
  • 48

3 Answers3

0
Parameter Expansion
   The `$' character introduces parameter expansion, command substitution, or arithmetic expansion.  The parameter name  or
   symbol  to  be  expanded  may be enclosed in braces, which are optional but serve to protect the variable to be expanded
   from characters immediately following it which could be interpreted as part of the name.

   When braces are used, the matching ending brace is the first `}' not escaped by a backslash or within a  quoted  string,
   and not within an embedded arithmetic expansion, command substitution, or parameter expansion.

   ${parameter}
          The  value  of  parameter  is substituted.  The braces are required when parameter is a positional parameter with
          more than one digit, or when parameter is followed by a character which is not to be interpreted as part  of  its
          name.

so : hive -e 'set a=test_table; desc ${hiveconf:a};'

Sterling Archer
  • 22,070
  • 18
  • 81
  • 118
0

Try this:

hive --hiveconf a="test_table" -e "describe database.${hiveconf:a}"

swapnil shashank
  • 877
  • 8
  • 11
-1

you have to code like below.

   >a=test_table
   >hive -e "describe $a"

Check language manual

Balaswamy Vaddeman
  • 8,360
  • 3
  • 30
  • 40