Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Hive >> mail # user >> Find table location


+
Peter Marron 2013-06-27, 08:49
+
Nitin Pawar 2013-06-27, 08:56
Copy link to this message
-
RE: Find table location
Hi,

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

CREATE TABLE small (...)
STORED AS
INPUTFORMAT 'MyInputFormat'
...;

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.

Z

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

from Alex's blog
http://mapredit.blogspot.in/2013/05/get-all-extended-hive-tables-with.html
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 <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>> wrote:
Hi,

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.)

Z

--
Nitin Pawar