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

Fix insertion of empty map into JSON column by using _dummy subcolumn #1116

Merged
merged 2 commits into from
Oct 11, 2023

Conversation

leodido
Copy link
Contributor

@leodido leodido commented Oct 11, 2023

Summary

Fixes #1113 (in the issue the code to reproduce it)

This PR correctly handles the inputting of an empty map,
by creating an empty tuple to ensure the subcolumns protocol is happy.

The _dummy key is a ClickHouse internal name for an empty tuple subcolumn. In fact, it is the same key it gets used when inputting {}.

With this PR,
inputting map[string]any{} from Go has the same effect as INSERT INTO single_json_type_table VALUES ('{}');.

In @jkaflik's PR #1115 there are other evaluated fixes/solutions.

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

@CLAassistant
Copy link

CLAassistant commented Oct 11, 2023

CLA assistant check
All committers have signed the CLA.

@jkaflik
Copy link
Contributor

jkaflik commented Oct 11, 2023

Nice! Thanks @leodido

@jkaflik jkaflik merged commit 478c1cd into ClickHouse:main Oct 11, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mismatched len of columns when inserting empty map into JSON column
3 participants