node-clickhouse
node-clickhouse copied to clipboard
handle the data failed when use `with totals` in query
hi
It failed when using with totals in query
version v1.6.2
sql
select sum(1) from tables group by name with totals
query options
{
dataObjects: true,
syncParser: true
}
output
Unknown error field: SyntaxError: Unexpected token C in JSON at position 2478
[2020-04-13 09:48:58.949 +0800] ERROR (6707 on psnails-MacBook-Pro.local):
err: {
"type": "Error",
"message": "SyntaxError: Unexpected token C in JSON at position 2478",
"stack":
Error: SyntaxError: Unexpected token C in JSON at position 2478
at parseError (/Users/psnail/Documents/thunder/projects/abacus/abacus-merchant-desktop/node_modules/@apla/clickhouse/src/parse-error.js:2:15)
at errorHandler (/Users/psnail/Documents/thunder/projects/abacus/abacus-merchant-desktop/node_modules/@apla/clickhouse/src/clickhouse.js:29:13)
at IncomingMessage.<anonymous> (/Users/psnail/Documents/thunder/projects/abacus/abacus-merchant-desktop/node_modules/@apla/clickhouse/src/clickhouse.js:160:12)
at IncomingMessage.emit (events.js:323:22)
at endReadableNT (_stream_readable.js:1204:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
}
is it a bug or is there any option to handle it?
thanks
Hi! I've tried to reproduce your case
var ClickHouse = require('@apla/clickhouse');
var ch = new ClickHouse({host: '127.0.0.1', port: 8123});
ch.query(
'SELECT sum(number), number % 2 AS isEven FROM (SELECT * FROM system.numbers LIMIT 10) GROUP BY isEven WITH TOTALS',
{
dataObjects: true,
syncParser: true
},
console.log,
)
and it works fine.
It may be an unexpected proxy response or some edge case with your data. It would be great if you can check raw response or even paste it here
curl -v http://localhost:8123/ --data-urlencode 'query=YOUR SELECT QUERY HERE'