Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Why my beeline CLI commnds not working as desired in shell script?

Highlighted

Why my beeline CLI commnds not working as desired in shell script?

New Contributor

I have a shell script code that automates the beeline commands. The code is able to connect to the JDBC, but it sits there, it doesn't seem to execute the further codes in the shell script, ie. it doesn't truncate the table, doesn't load the data, doesn't insert. Below is the whole code::

#! /bin/bash
timestamp=$(date +%Y-%m-%d-%H:%M:%S:%N)
unix_time=$(date +%Y-%m-%d-%H:%M:%S)
export 
BEELINE_PREFIX='"jdbc:hive2://server:port,server:port,server:port/;serviceDiscoveryMode=zookeeper;zookeeperNamespace=hiveser
ver2;principal=hive/server@hello.COM"'
beeline -u $BEELINE_PREFIX -e use next;
echo "truncating the staging table tbl1..."
beeline -u $BEELINE_PREFIX -e  "TRUNCATE TABLE next.tbl1;"
echo "Loading the data in stating table tbl1"
beeline -u $BEELINE_PREFIX -e "LOAD DATA LOCAL INPATH 'path_to/tbl1.txt' INTO TABLE next.tbl1;"
echo "Appending the data into history table tbl1.."
beeline -u $BEELINE_PREFIX -e "insert into table next.hist_tbl1 select *,'$unix_time' from next.tbl1;"
When I execute ./tbl1.sh

I could see below output:

Connecting to 
jdbc:hive2://jdbc:hive2://server:port,server:port,server:port/;serviceDiscoveryMode=zookeeper;zookeeperNamespace=hiveserver2
;principal=hive/server@hello.COM
Connected to:ApacheHive
Driver:Hive JDBC
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 1.2.1000.2.6.5.0-292 by ApacheHive

The code seem to only execute the veru first "beeline -u", i.e, JDBC connection only. I have noted that, When I use ctrl +c, then it goes forward, and throw below error

Error:Errorwhile processing statement: FAILED:ExecutionError,return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask.File file:/usr/ibmpacks/current/bigsql/hive/lib/hive-hbase-handler.jar does not exist (state=08S01,code=1)

Any idea, what is the mistake?

1 REPLY 1

Re: Why my beeline CLI commnds not working as desired in shell script?

@amitesh sahay

I think you might just be missing quotes around "use next;" of your first beeline command. Looks like you have the quotes correctly included on the next two though.

Don't have an account?
Coming from Hortonworks? Activate your account here