feat: add struct column extraction helper#1875
Conversation
|
Summary This PR adds Must fix (none) Should fix
Nits
Verdict Needs discussion — the core helper is well-designed, tested, and documented. The de-duplication and the non-struct-embed panic guard are small, worthwhile robustness fixes for a new public API; once those are addressed (or consciously waived) this is good to merge. |
|
Thanks for the review. I pushed
Re-ran:
|
🤖 Claude reviewAdds a package-level Why it's sound:
Test coverage is strong: dedup, anonymous-non-struct no-panic, cache-copy isolation, error inputs, tag options, plus a real native round-trip in the example test. Blind spots: could not run the live example round-trip (no ClickHouse server here) to confirm server-side Verdict: ✅ Approve General findings
Inline comments are attached to the relevant lines. This summary updates in place on re-review. |
Summary
clickhouse.StructColumnsto extract deterministic insert column lists from structs using the same mapping rules asAppendStruct/ScanStructchtag options in struct mapping by using the name before the first commaAppendStructwhen tables contain server-sideDEFAULTcolumnsStructColumnsso omitted columns can use theirDEFAULTvaluesStructColumnsby de-duplicating returned column names and ignoring anonymous non-struct embeds without panickingFixes #1874
Related to #587
Testing
go test -race -count=1 -v . -run 'TestStructColumns|TestStructIdx|TestMapper'make up && go test -race -count=1 -v ./tests -run TestAppendStruct && go test -race -count=1 -v ./examples/clickhouse_api -run TestStructColumns && make downgo test -count=1 ./...was also run earlier; it failed in existing JSON integration tests againstclickhouse/clickhouse-server:latest(26.5.1) with timestamp parsing errors inTestJSONString, unrelated to this change.