Skip to content

Commit e01d929

Browse files
committed
Update example script
1 parent e425904 commit e01d929

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

example.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,28 @@
33
// Load this lib
44
require_once __DIR__ . '/ThriftSQL.phar';
55

6-
// Try out a Hive query
7-
$hive = new \ThriftSQL\Hive( 'hive.host.local' );
6+
// Try out a Hive query via iterator object
7+
$hive = new \ThriftSQL\Hive( 'hive.host.local', 10000, 'user', 'pass' );
88
$hiveTables = $hive
9-
->setSasl( false ) // To turn SASL auth off, on by default
109
->connect()
11-
->queryAndFetchAll( 'SHOW TABLES' );
12-
print_r( $hiveTables );
10+
->getIterator( 'SHOW TABLES' );
1311

14-
// Try out an Impala query
12+
// Try out an Impala query via iterator object
1513
$impala = new \ThriftSQL\Impala( 'impala.host.local' );
1614
$impalaTables = $impala
1715
->connect()
18-
->queryAndFetchAll( 'SHOW TABLES' );
19-
print_r( $impalaTables );
16+
->getIterator( 'SHOW TABLES' );
2017

21-
// Don't forget to clear the client and close socket.
18+
// Execute the Hive query and iterate over the result set
19+
foreach( $hiveTables as $rowNum => $row ) {
20+
print_r( $row );
21+
}
22+
23+
// Execute the Impala query and iterate over the result set
24+
foreach( $impalaTables as $rowNum => $row ) {
25+
print_r( $row );
26+
}
27+
28+
// Don't forget to close socket connection once you're done with it
2229
$hive->disconnect();
2330
$impala->disconnect();

0 commit comments

Comments
 (0)