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

docs: json datatype rfc #4515

Merged
merged 16 commits into from
Sep 19, 2024
Merged

docs: json datatype rfc #4515

merged 16 commits into from
Sep 19, 2024

Conversation

CookiePieWw
Copy link
Collaborator

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

#4230

What's changed and what's your intention?

RFC of json datatype.

Checklist

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

@CookiePieWw CookiePieWw requested a review from a team as a code owner August 6, 2024 00:48
Copy link
Contributor

coderabbitai bot commented Aug 6, 2024

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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 generate interesting stats about this repository and render them as a table.
    -- @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 Aug 6, 2024
Copy link
Contributor

@killme2008 killme2008 left a comment

Choose a reason for hiding this comment

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

Looks cool to me!

docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
@fengjiachun
Copy link
Collaborator

LGTM, @WenyXu PTAL

docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
@WenyXu WenyXu mentioned this pull request Aug 7, 2024
8 tasks
@waynexia
Copy link
Member

waynexia commented Aug 8, 2024

I came up with two scenarios of how JSON would be used by end users:

  • Data source uses JSON to encode their data, but the schema to JSON is relatively fixed. Like OTLP protocol or some HTTP header/response. In this case the JSON itself is usually defined with a clear schema.
  • Use us to store an arbitrary JSON object. Neither the user nor user of our user knows the schema.

For the first case, we can suggest users decompose the JSON object into table columns. Either by themselves (predefined table schema) or by GreptimeDB (gRPC auto alter or through pipeline). So from the DB side, it's just a wide table with several atomic types. And is not distinguishable from other tables. Advantages like high compression ratio or SQL interface are available out-of-box.

The second case on the contrary, requires a fully dynamic ability to JSON data. We'd prefer to handle the "JSON part" on read (like decoding and/or field accessing) to minimize the affection to write performance. This choice is based on the hypothesis that data without known schema is unlikely to be queried frequently.

Reflecting to the implementation phase, the need & no-need to are:

  • Need a mechanism to decompose JSON and trigger ALTER TABLE if necessary.
    • This operation needs to happen on frontend or before frontend. The Pipeline is a good choice.
  • Need a bunch of util functions to handle (undecomposed, the second case) JSON data
  • Don't need to be aware of the concrete JSON schema in the storage engine layer. JSON data is either decomposed for the first case or stored as an opaque field for the second case
  • Don't need to introduce STRUCT type as it's not a hard requirement. I.e., it can bring a better experience in expressing the schema of decomposed JSON data, but we can still use this without STRUCT type.

@CookiePieWw
Copy link
Collaborator Author

CookiePieWw commented Aug 12, 2024

Thanks for all suggestions! I've changed the rfc to a relatively simple jsonb plan which is a first consensus for general json data type. It's not a detailed plan. I think I can first make some efforts in the direction and then get back and refine this rfc.

docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
@waynexia
Copy link
Member

For those "util functions", we can use https://github.com/datafusion-contrib/datafusion-functions-json which provides an out-of-box implementation. As well as the binary representation, JSONA.

@WenyXu
Copy link
Member

WenyXu commented Aug 14, 2024

For those "util functions", we can use https://github.com/datafusion-contrib/datafusion-functions-json which provides an out-of-box implementation. As well as the binary representation, JSONA.

set of functions for querying JSON strings in DataFusion

This crate just provides functions for querying JSON strings.

@CookiePieWw
Copy link
Collaborator Author

I happens to trigger some auto-review-request because of misoperation QAQ, sry for that.

docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
docs/rfcs/2024-08-06-json-datatype.md Outdated Show resolved Hide resolved
@WenyXu WenyXu added this pull request to the merge queue Sep 19, 2024
Merged via the queue into GreptimeTeam:main with commit 0295f8d Sep 19, 2024
9 checks passed
@CookiePieWw CookiePieWw deleted the json-rfc branch September 26, 2024 05:34
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.

7 participants