Giter Site home page Giter Site logo

Comments (4)

vineetma avatar vineetma commented on June 15, 2024 1

There are visible two issues in above code:
connection.connect() --> it is a promise, which needs to be written differently.
connection.connect.then( (cursor) => { /*your cursor related code goes here.. */ });

Similarly, in your cursor code, you would get results. i.e.
cursor.execute("sql query..").then( (results) => { /* data handling code goes here..*/ })

It need not have resolve and reject, inside then callback.

from jshs2.

MarineRu avatar MarineRu commented on June 15, 2024

I'm writing the same code and I have the same problem.
How to fix it ?

from jshs2.

mauryaavinash95 avatar mauryaavinash95 commented on June 15, 2024

I am getting the same error. Is there a workaround for this?
Is there something I am doing wrong?

--------------------CODE----------------------

const jshs2 = require('jshs2');
const HS2Util = jshs2.HS2Util;
const IDLContainer = jshs2.IDLContainer;
const HiveConnection = jshs2.HiveConnection;
const Configuration = jshs2.Configuration;

console.log("In server.js");
const options1 = {
        // Connection configuration 
        auth: 'NOSASL',
        host: '127.0.0.1',           // HiveServer2 hostname 
        port: '10000',                     // HiveServer2 port 
        timeout: 10000,                    // Connection timeout 
        username: 'admin',           // HiveServer2 user 
        password: 'admin',                      // HiveServer2 password 
        hiveType: HS2Util.HIVE_TYPE.HIVE,  // HiveServer2 type, (Hive or CDH Hive) 
        hiveVer: '1.1.0',                  // HiveServer2 Version 
        thriftVer: '0.9.2',                // Thrift version at IDL Compile time 
        maxRows: 5120,
        nullStr: 'NULL',
        i64ToString: true,
};
const configure = new Configuration(options1);
const idl = new IDLContainer();
idl.initialize(configure).then(() => {
	connection = new HiveConnection(configure, idl);
        cursor = connection.connect();
	serviceType = idl.ServiceType;
	console.log("Cursor getting initialised", cursor);
	cursor.execute("select * from test.test_table;").then((resolve)=>{
		console.log("Resolved");
	}, (reject)=>{
		console.log("Rejected");
	});
        console.log("In the end");
});

----------------------------OUTPUT---------------------------------
In server.js Cursor getting initialised Promise { <pending> } (node:31149) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: cursor.execute is not a function (node:31149) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

from jshs2.

mauryaavinash95 avatar mauryaavinash95 commented on June 15, 2024

Thanks a lot @vineetma . Checked my Thrift hive logs and this code is hitting request, but somehow it is failing as

17/11/25 16:51:31 ERROR TThreadPoolServer: Error occurred during processing of message.
java.lang.RuntimeException: org.apache.thrift.transport.TTransportException: Invalid status -128
	at org.apache.thrift.transport.TSaslServerTransport$Factory.getTransport(TSaslServerTransport.java:219)
	at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:269)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.thrift.transport.TTransportException: Invalid status -128
	at org.apache.thrift.transport.TSaslTransport.sendAndThrowMessage(TSaslTransport.java:232)
	at org.apache.thrift.transport.TSaslTransport.receiveSaslMessage(TSaslTransport.java:184)
	at org.apache.thrift.transport.TSaslServerTransport.handleSaslStartMessage(TSaslServerTransport.java:125)
	at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:271)
	at org.apache.thrift.transport.TSaslServerTransport.open(TSaslServerTransport.java:41)
	at org.apache.thrift.transport.TSaslServerTransport$Factory.getTransport(TSaslServerTransport.java:216)
	... 4 more

For now, I am using this post to get it done:
https://dzone.com/articles/connect-apache-spark-sql-to-nodejs-on-linux-via-jd

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.