apla / node-clickhouse

Yandex ClickHouse driver for nodejs
MIT License
216 stars 50 forks source link

Error: Cannot read from istream at offset 0 #62

Closed vladimirteddy closed 4 years ago

vladimirteddy commented 4 years ago

I query with format INSERT INTO MY_TABLE with option JSONEachRow, my data have one billion records, I splice and write up 1000 each time, and write from record 79k I have a bug Error: Cannot read from istream at offset 0. My query "INSERT INTO " + table + " FORMAT JSONEachRow " + data.

logs Log error on the server.

Please help my issue, thank.

nezed commented 4 years ago

@banbedangki Please provide more detailed example illustrating the way you are working with data

vladimirteddy commented 4 years ago

@banbedangki Please provide more detailed example illustrating the way you are working with data

I use ch.query("INSERT INTO " + table + " FORMAT JSONEachRow " + data). My data is JSON arrays and my option: options = { host: 'localhost', port: 8124, user: 'phanbinh', password: 'my_pass', readonly: false, queryOptions: { profile: "default", database: "Abc", insert_sample_with_metadata: 0 } }

vladimirteddy commented 4 years ago

I POST with format ch.query("INSERT INTO " + table + " FORMAT JSONEachRow " + data) If I cancel command run code on terminal then data will be created. Can tell me why? I think my bugs from here. When I POST one billion records, I split and POST ten thousand at a time but every POST 10k records, data not created on ClickHouse, if I cancel run code on the terminal then data will be created.

vladimirteddy commented 4 years ago

let stream = ch.query("INSERT INTO " + table + " FORMAT JSONEachRow " + data). I'm log stream: screenshot_1 What is '\n' in my query? screenshot_2 Logs error.

vladimirteddy commented 4 years ago

I'm fixed, thank for your interest.

nezed commented 4 years ago

@vladimirteddy It's a good news!

For now i can only suggest that the problem was caused by malformed query. Also this driver is using http interface and always automatically adding "\n" after query to separate it from data, but it should not be a problem if you are using this driver as described in docs.

This means that you must choose one of following options:

nezed commented 4 years ago

See also https://clickhouse.tech/docs/en/sql-reference/statements/insert-into/