Fully implement JSON binary writing, and add the ability to write directly from POCOs#179
Merged
alex-clickhouse merged 24 commits intomainfrom Jan 22, 2026
Merged
Fully implement JSON binary writing, and add the ability to write directly from POCOs#179alex-clickhouse merged 24 commits intomainfrom
alex-clickhouse merged 24 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements comprehensive POCO serialization for ClickHouse JSON columns, enabling type-safe binary encoding when column type hints are present. The implementation adds reflection-based property mapping with caching, attribute-based path customization, and automatic type inference for unhinted fields.
Changes:
- Adds POCO serialization with binary encoding for JSON columns using type hints from column definitions
- Implements
BinaryTypeEncoderfor writing ClickHouse type headers on dynamic paths - Changes string/JsonNode inputs to use string serialization (requires
input_format_binary_read_json_as_string=1)
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| RELEASENOTES.md | Documents breaking change for string/JsonNode JSON writing and new POCO serialization feature |
| ClickHouse.Driver/Types/JsonType.cs | Core implementation: adds reflection caching, POCO field writing, type inference, and binary encoding |
| ClickHouse.Driver/Types/EnumType.cs | Exposes Values dictionary as internal for BinaryTypeEncoder access |
| ClickHouse.Driver/Types/BinaryTypeEncoder.cs | New encoder that writes ClickHouse binary type headers for dynamic JSON paths |
| ClickHouse.Driver/PublicAPI/PublicAPI.Unshipped.txt | Adds public API surface for new JSON attributes |
| ClickHouse.Driver/Json/ClickHouseJsonPathAttribute.cs | New attribute for custom JSON path mapping |
| ClickHouse.Driver/Json/ClickHouseJsonIgnoreAttribute.cs | New attribute to exclude properties from serialization |
| ClickHouse.Driver.Tests/Utilities/TestUtilities.cs | Temporarily disables JSON data type samples pending full string format support |
| ClickHouse.Driver.Tests/Types/JsonTypeTests.cs | Comprehensive test coverage for POCO serialization scenarios |
| ClickHouse.Driver.Tests/BulkCopy/BulkCopyTests.cs | Updates existing tests with required server setting for string-based JSON parsing |
mzitnik
reviewed
Jan 21, 2026
Contributor
mzitnik
left a comment
There was a problem hiding this comment.
Let's also write unhappy path tests
- wrong paths/types
- Empty values
mzitnik
approved these changes
Jan 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds POCO serialization for JSON columns with typed hints, allowing users to skip the JsonNode serialization when inserting from a POCO to a JSON column.
Implementation:
Breaking: String/JsonNode inputs now use string serialization (requires input_format_binary_read_json_as_string=1). First-class support for this will come in a different pr: #175 (There are some temporary hacks for the tests related to this).
Note
Introduces first-class JSON write support and Dynamic write capabilities.
RegisterJsonSerializationType<T>()onClickHouseConnection/IClickHouseConnection; attributesClickHouseJsonPathandClickHouseJsonIgnore; validation errors viaClickHouseJsonSerializationException; cached reflection and nested type handling viaJsonTypeRegistry.string/JsonNodeinputs are sent as JSON strings for server parsing (requiresinput_format_binary_read_json_as_string=1); hinted paths use column types; unhinted properties are inferred.DynamicType.Writewith automatic type inference and newBinaryTypeDescriptionWriterfor type headers.TypeSettingsto carry registry; exposeEnumType.Values; set default scale forDecimal128mapping.Written by Cursor Bugbot for commit b5efc2c. This will update automatically on new commits. Configure here.