Skip to content

Conversation

@MichaelScofield
Copy link
Collaborator

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

Make json value represented as struct JsonValue, instead of Value. New json value has its fields sorted, which is more convenient for further use. And lesser verbose codes when dealing with different json variants.

related proto change: GreptimeTeam/greptime-proto#289

PR Checklist

Please convert it to a draft if some of the following conditions are not met.

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.
  • API changes are backward compatible.
  • Schema or data changes are backward compatible.

@MichaelScofield MichaelScofield requested a review from a team as a code owner November 11, 2025 13:08
@github-actions github-actions bot added size/XL docs-not-required This change does not impact docs. labels Nov 11, 2025
Copilot finished reviewing on behalf of MichaelScofield November 11, 2025 13:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors JSON value representation by introducing a dedicated JsonValue struct instead of using the generic Value type. The new implementation uses BTreeMap for JSON objects to maintain sorted field ordering, simplifying code when working with different JSON variants.

  • Introduces new JsonValue, JsonValueRef, JsonVariant, and JsonVariantRef types with sorted field support
  • Updates JSON encoding/decoding logic to use the new types throughout the codebase
  • Enforces homogeneous type requirements for JSON array items (all items must have the same type)

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/datatypes/src/json/value.rs New file defining JsonValue and related types with sorted JSON object fields using BTreeMap
src/datatypes/src/value.rs Updated Value enum to use Box<JsonValue> instead of Box<Value> for JSON variant
src/datatypes/src/json.rs Refactored JSON encoding/decoding to use JsonValue types and enforce array type homogeneity
src/datatypes/src/types/json_type.rs Added helper methods and extracted plain_json_struct_type function
src/datatypes/src/vectors/json/builder.rs Updated JSON vector builder to work with new JsonValueRef type
src/api/src/helper.rs Added encode_json_value and decode_json_value functions for protobuf conversion
src/frontend/src/limiter.rs Updated size calculation logic for new JSON value structure
src/partition/src/collider.rs Added clippy allow annotation for mutable key type usage
Cargo.toml / Cargo.lock Updated greptime-proto dependency to support new JSON value representation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@sunng87 sunng87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to double-check with this JsonValue, are we still using Arrow's Struct for json object internally? Because we need that for flattening nested data in parquet, which is of critical importance to ensure a columnar format for json

@MichaelScofield
Copy link
Collaborator Author

Just want to double-check with this JsonValue, are we still using Arrow's Struct for json object internally? Because we need that for flattening nested data in parquet, which is of critical importance to ensure a columnar format for json

@sunng87 Physically the JsonValue is still stored as Arrow Struct, see https://github.com/GreptimeTeam/greptimedb/pull/7214/files#diff-fe8d389bf14fcacc04453c6b51e9ee8d21af580ba700fe944914c252047b43f8R44 and https://github.com/GreptimeTeam/greptimedb/pull/7214/files#diff-02bc4a0d88d5e644788241668f9d295cd9be7a9c37c179bf45a136a93932eee5R611

@MichaelScofield MichaelScofield force-pushed the refactor/value-json-for-json-value branch from 5fbd23c to 737e069 Compare November 12, 2025 04:05
@MichaelScofield
Copy link
Collaborator Author

@sunng87 @copilot PTAL

Copy link
Contributor

Copilot AI commented Nov 12, 2025

@MichaelScofield I've opened a new pull request, #7217, to work on those changes. Once the pull request is ready, I'll request review from you.

@MichaelScofield
Copy link
Collaborator Author

@copilot review

Copy link
Contributor

Copilot AI commented Nov 12, 2025

@MichaelScofield I've opened a new pull request, #7218, to work on those changes. Once the pull request is ready, I'll request review from you.

Signed-off-by: luofucong <[email protected]>
@MichaelScofield MichaelScofield force-pushed the refactor/value-json-for-json-value branch from 3ce00ee to 6305b29 Compare November 12, 2025 05:15
Signed-off-by: luofucong <[email protected]>
@MichaelScofield MichaelScofield added this pull request to the merge queue Nov 17, 2025
Merged via the queue into main with commit cdf9d18 Nov 17, 2025
43 checks passed
@MichaelScofield MichaelScofield deleted the refactor/value-json-for-json-value branch November 17, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required This change does not impact docs. size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants