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: customize copy to parquet parameter #4328

Merged
merged 6 commits into from
Jul 10, 2024

Conversation

v0y4g3r
Copy link
Contributor

@v0y4g3r v0y4g3r commented Jul 9, 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 adds customized column config for parquet writer while copying table data to parquet files.

733->524

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

    • Enhanced Parquet file writing with customizable column properties and improved compression settings.
  • Improvements

    • Increased the default value of max_active_window_runs from 1 to 4, improving performance in specific scenarios.
    • Updated compaction test configurations to include detailed options for compaction type and settings.
  • Tests

    • Adjusted test scenarios to reflect new compaction and merge mode settings, ensuring consistency and reliability.

Enhance Parquet Writer with Column-wise Configuration

Summary:

 • Introduced column_wise_config function to customize per-column properties in Parquet writer.
Enhance Parquet File Format Handling for Specific Data Types

Summary:

 • Added ConcreteDataType import to support specific data type handling.
@v0y4g3r v0y4g3r requested a review from a team as a code owner July 9, 2024 12:39
@v0y4g3r v0y4g3r requested a review from shuiyisong July 9, 2024 12:40
Copy link
Contributor

coderabbitai bot commented Jul 9, 2024

Walkthrough

The recent modifications encompass enhancements to Parquet file writing, adjustments to default configuration values for compaction processes, and updates to test scenarios for better alignment with new settings. Specifically, Parquet writing now benefits from custom column properties, while TWCS compaction has an increased default window run count, and test cases have been updated for comprehensive configuration coverage.

Changes

Files Change Summary
src/common/datasource/src/file_format/parquet.rs Introduced ConcreteDataType and SchemaRef, enhanced WriterProperties with column-specific configs.
src/mito2/src/region/options.rs Changed default max_active_window_runs in TwcsOptions from 1 to 4.
src/mito2/src/engine/compaction_test.rs Updated test_compaction_region to include compaction-specific settings in CreateRequest.
src/mito2/src/engine/merge_mode_test.rs Adjusted compaction test configurations, setting max active/inactive window runs from 2 to 1.

Sequence Diagram(s)

No sequence diagrams needed for these changes as they primarily involve configuration updates and test enhancements.

Poem

In the code where data flows,
Parquet writes with custom glows,
Compaction rules, now four strong,
Tests aligned, we march along.
In the fields of bytes and rows,
CodeRabbit cheers, and onward goes! 🚀🐇


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 9, 2024
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 1ddf19d and e3db2c7.

Files selected for processing (2)
  • src/common/datasource/src/file_format/parquet.rs (4 hunks)
  • src/operator/src/statement/copy_table_to.rs (1 hunks)
Additional comments not posted (4)
src/operator/src/statement/copy_table_to.rs (1)

78-89: LGTM! Ensures schema is utilized correctly for Parquet writing.

The changes correctly extract the schema from the stream before calling stream_to_parquet, ensuring the schema information is utilized during the Parquet file writing process.

src/common/datasource/src/file_format/parquet.rs (3)

30-31: Approved: Necessary imports for column-wise configuration.

The imports of ConcreteDataType and SchemaRef are necessary for the new column-wise configuration functionality.


190-199: LGTM! Enhances flexibility with column-wise configuration.

The addition of the call to column_wise_config allows for customized column properties, enhancing the flexibility of Parquet file writing.


224-247: LGTM! Provides granular control over column properties.

The column_wise_config function customizes per-column properties, such as disabling dictionary encoding for the timestamp column and using delta binary packed encoding for int32/int64 columns, improving the efficiency and customization of Parquet file writing.

Copy link

codecov bot commented Jul 9, 2024

Codecov Report

Attention: Patch coverage is 21.05263% with 30 lines in your changes missing coverage. Please review.

Project coverage is 84.90%. Comparing base (1a9314a) to head (76e66aa).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4328      +/-   ##
==========================================
- Coverage   85.18%   84.90%   -0.29%     
==========================================
  Files        1061     1060       -1     
  Lines      188392   189069     +677     
==========================================
+ Hits       160485   160520      +35     
- Misses      27907    28549     +642     

 Refactor Parquet file format configuration
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 e3db2c7 and 19c87a7.

