-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathexample.php
32 lines (26 loc) · 920 Bytes
/
example.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
<?php
// Load this lib
require_once __DIR__ . '/ThriftSQL.phar';
// Try out a Hive query via iterator object
$hive = new \ThriftSQL\Hive( 'hive.host.local', 10000, 'user', 'pass' );
$hiveTables = $hive
->connect()
->getIterator( 'SHOW TABLES' );
// Try out an Impala query via iterator object
$impala = new \ThriftSQL\Impala( 'impala.host.local' );
$impalaTables = $impala
->connect()
->setOption( 'REQUEST_POOL', 'php' )
->setOption( 'MEM_LIMIT', '256mb' )
->getIterator( 'SHOW TABLES' );
// Execute the Hive query and iterate over the result set
foreach( $hiveTables as $rowNum => $row ) {
print_r( $row );
}
// Execute the Impala query and iterate over the result set
foreach( $impalaTables as $rowNum => $row ) {
print_r( $row );
}
// Don't forget to close socket connection once you're done with it
$hive->disconnect();
$impala->disconnect();