hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy <jk...@kickbackpoints.com>
Subject Re: How do I get the php client to run?
Date Thu, 27 Mar 2014 18:44:52 GMT
Or how do query hive from php?

On 03/27/2014 12:25 PM, Jeremy wrote:
> Or is there another way I can pull data from hive using php?
> 
> On 03/27/2014 11:54 AM, Jeremy wrote:
>> https://cwiki.apache.org/confluence/display/Hive/HiveClient#HiveClient-PHP
>>
>> What kind of setup and what do I need to do to get this client to run?
>>
>>
>> <?php
>> // set THRIFT_ROOT to php directory of the hive distribution
>> $GLOBALS['THRIFT_ROOT'] = '/lib/php/';
>> // load the required files for connecting to Hive
>> require_once $GLOBALS['THRIFT_ROOT'] .
>> 'packages/hive_service/ThriftHive.php';
>> require_once $GLOBALS['THRIFT_ROOT'] . 'transport/TSocket.php';
>> require_once $GLOBALS['THRIFT_ROOT'] . 'protocol/TBinaryProtocol.php';
>> // Set up the transport/protocol/client
>> $transport = new TSocket('localhost', 10000);
>> $protocol = new TBinaryProtocol($transport);
>> $client = new ThriftHiveClient($protocol);
>> $transport->open();
>>
>> // run queries, metadata calls etc
>> $client->execute('SELECT * from src');
>> var_dump($client->fetchAll());
>> $transport->close();
>>
>> Thanks
>>

Mime
View raw message