hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Koert Kuipers <ko...@tresata.com>
Subject Re: Do some basic operations on my hive warehouse from java
Date Wed, 19 Oct 2011 23:27:14 GMT
Thanks for your reply Edward.

I see you use CommandProcessorFactory, and then you pass the actual commands
in as strings, such as:
doHiveCommand("create table bla (id int)", c)

However i assume this somewhere gets translated into normal Java commands
inside of hive? Something like Someclass.createTable(someinput). I would
prefer to work at that level instead of having to translate my commands
first into Strings which then get passed into a CommandProcessor.

With a remote connection (to a hive server) i can do just that:
TTransport transport = new TSocket(host, port);
TProtocol protocol = new TBinaryProtocol(transport);
HiveClient client = new HiveClient(protocol);
client.drop_table(database, table, true)

Do you know of any similar interface for a local hive? Thanks

On Wed, Oct 19, 2011 at 5:28 PM, Edward Capriolo <edlinuxguru@gmail.com>wrote:

>
>
> On Wed, Oct 19, 2011 at 5:18 PM, Koert Kuipers <koert@tresata.com> wrote:
>
>> I have the need to do some cleanup on my hive warehouse from java, such as
>> deleting tables (both in metastore and the files on hdfs)
>>
>> I found out how to do this using remote connection:
>> org.apache.hadoop.hive.service.HiveClient connects to a hive server with
>> only a few lines of code, and it provides simple java methods such a
>> drop_table to do my tasks. Neat!
>>
>> But how do i archieve the same result if i do not want a remote connection
>> via hive server, but instead i want to use a direct connection?
>>
>> Thanks! Koert
>>
>
> You have to be careful when you do this. The reason is because the code
> below the CLI is not designed direct use. The API can change etc although
> they do not change much. That being said I do this :). The way to do it is
> you gut the CLI and make a stand alone application.
>
> You can then launch that application with 'hive --service jar /path/to/jar
> my.class.name '
>
> An example is a tool I use to generate show create table statments.
> https://issues.apache.org/jira/browse/HIVE-967
>
> Or my github project for unit testing hive work.
> https://github.com/edwardcapriolo/hive_test
>
> Again, hive was not designed to work this way.
>
>
>

Mime
View raw message