Jackson
Jackson

Reputation: 6871

Hive Query: Use specific database and show tables

I'm trying to execute the following Hive query:

"USE DATABASE1; SHOW TABLES"

Returns the following error:

HiveServerException: Error while compiling statement: FAILED: ParseException line 1:13 missing EOF at ';' near 'DATABASE1'

Upvotes: 1

Views: 10649

Answers (3)

Swarup
Swarup

Reputation: 139

You can simply use the below command to get it done.

show tables in <YOUR_DATABASE_NAME>;

Upvotes: 3

invoketheshell
invoketheshell

Reputation: 3897

I could not get hive to reproduce your error but this might help.

  1. If the database didn't exist you would get a "Database does not exist" error. So I rule that out.
  2. Don't submit with quotes around it and make sure you close your last line with ";". Use this code here:

    use database1; show tables;
    

Upvotes: 1

Nick Veys
Nick Veys

Reputation: 23949

Untested, but some simple database APIs don't support multiple statements very well. Looking at the API, try something like this:

RBHive.connect(address, port) do |connection|
  connection.execute('USE DATABASE1')
  connection.fetch('SHOW TABLES')
end

Upvotes: 0

Related Questions