Closed zimv closed 3 years ago
Hi, Could you please share create table schema?
clickhouse version 21.3.2.5
CREATE TABLE test.events
(
`event` String,
`create_time` DateTime,
`app_id` String,
)
ENGINE = MergeTree
PARTITION BY toYYYYMM(create_time)
ORDER BY create_time
const client = new ClickHouse({
url: 'http://localhost',
port: 8123,
basicAuth: null,
debug: true,
isUseGzip: false,
format: 'json', // "json" || "csv" || "tsv"
});
client.insert(`INSERT INTO test.events (event, create_time, app_id)`, [{event:'test', create_time: 1616574054093 ,app_id:''}])
You could try once.
console info:
QueryCursor {
query: 'INSERT INTO test.events (event, create_time, app_id,)',
data: [
{
event: '123',
create_time: 1616568277902,
app_id: 'test',
},
{
event: '123',
create_time: 1616568277902,
app_id: '',
}
],
opts: { format: 'json' }
}
QueryCursor._getReqParams: params INSERT INTO test.events (create_time, event, app_id) {
headers: { 'Content-Type': 'text/plain' },
body: '123\t1616568277902\ttest\n123\t1616568277902\t',
url: 'http://localhost:8123/?user=default&session_timeout=60&output_format_json_quote_64bit_integers=0&enable_http_compression=0&query_id=a2e1c1a5-bd50-44ce-9289-9316e8a349c2&database=default&query=INSERT+INTO+test.events+%28app_id%2Ccreate_time%2Cevent%2Ccontent%29+FORMAT+TabSeparated'
}
nodejs.Error: 500: Code: 33, e.displayText() = DB::ParsingException: Unexpected end of stream, while parsing value of Nullable type: Buffer has gone, cannot extract information about what has been parsed.: (at row 2)
I have a interim code inside:
exec(cb) {
const me = this;
const reqParams = me._getReqParams();
reqParams.body += '\n'; // <========+1
me._request = request.post(reqParams, (err, res) => {
if (me.isDebug) {
console.log('QueryCursor.exec: result', me.query, err, _.pick(res, [
'statusCode',
'body',
'statusMessage',
'headers'
]));
}
...
}
Try to use version 2.2.4 of lib. With clickhouse 21.3.5.42 the lib works without error
Sure!
Now, I have three column. My request data is
[{c1:1,c2:2,c3:3},{c1:4,c2:5,c3:''}]
. After transformation, I see the http request body is1\t2\t3\n4\t5\t
.Then the db response message is:If my request data is
[{c1:1,c2:2,c3:''},{c1:4,c2:5,c3:6}]
.The request body is1\t2\t\n4\t5\t6
, It's ok. If my request data is[{c1:1,c2:2,c3:3},{c1:4,c2:5,c3:''}]
.The request body is1\t2\t3\n4\t5\t\n
, It's ok.So the body should not empty in last. You could Insert '\n' at the end of the body.