node-clickhouse icon indicating copy to clipboard operation
node-clickhouse copied to clipboard

Termination with comments in query and .query method

Open ks-s-a opened this issue 5 years ago • 1 comments

Run such snippet:

const ClickHouse = require('@apla/clickhouse');

const c = new ClickHouse({
  host,
  port,
  auth
});

const q = 'select count() from table
-- ololololoolololololoolololololol
'
const stream = c.query(q);

stream.on('metadata', function (metadata) {
  console.log('metadata', metadata);
});

stream.on('data', function (data) {
  console.log('data!', data);
});

stream.on('error', err => {
  console.log('error', err);
});

stream.on('end', () => {
  console.log('end');
});

stream.on('end', () => {
  console.log('end');
});

And receive nothing. Stream was closed and the script terminated. There were no fired events. However, if I remove comments from the query it will work properly.

I looked at tcpdump and saw that the request was sent to the server. After sending we got 'close' event from http.response inside the client's code then 'response' event and 'close' again.

Tried to send the request with http://ui.tabix.io/ - everything is fine. And it is the reason why I texted here. It looks like client bug, which not related to server settings.

ks-s-a avatar Feb 11 '20 17:02 ks-s-a

Ok. Swiched clickhouse server to debug mode and got:

2020.02.13 11:53:32.442129 <Debug> executeQuery: (from ${IP}:46934, user: username) select count() from default.events -- FORMAT JSONCompact

Looks like client adds FORMAT statement to the end of the query and it becomes part of comment. Is it expected behavior?

ks-s-a avatar Feb 13 '20 11:02 ks-s-a