Files selected for processing (1)
  • src/common/datasource/src/file_format/parquet.rs (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/common/datasource/src/file_format/parquet.rs

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.

Rest LGM

src/common/datasource/src/file_format/parquet.rs Outdated Show resolved Hide resolved
 Enhance Parquet file format handling for timestamp columns

 - Added logic to disable dictionary encoding and set DELTA_BINARY_PACKED encoding for timestamp columns in the Parquet file format configuration.
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 19c87a7 and 4ac87c2.

Files selected for processing (1)
  • src/common/datasource/src/file_format/parquet.rs (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/common/datasource/src/file_format/parquet.rs

 Disable dictionary encoding for timestamp columns in Parquet writer and update default max_active_window_runs in TwcsOptions

 - Modified Parquet writer to disable dictionary encoding for timestamp columns to optimize for increasing timestamp data.
@v0y4g3r v0y4g3r requested a review from waynexia as a code owner July 10, 2024 07:07
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4ac87c2 and 5e51546.

Files selected for processing (2)
  • src/common/datasource/src/file_format/parquet.rs (4 hunks)
  • src/mito2/src/region/options.rs (1 hunks)
Additional comments not posted (5)
src/common/datasource/src/file_format/parquet.rs (4)

30-37: LGTM! Imports are necessary for added functionality.

The new imports from datatypes module and parquet::schema::types::ColumnPath are appropriate and necessary for the added functionality.


223-239: LGTM! But consider improving the logic for other data types.

The column_wise_config function correctly customizes per-column properties, especially for timestamp columns.

However, consider improving the logic for other data types based on previous review comments.

    for col in schema.column_schemas() {
        if col.data_type.is_timestamp() {
            let path = ColumnPath::new(vec![col.name.clone()]);
            props = props
                .set_column_dictionary_enabled(path.clone(), false)
                .set_column_encoding(path, Encoding::DELTA_BINARY_PACKED)
        }
    }

Line range hint 78-80: Skip generating a review comment.

The TODO comment is a reminder for future improvements and does not affect the current functionality.


189-198: LGTM! But verify the function usage in the codebase.

The changes to incorporate the new column-wise configuration in the stream_to_parquet function are approved.

However, ensure that all function calls to stream_to_parquet are updated to handle the new configuration.

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

219-219: LGTM! But verify the usage of TwcsOptions in the codebase.

The change to increase the default value for the max_active_window_runs field from 1 to 4 is approved.

However, ensure that this change does not introduce any issues by verifying the usage of TwcsOptions in the codebase.

@evenyag
Copy link
Contributor

evenyag commented Jul 10, 2024

 Update compaction settings in tests

 - Modified `test_compaction_region` to include new compaction options: `compaction.type`,
 `compaction.twcs.max_active_window_runs`, and `compaction.twcs.max_inactive_window_runs`.
 - Updated `test_merge_mode_compaction` to use `compaction.twcs.max_active_window_runs` and
 `compaction.twcs.max_inactive_window_runs` instead of `max_active_window_files` and
 `max_inactive_window_files`.
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 5e51546 and 76e66aa.

Files selected for processing (2)
  • src/mito2/src/engine/compaction_test.rs (1 hunks)
  • src/mito2/src/engine/merge_mode_test.rs (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/mito2/src/engine/merge_mode_test.rs
Additional comments not posted (1)
src/mito2/src/engine/compaction_test.rs (1)

115-119: Verify the compaction options.

The added options for compaction.type and compaction.twcs.* settings should be verified to ensure they are correctly implemented and used in the codebase.

Verification successful

The compaction options are correctly implemented and used.

The added options for compaction.type and compaction.twcs.* settings are correctly implemented and referenced in multiple places in the codebase, including relevant tests and configurations.

  • src/store-api/src/mito_engine_options.rs
  • src/sql/src/statements/create.rs
  • src/sql/src/parsers/create_parser.rs
  • src/mito2/src/region/options.rs
  • src/mito2/src/engine/append_mode_test.rs
  • src/mito2/src/engine/filter_deleted_test.rs
  • src/mito2/src/engine/compaction_test.rs
  • src/mito2/src/engine/merge_mode_test.rs
  • src/common/function/src/table/flush_compact_table.rs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new compaction options in the codebase.

# Test: Search for the usage of compaction options. Expect: Correct usage in relevant files.
rg --type rust -A 5 $'compaction.type'
rg --type rust -A 5 $'compaction.twcs.max_active_window_runs'
rg --type rust -A 5 $'compaction.twcs.max_inactive_window_runs'

Length of output: 20278

@evenyag evenyag added this pull request to the merge queue Jul 10, 2024
Merged via the queue into GreptimeTeam:main with commit da0c840 Jul 10, 2024
55 checks passed
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