Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Data support fails #29

Open
kapopken opened this issue Aug 8, 2023 · 0 comments
Open

JSON Data support fails #29

kapopken opened this issue Aug 8, 2023 · 0 comments

Comments

@kapopken
Copy link

kapopken commented Aug 8, 2023

I am trying to use the client to post to a json table
CREATE table sensor_raw
(
source LowCardinality(String) DEFAULT JSONExtractString(message_raw, 'source'),
uid LowCardinality(String) DEFAULT JSONExtractString(message_raw, 'uid'),
timeStamp DateTime64 DEFAULT fromUnixTimestamp(JSONExtractInt(message_raw, 'timeStamp')),
tid LowCardinality(String) DEFAULT JSONExtractString(message_raw, 'tid'),
traceId LowCardinality(String) DEFAULT JSONExtractString(message_raw, 'traceId'),
dataProvider LowCardinality(String) DEFAULT JSONExtractString(JSONExtractString(message_raw,'payload'), ('dataProvider')),
integrationId LowCardinality(String) DEFAULT JSONExtractString(JSONExtractString(message_raw,'payload'),('integrationId')),
templateId LowCardinality(String) DEFAULT JSONExtractString(JSONExtractString(message_raw,'payload'),('templateId')),
executionId LowCardinality(String) DEFAULT JSONExtractString(JSONExtractString(message_raw,'payload'), ('executionId')),
message JSON DEFAULT message_raw,
message_raw String EPHEMERAL
) ENGINE = MergeTree ORDER BY (source, uid);

inserting like this works
insert into sensor_raw(message_raw) FORMAT JSONAsString {"source": "test", "uid": "test"}

but when using the sdk
await this.clickhouseRepo.insertPromise('sensor_raw', [{message_raw: jsonData});

It fails with error
Code: 117. DB::Exception: JSON object must begin with '{'.: (at row 1)

i can copy the log and do a directly insert and it works fine.

"@depyronick/nestjs-clickhouse": "^2.0.2",
"@nestjs/core": "10.1.3",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant