Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON Type #1455

Open
wants to merge 1 commit into
base: dynamic_type
Choose a base branch
from
Open

Add JSON Type #1455

wants to merge 1 commit into from

Conversation

SpencerTorres
Copy link
Member

@SpencerTorres SpencerTorres commented Dec 20, 2024

PR text is pending update

Note: There are some server-side bugs that need to be fixed/merged, including a protocol update. However, this PR can still be reviewed as-is.

Summary

Implement JSON column type. Fully resolves #1430.

Usage

The user can use JSON in 3 ways:

  1. By using the new clickhouse.JSON type to assemble JSON data by path strings.
  2. By using a struct or map. The struct can be any nested structure, but the map must be map[string]any.
  3. By using strings. In this mode the user handles their own json.(Un)Marshal and the strings get sent to the server as-is.

The JSON column also supports the clickhouse.Dynamic and clickhouse.DynamicWithType type for handling a path with multiple data types. Structs can also include a tag to specify type, such as json:"my_field" chType:"Array(String)".

See examples folder for sample code.

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

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.

1 participant