You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Jeremy <jk...@kickbackpoints.com> on 2014/03/27 18:54:04 UTC

How do I get the php client to run?

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


Re: How do I get the php client to run?

Posted by Jeremy <jk...@kickbackpoints.com>.
First of all thank you so much for taking the time to reply to my question.

When I do that I get this error
PHP Parse error: syntax error, unexpected ';', expecting T_STRING or
T_NS_SEPARATOR or '{' in
/apache-hive-0.14.0-SNAPSHOT-bin/lib/php/packages/hive_service/ThriftHive.php
on line 2

and on line 2 of that file it says
namespace ;

Thanks


On 03/28/2014 04:15 AM, Chinna Rao Lalam wrote:
> Hi,
> 
>    1. Start Hiveserver
>    2. In php client code set THRIFT_ROOT to php lib of hive distribution (Ex: 
> /home/install/apache-hive-0.14.0-SNAPSHOT-bin/lib/php)
> 
> Hope It Helps,
> Chinna
> 
> 
> On Fri, Mar 28, 2014 at 12:14 AM, Jeremy <jking@kickbackpoints.com 
> <ma...@kickbackpoints.com>> wrote:
> 
>     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
>      >>
> 
> 

Re: How do I get the php client to run?

Posted by Chinna Rao Lalam <la...@gmail.com>.
Hi,

  1. Start Hiveserver
  2. In php client code set THRIFT_ROOT to php lib of hive distribution
(Ex: /home/install/apache-hive-0.14.0-SNAPSHOT-bin/lib/php)

Hope It Helps,
Chinna


On Fri, Mar 28, 2014 at 12:14 AM, Jeremy <jk...@kickbackpoints.com> wrote:

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

Re: How do I get the php client to run?

Posted by Jeremy <jk...@kickbackpoints.com>.
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
>>

Re: How do I get the php client to run?

Posted by Jeremy <jk...@kickbackpoints.com>.
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
>