-
Notifications
You must be signed in to change notification settings - Fork 425
refactor: make json value use json type #7248
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
Conversation
There was a problem hiding this 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 the JSON value implementation to use a dedicated JsonNativeType enum instead of being directly backed by ConcreteDataType. This makes the JSON type system more precise and reduces verbosity when operating on JSON types.
Key changes:
- Introduced new
JsonNativeTypeenum with variants for Null, Bool, Number, String, Array, and Object - Implemented bidirectional conversions between
JsonNativeTypeandConcreteDataType - Updated all JSON encoding/decoding logic to use
JsonNativeTypeinternally
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/datatypes/src/types/json_type.rs | Introduces JsonNativeType enum and refactors JsonType to use it; simplifies merge logic |
| src/datatypes/src/json/value.rs | Updates JsonVariant and JsonVariantRef to work with JsonNativeType |
| src/datatypes/src/json.rs | Refactors encoding functions to accept JsonNativeType instead of ConcreteDataType |
| src/datatypes/src/types/struct_type.rs | Adds #[expect(unused)] attribute to metadata() method |
| src/datatypes/src/data_type.rs | Updates json_native_datatype() to use new conversion |
| src/api/src/helper.rs | Adjusts conversion logic for JsonFormat::Native |
Comments suppressed due to low confidence (1)
src/datatypes/src/json/value.rs:1
- Unnecessary clone operation. The
native_type()method now returns&JsonNativeType(a reference), so calling.clone()on each array item creates unnecessary allocations. Consider refactoring to avoid cloning in the loop.
// Copyright 2023 Greptime Team
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5bf0f14 to
087dd64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: luofucong <[email protected]>
087dd64 to
641659b
Compare
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?
instead of being backed by
ConcreteDataTypedirectly, which makes json value verbose to operate its typealso the new json type is precisely corresponding to the json value, making codes lesser error-prone
PR Checklist
Please convert it to a draft if some of the following conditions are not met.