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
Existing issue Default values are ignored in AppendStruct #587 documents that AppendStruct fails when a table contains columns that are absent from the Go struct, even when those columns have server-side DEFAULT expressions.
The current workaround is to explicitly list the inserted columns in PrepareBatch, for example INSERT INTO events (id, name, timestamp), so ClickHouse can apply defaults to omitted columns.
That workaround is effective, but it duplicates the struct's ch tags in raw SQL. In wide or frequently evolving ingestion structs, the column list can drift from the struct definition.
Expected behaviour
The driver should expose a small helper that extracts the ordered ClickHouse column names represented by a struct, so callers can build explicit insert column lists from the same source of truth used by AppendStruct.
This does not need to change AppendStruct semantics or add an implicit DESCRIBE round trip. It would make the documented workaround for #587 easier to use correctly.
Observed
AppendStructfails when a table contains columns that are absent from the Go struct, even when those columns have server-sideDEFAULTexpressions.PrepareBatch, for exampleINSERT INTO events (id, name, timestamp), so ClickHouse can apply defaults to omitted columns.chtags in raw SQL. In wide or frequently evolving ingestion structs, the column list can drift from the struct definition.Expected behaviour
The driver should expose a small helper that extracts the ordered ClickHouse column names represented by a struct, so callers can build explicit insert column lists from the same source of truth used by
AppendStruct.This does not need to change
AppendStructsemantics or add an implicitDESCRIBEround trip. It would make the documented workaround for #587 easier to use correctly.Code example
With a table like this, ClickHouse can apply
sourceserver-side because the generated insert statement only namesidandname:Error log
Current open-ended insert behaviour still fails as described in #587:
Details
Environment
clickhouse-goversion: currentmainand released v2 versions withAppendStructDEFAULTcolumnsCREATE TABLEstatements for tables involved: see code example aboveRelated: #587