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

feat: expose merge_mode option #4289

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

evenyag
Copy link
Contributor

@evenyag evenyag commented Jul 4, 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?

This PR exposes the merge_mode table options and adds sqlness tests for it.

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

  • New Features

    • Introduced new "merge_mode" option for handling data insertion into tables.
    • Added support for different merge modes such as last_non_null and last_row during table creation and data insertion.
  • Tests

    • Added SQL tests demonstrating the behavior of new merge modes and handling of NULL values during data insertion.

Copy link
Contributor

coderabbitai bot commented Jul 4, 2024

Walkthrough

The changes introduce a new feature: the "merge_mode" option to the mito engine options. This includes modifications to the engine's key checking function, alongside new SQL scripts and test cases demonstrating the handling of NULL values in various merge modes like last_non_null and last_row.

Changes

File Path Summary
src/mito2/src/region/options.rs Added a comment about updating a function if exposing an option to table options.
src/store-api/src/mito_engine_options.rs Added "merge_mode" to valid keys in is_mito_engine_option_key.
tests/.../common/insert/merge_mode.result Introduced SQL behaviors for different merge modes (last_non_null, last_row, invalid).
tests/.../common/insert/merge_mode.sql Added tables and data insertion examples for various merge modes in SQL.

Poem

In the realm where data flows,
merge_mode now softly glows,
Last non-null, or last row to keep,
Through tables, it will sweep.
With queries set and tests in hand,
Mito's reign we now expand.


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>.
    • 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 show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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 Jul 4, 2024
@evenyag evenyag marked this pull request as ready for review July 4, 2024 13:47
@evenyag evenyag requested review from v0y4g3r, waynexia and a team as code owners July 4, 2024 13:47
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b5c6c72 and a0b0579.

Files selected for processing (4)
  • src/mito2/src/region/options.rs (1 hunks)
  • src/store-api/src/mito_engine_options.rs (1 hunks)
  • tests/cases/standalone/common/insert/merge_mode.result (1 hunks)
  • tests/cases/standalone/common/insert/merge_mode.sql (1 hunks)
Additional comments not posted (17)
tests/cases/standalone/common/insert/merge_mode.sql (6)

1-10: LGTM! Verify functionality of last_non_null merge mode.

The SQL script for creating the last_non_null_table with merge_mode set to last_non_null appears correct.

However, ensure that the merge_mode works as intended by verifying the results of the SELECT queries.


12-24: LGTM! Verify results of SELECT queries for last_non_null_table.

The SQL script for inserting data into the last_non_null_table and performing SELECT queries appears correct.

However, ensure that the results of the SELECT queries match the expected behavior of the last_non_null merge mode.


28-37: LGTM! Verify functionality of last_row merge mode.

The SQL script for creating the last_row_table with merge_mode set to last_row appears correct.

However, ensure that the merge_mode works as intended by verifying the results of the SELECT queries.


39-43: LGTM! Verify results of SELECT queries for last_row_table.

The SQL script for inserting data into the last_row_table and performing SELECT queries appears correct.

However, ensure that the results of the SELECT queries match the expected behavior of the last_row merge mode.


47-56: LGTM! Verify error handling for invalid_merge_mode.

The SQL script for creating the invalid_merge_mode table with an invalid merge mode appears correct.

However, ensure that the error is thrown as expected.


58-67: LGTM! Verify error handling for invalid_merge_mode with multiple merge modes.

The SQL script for creating the invalid_merge_mode table with multiple merge modes appears correct.

However, ensure that the error is thrown as expected.

src/store-api/src/mito_engine_options.rs (2)

38-38: LGTM! Merge mode option correctly included.

The merge_mode option is correctly included in the list of valid keys in the is_mito_engine_option_key function.


Line range hint 41-75:
LGTM! Comprehensive test cases for is_mito_engine_option_key function.

The test cases for the is_mito_engine_option_key function are comprehensive and cover various valid keys.

tests/cases/standalone/common/insert/merge_mode.result (5)

1-30: LGTM! Results for last_non_null_table are correct.

The results for the last_non_null_table match the expected behavior of the last_non_null merge mode.


31-55: LGTM! Results for additional data insertions into last_non_null_table are correct.

The results for additional data insertions into the last_non_null_table match the expected behavior of the last_non_null merge mode.


61-89: LGTM! Results for last_row_table are correct.

The results for the last_row_table match the expected behavior of the last_row merge mode.


95-106: LGTM! Error message for invalid_merge_mode is correct.

The error message for creating a table with an invalid merge mode matches the expected behavior.


108-119: LGTM! Error message for invalid_merge_mode with multiple merge modes is correct.

The error message for creating a table with multiple merge modes matches the expected behavior.

src/mito2/src/region/options.rs (4)

Line range hint 42-48:
LGTM! MergeMode enum is correctly defined.

The MergeMode enum is correctly defined to handle duplicate rows while merging.


Line range hint 51-69:
LGTM! RegionOptions struct is correctly updated.

The RegionOptions struct is correctly updated to include the merge_mode option.


Line range hint 71-78:
LGTM! Validate method is correctly updated.

The validate method of the RegionOptions struct is correctly updated to ensure that merge_mode is not allowed when append_mode is enabled.


Line range hint 91-138:
LGTM! TryFrom implementation is correctly updated.

The try_from implementation for RegionOptions is correctly updated to include the merge_mode option.

@github-actions github-actions bot added docs-required This change requires docs update. and removed docs-not-required This change does not impact docs. labels Jul 4, 2024
@github-actions github-actions bot added docs-not-required This change does not impact docs. and removed docs-required This change requires docs update. labels Jul 4, 2024
Copy link

codecov bot commented Jul 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.67%. Comparing base (b5c6c72) to head (a0b0579).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4289      +/-   ##
==========================================
- Coverage   84.94%   84.67%   -0.28%     
==========================================
  Files        1061     1061              
  Lines      188105   188106       +1     
==========================================
- Hits       159795   159287     -508     
- Misses      28310    28819     +509     

@evenyag evenyag requested a review from fengjiachun July 5, 2024 07:04
@evenyag evenyag changed the title feat: expose merge mode options feat: expose merge_mode option Jul 5, 2024
@waynexia waynexia removed the docs-not-required This change does not impact docs. label Jul 5, 2024
@github-actions github-actions bot added the docs-required This change requires docs update. label Jul 5, 2024
Copy link
Contributor

@v0y4g3r v0y4g3r left a comment

Choose a reason for hiding this comment

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

LGTM

@v0y4g3r v0y4g3r added this pull request to the merge queue Jul 5, 2024
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.

LGTM

Merged via the queue into GreptimeTeam:main with commit 60f599c Jul 5, 2024
64 of 78 checks passed
@v0y4g3r v0y4g3r deleted the feat/expose-merge-mode branch July 5, 2024 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-required This change requires docs update.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants