Giter Site home page Giter Site logo

Comments (9)

imjuni avatar imjuni commented on June 15, 2024

jshs2 is hive server2 client library, for querying. That is not suitable server management.

from jshs2.

jcollum avatar jcollum commented on June 15, 2024

I might be missing it in the docs. Is there a sample of using this to do something like SELECT * from tableName? I can't find it in the docs or the tests.

from jshs2.

imjuni avatar imjuni commented on June 15, 2024

in my testcase PromiseTest.js (similar in README.md),

var options = {};

options.auth = config[config.use].auth;
options.host = config[config.use].host;
options.port = config[config.use].port;
options.timeout = config[config.use].timeout;
options.username = config[config.use].username;
options.hiveType = config[config.use].hiveType;
options.hiveVer = config[config.use].hiveVer;
options.cdhVer = config[config.use].cdhVer;
options.thriftVer = config[config.use].thriftVer;

options.maxRows = config[config.use].maxRows;
options.nullStr = config[config.use].nullStr;
options.i64ToString = config[config.use].i64ToString;

testConf.config = config;
testConf.jshs2 = options;

set your environment,

configuration = new Configuration(testConf.jshs2);

yield configuration.initialize();

initialize jshs2 object,

connection = new Connection(configuration);
cursor = yield connection.connect();

create connection,

serviceType = cursor.getConfigure().getServiceType();
execResult = yield cursor.execute(testConf.config.Query.query);
for (i = 0, len = 1000; i < len; i++) {
status = yield cursor.getOperationStatus();
log = yield cursor.getLog();

debug('wait, status -> ', hs2util.getState(serviceType, status));
debug('wait, log -> ', log);

if (hs2util.isFinish(cursor, status)) {
  debug('Status -> ', status, ' -> stop waiting');

  break;
}

yield hs2util.pSleep(10000);
}

execute and check operation status.

if (execResult.hasResultSet) {
  schema = yield cursor.getSchema();

  debug('schema -> ', schema);

  fetchResult = yield cursor.fetchBlock();

  debug('first row ->', JSON.stringify(fetchResult.rows[0]));
  debug('rows ->', fetchResult.rows.length);
  debug('rows ->', fetchResult.hasMoreRows);
}

fetch data

return {
  hasResultSet: execResult.hasResultSet,
  rows: (execResult.hasResultSet) ? fetchResult.rows : []
};

return data for callee

Everything in my testcase PromiseTest.js. If you use old node.js version, use callback version.

from jshs2.

jcollum avatar jcollum commented on June 15, 2024

In your Example code, where is cursor defined?

const execResult = yield cursor.execute(config.Query.query);

from jshs2.

imjuni avatar imjuni commented on June 15, 2024

Plz, see my answer,

connection = new Connection(configuration);
cursor = yield connection.connect();

That is cursor.

from jshs2.

jcollum avatar jcollum commented on June 15, 2024

The example is confusing because the cursor is never initialized, where is the let/var/const? I can figure that out of course.

It's also odd that a connect function would return a cursor -- I think of a cursor as a set of results you can iterate through (paging etc), not a connection.

The library would be more readable if it was more like:

connection = new Connection(configuration);
cursor = yield connection.query(query);

// iterate first set of results in cursor 
// or use a while hasResults loop 

from jshs2.

jcollum avatar jcollum commented on June 15, 2024

In your Example in the README on this line:

const execResult = yield cursor.execute(config.Query.query);

This will always fail because cursor is null. The example seems to be missing something.

from jshs2.

wuwanyu avatar wuwanyu commented on June 15, 2024

Very Agree ! Maybe you can make a littler example,this doc is difficult for those who are not familiar with Promise

from jshs2.

jcollum avatar jcollum commented on June 15, 2024

@wuwanyu we've decided that webhcat will work better for our needs, we just need to set up a server to listen for web callbacks

from jshs2.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.