Jump to content

Specifiy "use database" in Hadoop Hive HQL query


bradley.harris

Recommended Posts

We have multiple databases defined in Hive. In Hive command line mode or a script I can issue "use database" followed by a query (example below). When I try to specify the use database in the report query dialog I get an errror. Also I replaced /defualt at the end of JDBC connection string with my database name and it did not like that. Is there a method to specify a database name?

 

use test;

select * from test_table;

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

If I use the connection string below I connect to the default database.

jdbc:hive://hdpencwy0001:10000/default

If I point to the "test" database (jdbc:hive://hdpencwy0001:10000/test)I receive the following error: Error: net.sf.jasperreports.engine.JRException: Invalid Hive JDBC url:jdbc:hive://hdpencwy0001:10000/test

Verified database and table with data exists. Using vesrion 5.

Link to comment
Share on other sites

  • 9 months later...
  • 1 month later...

Unfortuately the JDBC Hive driver only allows connecting to the "default" database (this is not a Jaspersoft limitation but a JDBC Hive driver one) - so to get around this just use the table aliasing in dot notation, like this:

 

select * from store.sales

 

Connects to database store, table sales!

 

This is the page that points out the limitation in Hadoop Hive JDBC driver:

https://cwiki.apache.org/confluence/display/Hive/HiveClient#HiveClient-JDBC

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...