Permalink
Browse files

fetch in batch returns ResultSet

  • Loading branch information...
Jae committed Jul 12, 2011
1 parent 1451b0c commit 8c5b8fc85ff687cab434dd3b7ca1046ebbb0ecc3
Showing with 15 additions and 12 deletions.
  1. +1 −1 examples/test.js
  2. +14 −11 node-hive.js
View
@@ -9,7 +9,7 @@ hive.fetch("SELECT * FROM weather_data where dated = '2011-07-01' limit 10", fun
var i = 1;
hive.fetchInBatch(100, "SELECT * FROM weather_data where dated = '2011-07-02' limit 1002", function(err, data) {
console.log("SELECT * FROM weather_data where dated = '2011-07-02'");
- console.log(i++ + "th data:", data);
+ console.log(i++ + "th data:", data.toTSV());
});
hive.execute("DESCRIBE weather_data", function(err, data) {
View
@@ -33,17 +33,20 @@ var hiveClient = function(futureConnection) {
futureConnection(function(client, connection) {
client.execute(query, function(err){
if (err) return cb(true, err);
- var fetchBatch = function() {
- client.fetchN(batchSize, function(err, data){
- if (err) return cb(true, err);
- if(data.length > 0) {
- cb(null, data);
- process.nextTick(fetchBatch);
- }
- else connection.end();
- });
- };
- fetchBatch();
+ client.getSchema(function(err, schema) {
+ if (err) return cb(true, err);
+ var fetchBatch = function() {
+ client.fetchN(batchSize, function(err, data){
+ if (err) return cb(true, err);
+ if(data.length > 0) {
+ cb(null, ResultSet.create(data, schema));
+ process.nextTick(fetchBatch);
+ }
+ else connection.end();
+ });
+ };
+ fetchBatch();
+ });
});
})
},

0 comments on commit 8c5b8fc

Please sign in to comment.