File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change 3
3
// Load this lib
4
4
require_once __DIR__ . '/ThriftSQL.phar ' ;
5
5
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 ' );
8
8
$ hiveTables = $ hive
9
- ->setSasl ( false ) // To turn SASL auth off, on by default
10
9
->connect ()
11
- ->queryAndFetchAll ( 'SHOW TABLES ' );
12
- print_r ( $ hiveTables );
10
+ ->getIterator ( 'SHOW TABLES ' );
13
11
14
- // Try out an Impala query
12
+ // Try out an Impala query via iterator object
15
13
$ impala = new \ThriftSQL \Impala ( 'impala.host.local ' );
16
14
$ impalaTables = $ impala
17
15
->connect ()
18
- ->queryAndFetchAll ( 'SHOW TABLES ' );
19
- print_r ( $ impalaTables );
16
+ ->getIterator ( 'SHOW TABLES ' );
20
17
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
22
29
$ hive ->disconnect ();
23
30
$ impala ->disconnect ();
You can’t perform that action at this time.
0 commit comments