-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.php
33 lines (25 loc) · 994 Bytes
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
use Thrift\Transport\TBufferedTransport;
use Thrift\Transport\TSocket;
use Thrift\Protocol\TBinaryProtocol;
// include the phar
require_once 'build/php-impala.phar';
// grab the classmap from the phar put in globals
$GLOBALS['PHP_IMPALA_CLASSMAP'] = require_once 'phar://php-impala.phar/autoload_classmap.php';
// build a nice little autoloader using the classmap
spl_autoload_register(function ($class) {
if(array_key_exists($class, $GLOBALS['PHP_IMPALA_CLASSMAP'])) {
require $GLOBALS['PHP_IMPALA_CLASSMAP'][$class];
}
});
// now to access the impala service
$socket = new TSocket('<impala_host>', 21000); // make sure to enter your impala host ip address
$transport = new TBufferedTransport($socket);
$transport->open();
$protocol = new TBinaryProtocol($transport);
$client = new ImpalaServiceClient($protocol);
$query = new Query();
$query->query = 'SHOW TABLES';
$queryHandle = $client->query($query);
$result = $client->fetch($queryHandle,false,100);
var_dump($result);