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.
Summary
The NestedMap function converts a flat
map[string]any
into a structure usable byjson.Marshal
. The behavior has been updated to match that of ClickHouse server. A good example of this feature in use is the Grafana integration.The main change here is the exclusion of
nil
values from encoding.Comparison
Here is the outputs before/after for comparison (the sorting is inconsistent since there's no sorting key)
ClickHouse Server (expected output):
Grafana output (incorrect, nulls are included):
![json output in Grafana not matching ClickHouse server](https://private-user-images.githubusercontent.com/28887171/406631321-dade4076-54ff-4c49-b8e1-455cb38b2c04.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNTgyNTgsIm5iZiI6MTczOTA1Nzk1OCwicGF0aCI6Ii8yODg4NzE3MS80MDY2MzEzMjEtZGFkZTQwNzYtNTRmZi00YzQ5LWI4ZTEtNDU1Y2IzOGIyYzA0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDIzMzkxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQxNDk2MDk2NDNiYjBhMmMwOTIzZDJmOGU0NjExMWEyOTI3NmVmZDBkYmZjZmY4MmViN2M0NWE0ODYwYjU4NDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.70Fhjr2n0Q6Fy5lTKxVBGKfbvv2EfxcNGZzYll5nShE)
Grafana output (corrected):
![json output in Grafana matching ClickHouse server](https://private-user-images.githubusercontent.com/28887171/406631181-ace80a99-c0ab-4cca-a863-261e60086bc1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNTgyNTgsIm5iZiI6MTczOTA1Nzk1OCwicGF0aCI6Ii8yODg4NzE3MS80MDY2MzExODEtYWNlODBhOTktYzBhYi00Y2NhLWE4NjMtMjYxZTYwMDg2YmMxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDIzMzkxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQyZjFhZTFkNDcwNjI3ZGE1ZjY2NzBlODdjODM0ZWNlZTdlZjgxNDY4ZDE0YmU5ZjgyODRmNTczMjNhODU2YzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.uF494bqgrInfefCkHruSRUdagE69LH3JMPqLQzffM_w)
Checklist