ufukomer / node-impala

Node Client for Impala using Apache Thrift
https://www.npmjs.com/package/node-impala
MIT License
31 stars 12 forks source link

TApplicationException: Invalid method name #5

Closed karladler closed 8 years ago

karladler commented 8 years ago

Using the example there: from https://www.npmjs.com/package/node-impala I got the following error:

{ TApplicationException: Invalid method name: 'query'
    at BeeswaxServiceClient.recv_query ([...]/node_modules/node-impala/lib/thrift/BeeswaxService.js:1527:13)
    at [...]/node_modules/thrift/lib/nodejs/lib/thrift/connection.js:157:41
    at Socket.<anonymous> [...]/node_modules/thrift/lib/nodejs/lib/thrift/buffered_transport.js:48:5)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:172:18)
    at Socket.Readable.push (_stream_readable.js:130:10)
    at TCP.onread (net.js:542:20)
  name: 'TApplicationException',
  message: 'Invalid method name: \'query\'',
  type: 1 }

The connection to the server seems to be established, but I can not execute the query.

ufukomer commented 8 years ago

@abimelex Could you try to create connection with callback and catch errors for being sure if the connection is started or not?

const config = { /* Your config here... */ }

client.connect(config)
    .then((res) => console.log('Success', res))
    .catch((err) => console.error(err));
karladler commented 8 years ago

Already did this. Returns 'Connection is established.'

client.connect({
            host: 'REDACTED',
            port: 21050,
            resultType: 'json-array'})
            .then((message) => {
                console.log(message);
            })
            .catch(error => console.error(error));

const query = `SELECT item_id FROM table.name`

client.query(query)
            .then(result => console.log(result))
            .catch(err => console.error(err))
            .done(() => client.close().catch(err => console.error(err)));
ufukomer commented 8 years ago

@abimelex the port should be 21000 in default, there is also connection on 21050 in cloudera. Maybe it creates a connection but cannot create client object because of wrong port number. If you know what to do and changed your impala thrift port as 21050 it should work in this way. It returns 'Connection is established' when connect event is triggered in here. Maybe the connect event is not working correctly, I don't trust that thrift module. Could you write a test under your node_modules to understand the problem (example). You can do this either cloning this repo or creating test folder under your node_modules/node_impala/.. directory.

Real world example (works perfectly): https://github.com/ufukomer/bloomery/blob/master/src/server.js#L47-L49

ufukomer commented 8 years ago

Yea it is about port! I got the same error when I change my port as 21050:

So I shouldn't send a success message when the wrong connections is established, and you should also change your port as 21000.

karladler commented 8 years ago

Seems legit! I changed the port and it worked. But I guess this is using Hive now, which is a lot slower. Is it somehow possible to use Impala?

ufukomer commented 8 years ago

No, it is using impala but data is stored inside the hive warehouse so that is why we use Beeswax. Btw it is not possible to use Hive with this module. Because hive uses hiveserver2 and it requires authentication, so it's not possible right now. If you try to switch off Hive and run your query it would still work (for proof).

Don't forget that Beeswax limits the results (max: 1000).

karladler commented 8 years ago

Cool, thanks for the short introduction, I must admit that I havn't any glue of Hadoop etc. I'm just the guy using it's API ;) So I guess this issue can be close. Thanks again!