You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Asking here instead of Bug Fixes, because my attempt to isolate the code failed to reproduce the problem.
Using go version 1.24.1 and clickhouse-go v2.34.0, I'm running into a problem inserting rows to CH (24.8.5.1) when an Array(JSON) column is an empty slice.
Given a column:
`events` Array(JSON)
And a type:
type Event struct {
... some JSON annotated fields ...
}
I can insert rows (using PrepareBatch and Append), using type []Event, that are interpreted correctly as long as one or more Events are populated.
But if the slice is empty, I get code: 117, message: Invalid version for Object structure serialization.
I've tried working around it by returning prerendered JSON (when the source data is empty), by creating a custom "database/sql" serializer, and a couple of other investigative steps. If I emit the string or raw [], it will appear in CH as ['{}', '{}'] seemingly creating an empty element at each character index, because if I tried to emit []::JSON I got eight such empties.
Finally, I tried creating a separate go project to isolate this call and simply emit rows in the expected format (using type []Event) and these get inserted properly to CH whether empty or not.
The only difference I can see is that my test project defines Event in main.go while my failing implementation defines them in a clickhouseexporter module.
I'm relatively new to go, but I'd appreciate any thoughts on what I should check for next.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Asking here instead of Bug Fixes, because my attempt to isolate the code failed to reproduce the problem.
Using go version 1.24.1 and clickhouse-go v2.34.0, I'm running into a problem inserting rows to CH (24.8.5.1) when an Array(JSON) column is an empty slice.
Given a column:
And a type:
I can insert rows (using PrepareBatch and Append), using type
[]Event
, that are interpreted correctly as long as one or more Events are populated.But if the slice is empty, I get
code: 117, message: Invalid version for Object structure serialization.
I've tried working around it by returning prerendered JSON (when the source data is empty), by creating a custom "database/sql" serializer, and a couple of other investigative steps. If I emit the string or raw
[]
, it will appear in CH as['{}', '{}']
seemingly creating an empty element at each character index, because if I tried to emit[]::JSON
I got eight such empties.Finally, I tried creating a separate go project to isolate this call and simply emit rows in the expected format (using type
[]Event
) and these get inserted properly to CH whether empty or not.The only difference I can see is that my test project defines Event in main.go while my failing implementation defines them in a clickhouseexporter module.
I'm relatively new to go, but I'd appreciate any thoughts on what I should check for next.
Beta Was this translation helpful? Give feedback.
All reactions