0

Using beeline, you can give specific hive commands (not HQL queries !) for hive configuration such as:

add jar myjar.jar

However, I do not understand how you can provide these commands to beeline without being in interactive mode as the documentation does not (or I do not find it) specify how to do it.

I have tried to provide it with the query argument -e , but no success:

beeline \
        -u toto \
        -n toto\
        -p toto \
        --silent=true \
        -e "add jar hivexmlserde-1.0.5.3.jar; show databases;" 

Error: AnalysisException: Syntax error in line 1:
add jar hivexmlserde-1.0.5.3.jar; show databases
^
Encountered: ADD

I have tried to do something like this, but it does not seem to do anything:

beeline \
        -u toto \
        -n toto\
        -p toto\
        --silent=true \
        -e "show databases;" <<EOF
        add jar hivexmlserde-1.0.5.3.jar
        list jar
        EOF

Which does not provide any log about adding a jar to the distributed cache.

How can I give to beeline some beeline commands before executing the provided HQL queries ?

Itération 122442
  • 2,644
  • 2
  • 27
  • 73

1 Answers1

0

Not sure why you are trying to add jar using beeline. You can easily do using hive shell.

  • upload the JAR file into hdfs path hadoop fs -put ~/Downloads/hive.jar /lib/
  • open hive shell and issue - add jar hdfs:///lib/hive.jar

Now, if you want to issue a SQL command, you can use -q in beeline.

beeline ...   -q "show databases;" 

I think for beeline - -u require to give DB url. Something like this

beeline -n username -p password -u jdbc:hive2://hs2.local:10012
Koushik Roy
  • 6,868
  • 2
  • 12
  • 33
  • The documentation says that beeline should be prefered over hive cli, that's why I tried using beeline. Moreover, I do not want to do all this stuff manually, as it is supposed to be an automated job. Finally, when using the hive cli, adding the jar, leaving the cli and getting back into it, the jar is not listed anymore. Is there a reason to that ? – Itération 122442 Oct 07 '22 at 08:55