Skip to content

Conversation

@iStefo
Copy link

@iStefo iStefo commented Jan 23, 2026

I have implemented basic support for decoding dynamic JSON in RowBinary.

The implementation essentially skips over all the type information encoded in the type header and then passes the remaining payload to the regular JSON decoding.

The current limitations of this approach are:

  • JSON's typed_paths encode the type headers of contained types. To strip the correct number of bytes, a more sophisticated approach would be necessary. I currently have skip_type/1 throw if it encounters a multi-byte type header.
  • The query must be run with output_format_binary_write_json_as_string = 1. If JSON is not stringified by ClickHouse, we pass incomprehensible data to Jason.decode. Unfortunately, I don't see a way of asserting correct use in code (matching on { as opening brace doesn't work since all types of JSON values can be returned)
  • We don't make use of the encoded type_paths, which means that encoded Dates etc. aren't converted to the more ergonomic Elixir types. However, this is probably not a feature people expect from JSON anyways.

Please let me know what you think.

@ruslandoga
Copy link
Collaborator

ruslandoga commented Jan 23, 2026

👋 @iStefo

Thank you for the contribution! I'll be able to take a closer look over the weekend. But it looks good!

Please feel free to ignore the CI failures / typos / etc. :) I can handle it after the PR is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants