You can certainly connect to Impala using Hive Driver from beeline, like below command:

beeline -u 'jdbc:hive2://<impala-daemon-host>:21050/default;auth=noSasl'

However, the result output format does not work properly:

> show tables;
customers
dim_prod
mansi
sample_07
sample_08
small
web_logs
+-------+--+
| name  |
+-------+--+
+-------+--+

Notice the output is not inside the columns?

The better approach is to use Cloudera Impala JDBC Driver, please follow the steps below:

1. Download the driver from Cloudera Impala JDBC Driver
2. Extract the files and put it somewhere on the host that you need to run beeline command, in my case is under /root/impala-jdbc/jdbc
3. Run the following command to update the HADOOP_CLASSPATH to include the Impala JDBC Driver JARs

export HADOOP_CLASSPATH=`hadoop classpath`:/root/impala-jdbc/jdbc/*

4. Finally you are ready to start beeline:

beeline -d "com.cloudera.impala.jdbc41.Driver" -u 'jdbc:impala://<impala-daemon-host>:21050;AuthMech=0'

You will need to tell beeline the class name for the driver using “-d” option, in my case the driver class is com.cloudera.impala.jdbc41.Driver

The output looks much better:

> show tables;
+------------+--+
|    name    |
+------------+--+
| customers  |
| dim_prod   |
| mansi      |
| sample_07  |
| sample_08  |
| small      |
| web_logs   |
+------------+--+
7 rows selected (0.219 seconds)

However, the best way is to connect from impala-shell which is designed for Impala natively.

Hope this helps.

5 Comments

  1. Vzeekan

    Eric,
    How do you set the impala resource pool in beeline from the command line?

    This command doesnt work
    beeline -u ‘jdbc:hive2://somehost:someport/db_name;principal=impala/Some Kerberos Principal’ -q ‘set REQUEST_POOL=root.FRW_Pool.fixed.other;’

    1. Eric Lin

      Hi Vzeekan,

      Sorry about the late reply and thanks for visiting my blog. I am on business trip in India, hence delayed response.

      You can’t run “SET REQUEST_POOL={name}” command, but you can pass the REQUEST_POOL when connecting to Impala if you are using Cloudera Impala JDBC driver, see the doc below for reference:

      https://www.cloudera.com/documentation/other/connectors/impala-jdbc/latest/Cloudera-JDBC-Driver-for-Impala-Install-Guide.pdf

      On page 22, you can see example there:

      jdbc:impala://localhost:18000/default2;AuthMech=3;UID=cloudera;PWD=cloudera;MEM_LIMIT=1000000000;REQUEST_POOL=myPool

      Hope this helps.

  2. Jose

    Hi There!
    I tried with the JDBC 4.1 2.5.37 driver and get NPE without stacktrace

    “`
    training@elephant:~/impala-jdbc$ beeline -d “com.cloudera.impala.jdbc41.Driver” -u ‘jdbc:hive2://elephant:21050/default;LogLevel=6;LogPath=`pwd`;principal=impala/elephant@COE.CLOUDERA.COM;AuthMech=1;’
    Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
    2019-07-11 11:17:38,747 WARN [main] mapreduce.TableMapReduceUtil: The hbase-prefix-tree module jar containing PrefixTreeCodec is not present. Continuing without it.
    Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
    Connecting to jdbc:hive2://elephant:21050/default;LogLevel=6;LogPath=`pwd`;principal=impala/elephant@COE.CLOUDERA.COM;AuthMech=1;
    java.lang.NullPointerException
    Beeline version 1.1.0-cdh5.9.0 by Apache Hive
    0: jdbc:hive2://elephant:21050/default (closed)> !q
    java.lang.NullPointerException
    java.lang.NullPointerException
    “`

Leave a Reply

Your email address will not be published. Required fields are marked *