hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Marron <>
Subject RE: Find table location
Date Thu, 27 Jun 2013 10:03:17 GMT

OK. Imagine I've created a Hive table like this:

CREATE TABLE small (...)

My class MyInputFormat looks like this:

public void configure(JobConf jc) {
                String tableName = "BigTable";
                String location = magicFunction(tableName);

(Obviously I don't really care which method of the InputFormat we use.)
So the question is how do I implement the magicFunction?

Your suggestion about HiveMetaStoreClient is what I want. I can see that if I call

                HiveMetaStoreClient.getTable(database, "BigTable").getSd().getLocation()

then this gives me what I want. So a couple of questions:

1)      I assume that the first argument to getTable is the database, how can I find

out what the "current" database is for the table that the Input format is created in?

2)      How do I get hold of a HiveMetaStoreClient object?

Many thanks for your help.


From: Nitin Pawar []
Sent: 27 June 2013 09:56
Subject: Re: Find table location

from Alex's blog

if you want to do it programatically then you will need to look at HiveMetaStoreClient

If both of these are not what you are looking for then sorry I will need a little more details
on your question

On Thu, Jun 27, 2013 at 2:19 PM, Peter Marron <<>>

Hopefully a simple question.
Given that I have a table name (as a String) is there an API call that I can
use to obtain the location of the table? Assume that my code is executing
in a custom InputFormat to define the context.  (I'm running "inside" a Hive
query so I assume that there's a way which doesn't involve calling an external
HCatalog server or anything like that.)


Nitin Pawar

View raw message