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

refactor: support distinct JSON format and improve type conversions #4979

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

WenyXu
Copy link
Member

@WenyXu WenyXu commented Nov 12, 2024

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?

support distinct JSON format and improve type conversions

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced enhanced handling for JSON data types, including new methods for converting and parsing JSON values.
    • Added a method to ConcreteDataType for casting to JsonType.
  • Bug Fixes

    • Improved error handling during JSON type conversions and parsing, providing clearer error messages.
  • Improvements

    • Enhanced compatibility between JSON and binary types in data validation.
    • Streamlined JSON data handling in MySQL and PostgreSQL writers for better performance and error management.

@WenyXu WenyXu requested review from evenyag, v0y4g3r, waynexia and a team as code owners November 12, 2024 12:23
Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

Walkthrough

The changes in this pull request primarily focus on enhancing the handling of JSON and binary data types within the data type conversion logic. Key modifications include clearer distinctions between ConcreteDataType::Json and ConcreteDataType::Binary, improved conversion functions, and the introduction of new methods for JSON type handling. Additional changes involve refining error handling and updating import statements across various modules to utilize new utility functions for JSON processing.

Changes

File Path Change Summary
src/api/src/helper.rs Updated conversion logic for ConcreteDataType to ColumnDataType, ensuring distinct handling of JSON types.
src/datatypes/src/data_type.rs Added method as_json to ConcreteDataType for casting to JsonType.
src/datatypes/src/types.rs Introduced functions json_type_value_to_string and parse_string_to_json_type_value for JSON handling.
src/datatypes/src/types/json_type.rs Added JsonFormat enum and updated JsonType struct to include a format field; modified constructor.
src/mito2/src/request.rs Modified proto_value_type_match to match ColumnDataType::Json with ColumnDataType::Binary.
src/operator/src/req_convert/common.rs Changed datatype of JSON columns from ColumnDataType::Binary to ColumnDataType::Json.
src/servers/src/mysql/writer.rs Updated import statements and modified write_recordbatch to use json_type_value_to_string.
src/servers/src/postgres/types.rs Added import for json_type_value_to_string and updated encoding logic for JSON types.
src/sql/src/statements.rs Refined JSON parsing logic in parse_string_to_value using parse_string_to_json_type_value.

Possibly related PRs

  • feat: add json data type #4619: The changes in this PR enhance the handling of Json data types within the ColumnDataTypeWrapper, which is directly related to the modifications in the main PR that refine the handling of ConcreteDataType::Json and its conversion to ColumnDataType::Json.

Suggested reviewers

  • v0y4g3r
  • evenyag
  • discord9
  • waynexia

🐇 In the meadow, hopping high,
JSON types now soar and fly.
With clearer paths and types defined,
Our data dances, well-aligned.
In code we trust, with joy we sing,
For every change, the rabbits bring! 🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Nov 12, 2024
@WenyXu
Copy link
Member Author

WenyXu commented Nov 12, 2024

@coderabbitai summary

Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

✅ Actions performed

Summary regeneration triggered.

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 82.97872% with 8 lines in your changes missing coverage. Please review.

Project coverage is 83.82%. Comparing base (0b6d78a) to head (062557d).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4979      +/-   ##
==========================================
- Coverage   84.06%   83.82%   -0.24%     
==========================================
  Files        1144     1144              
  Lines      213143   213171      +28     
==========================================
- Hits       179176   178694     -482     
- Misses      33967    34477     +510     

Copy link
Collaborator

@fengjiachun fengjiachun left a comment

Choose a reason for hiding this comment

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

Rest LGTM

src/datatypes/src/types/json_type.rs Show resolved Hide resolved
src/datatypes/src/types/json_type.rs Show resolved Hide resolved
@WenyXu WenyXu added this pull request to the merge queue Nov 13, 2024
Merged via the queue into GreptimeTeam:main with commit 3bf9981 Nov 13, 2024
39 checks passed
@WenyXu WenyXu deleted the feat/enhance-json-type branch November 13, 2024 03:20
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants