Add support for JSON type options#309
Merged
ruslandoga merged 2 commits intoplausible:masterfrom Apr 20, 2026
Merged
Conversation
Parse JSON(...) options into {:json, opts} with settings,
type_hints and skips, and encode them back to "JSON(...)".
Handle {:json, opts} in Ch.Types, Ch.RowBinary (encode/decoding)
and Ch.cast. Add tests covering settings, type hints and skip
directives for RowBinary insertion.
ruslandoga
reviewed
Apr 16, 2026
| def decode("JSON" <> _options), do: :json | ||
|
|
||
| def decode("JSON" <> options) do | ||
| case String.trim(options) do |
Collaborator
There was a problem hiding this comment.
Thank you for the PR!
Since we are not using these options, maybe we can keep them as-is, as a string, with trailing ) trimmed?
Contributor
Author
There was a problem hiding this comment.
I needed to fix the line breaks and sort the type hints.
{
:error,
%Ch.Error{
__exception__: true,
code: 117,
message: "Code: 117. DB::Exception: Type of 'json' must be JSON(max_dynamic_types=254, max_dynamic_paths=10000, age UInt8, name String, SKIP `pass.body_part`, SKIP REGEXP 't.*'), not JSON(\n max_dynamic_types=254,\n max_dynamic_paths=10000,\n age UInt8, name String,\n SKIP `pass.body_part`,\n SKIP REGEXP 't.*'\n)\n: (while reading header): While executing WaitForAsyncInsert. (INCORRECT_DATA) (version 26.3.3.20 (official build))\n"
}
}Simplify parsing of JSON(...) options by trimming and splitting in a
single pipeline, removing the earlier case branch while keeping the
{:json, ...} result shape.
Add unit tests covering JSON decoding, the json helper and encode
roundtrip for various option combinations.
Collaborator
|
Thank you! |
ruslandoga
approved these changes
Apr 20, 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.
Parse JSON(...) options into {:json, opts} with settings, type_hints and skips, and encode them back to "JSON(...)". Handle {:json, opts} in Ch.Types, Ch.RowBinary (encode/decoding) and Ch.cast. Add tests covering settings, type hints and skip directives for RowBinary insertion.
#308