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: impl show table status #4303

Merged
merged 3 commits into from
Jul 8, 2024

Conversation

killme2008
Copy link
Contributor

@killme2008 killme2008 commented Jul 6, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

#4017 #3354

What's changed and what's your intention?

  • Impl show table status [IN database] [LIKE name | WHERE ..].
mysql> show table status\G;
*************************** 1. row ***************************
           Name: numbers
         Engine: test_engine
        Version: 11
     Row_format: Fixed
           Rows: 0
 Avg_row_length: 0
    Data_length: 0
Max_data_length: 0
   Index_length: 0
      Data_free: 0
 Auto_increment: 0
    Create_time: 2024-07-05 23:20:47.992000
    Update_time: NULL
     Check_time: NULL
      Collation: NULL
       Checksum: 0
 Create_options:
        Comment: NULL
1 row in set (0.20 sec)
  • Fixed the ShowKind display, the All should not display, it's just a placeholder.

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 SHOW TABLE STATUS command to retrieve information about table statuses within the database.
  • Enhancements

    • Improved display logic for various SHOW commands to provide more consistent and clearer output.
  • Configuration Changes

    • Changed default Kafka compression setting from Lz4 to NoCompression for both Datanode and Standalone configurations.
  • Tests

    • Added new test cases for SHOW TABLES LIKE, SHOW FULL TABLES, and SHOW TABLE STATUS commands.

@killme2008 killme2008 marked this pull request as ready for review July 6, 2024 00:04
@killme2008 killme2008 requested review from evenyag and a team as code owners July 6, 2024 00:04
Copy link
Contributor

coderabbitai bot commented Jul 6, 2024

Walkthrough

The overall changes integrate a new ShowTableStatus feature, modify visibility for an ENGINE constant, refine query output formatting, and update compression settings within kafka configurations. The new ShowTableStatus statements span various files, enhancing SQL parsing, statement execution, and result formatting. These updates enable detailed table status retrieval via SQL, improving database management capabilities.

Changes

Files/Groups Change Summary
src/catalog/src/information_schema/tables.rs Changed visibility of ENGINE constant from private to public.
src/frontend/src/instance.rs Introduced Statement::ShowTableStatus case in check_permission function.
src/operator/src/statement (multiple files) Added show_table_status function and replaced ShowTables with ShowTableStatus.
src/query/src/sql.rs Added show_table_status function and updated show_tables to return Output if successful.
src/sql/src/parsers/show_parser.rs Added ShowTableStatus variant to Show enum and implemented parsing logic for SHOW statements.
src/sql/src/statements (multiple files) Updated ShowKind::All variant, added format_kind! macro, and enhanced Display implementations.
tests/cases/standalone/common/show (multiple files) Added new queries using SHOW TABLES LIKE, SHOW FULL TABLES, and SHOW TABLE STATUS.
src/common/wal/src/config.rs, src/common/wal/src/config/kafka/* (multiple files) Changed compression setting from Lz4 to NoCompression.

Poem

In the codebase, changes bloom,
Tables now show their status, room by room.
Compression shifts, light as air,
Improvements scattered everywhere.
🎉✨ Hopping through lines with cheer,
For updates that bring us near. 🚀🐇


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.

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 3f4928e and 2ac189c.

Files selected for processing (10)
  • src/catalog/src/information_schema/tables.rs (1 hunks)
  • src/frontend/src/instance.rs (1 hunks)
  • src/operator/src/statement.rs (1 hunks)
  • src/operator/src/statement/show.rs (2 hunks)
  • src/query/src/sql.rs (3 hunks)
  • src/sql/src/parsers/show_parser.rs (4 hunks)
  • src/sql/src/statements/show.rs (11 hunks)
  • src/sql/src/statements/statement.rs (3 hunks)
  • tests/cases/standalone/common/show/show_databases_tables.result (1 hunks)
  • tests/cases/standalone/common/show/show_databases_tables.sql (1 hunks)
Files skipped from review due to trivial changes (2)
  • src/catalog/src/information_schema/tables.rs
  • tests/cases/standalone/common/show/show_databases_tables.result
Additional comments not posted (9)
tests/cases/standalone/common/show/show_databases_tables.sql (1)

9-10: LGTM!

The added SQL commands for SHOW TABLE STATUS and its variations are syntactically correct and align with the feature implementation.

Also applies to: 11-12, 14-15, 17-18, 20-21, 23-24

src/sql/src/statements/statement.rs (1)

35-35: LGTM!

The addition of the ShowTableStatus variant in the Statement enum and its Display implementation is consistent with other variants and correctly implemented.

Also applies to: 74-75, 124-124

src/operator/src/statement/show.rs (1)

25-25: LGTM!

The addition of the show_table_status method in StatementExecutor is correctly implemented and consistent with other methods.

Also applies to: 58-67

src/sql/src/statements/show.rs (1)

32-33: LGTM!

The addition of the ShowTableStatus struct, its Display implementation, and the format_kind! macro are correctly implemented and consistent with other similar entities.

Also applies to: 40-46, 70-75, 89-95, 109-116, 134-141, 144-160

src/operator/src/statement.rs (1)

129-130: LGTM!

The addition of Statement::ShowTableStatus is consistent with the existing pattern of handling other Statement variants.

src/frontend/src/instance.rs (1)

523-525: LGTM!

The addition of Statement::ShowTableStatus is consistent with the existing pattern of handling other Statement variants. The macro validate_db_permission! is used appropriately.

src/sql/src/parsers/show_parser.rs (2)

39-46: LGTM!

The addition for handling SHOW TABLE STATUS is consistent with the existing pattern of handling other SHOW statements. The function parse_show_table_status is called appropriately.


353-377: LGTM!

The parse_show_table_status function correctly parses the SHOW TABLE STATUS statement and handles the optional database and ShowKind clauses. The implementation is consistent with the other parse_show_* functions.

src/query/src/sql.rs (1)

493-548: Ensure completeness and correctness of the show_table_status function.

The function show_table_status appears to be well-structured and follows the pattern used in other similar functions. However, ensure that all necessary fields are being queried and returned as per the MySQL documentation for SHOW TABLE STATUS.

Additionally, consider the following potential improvements:

  1. Error Handling: Ensure that any potential errors are properly handled and propagated.
  2. Code Comments: Adding comments to explain the purpose of each section of the code can improve readability and maintainability.
Verification successful

Ensure completeness and correctness of the show_table_status function.

The function show_table_status correctly includes all necessary fields as per the MySQL documentation for SHOW TABLE STATUS. However, consider the following potential improvements:

  1. Error Handling: Ensure that any potential errors are properly handled and propagated.
  2. Code Comments: Adding comments to explain the purpose of each section of the code can improve readability and maintainability.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all necessary fields are being queried and returned in the `show_table_status` function.

# Test: Search for the fields being queried. Expect: All necessary fields are present.
rg --type rust $'tables::TABLE_NAME|tables::ENGINE|tables::VERSION|tables::ROW_FORMAT|tables::TABLE_ROWS|tables::AVG_ROW_LENGTH|tables::DATA_LENGTH|tables::MAX_DATA_LENGTH|tables::INDEX_LENGTH|tables::DATA_FREE|tables::AUTO_INCREMENT|tables::CREATE_TIME|tables::UPDATE_TIME|tables::CHECK_TIME|tables::TABLE_COLLATION|tables::CHECKSUM|tables::CREATE_OPTIONS|tables::TABLE_COMMENT'

Length of output: 2011

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 2ac189c and 7b2ed13.

Files selected for processing (2)
  • src/sql/src/parsers/show_parser.rs (4 hunks)
  • src/sql/src/statements/show.rs (11 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/sql/src/parsers/show_parser.rs
  • src/sql/src/statements/show.rs

Copy link

codecov bot commented Jul 6, 2024

Codecov Report

Attention: Patch coverage is 58.04196% with 60 lines in your changes missing coverage. Please review.

Project coverage is 84.93%. Comparing base (3f4928e) to head (180dda1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4303      +/-   ##
==========================================
- Coverage   85.23%   84.93%   -0.30%     
==========================================
  Files        1059     1059              
  Lines      187111   187230     +119     
==========================================
- Hits       159480   159020     -460     
- Misses      27631    28210     +579     

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 7b2ed13 and 9b9602b.

Files selected for processing (10)
  • src/catalog/src/information_schema/tables.rs (1 hunks)
  • src/frontend/src/instance.rs (1 hunks)
  • src/operator/src/statement.rs (1 hunks)
  • src/operator/src/statement/show.rs (2 hunks)
  • src/query/src/sql.rs (3 hunks)
  • src/sql/src/parsers/show_parser.rs (4 hunks)
  • src/sql/src/statements/show.rs (11 hunks)
  • src/sql/src/statements/statement.rs (3 hunks)
  • tests/cases/standalone/common/show/show_databases_tables.result (1 hunks)
  • tests/cases/standalone/common/show/show_databases_tables.sql (1 hunks)
Files skipped from review as they are similar to previous changes (8)
  • src/operator/src/statement.rs
  • src/operator/src/statement/show.rs
  • src/query/src/sql.rs
  • src/sql/src/parsers/show_parser.rs
  • src/sql/src/statements/show.rs
  • src/sql/src/statements/statement.rs
  • tests/cases/standalone/common/show/show_databases_tables.result
  • tests/cases/standalone/common/show/show_databases_tables.sql
Additional comments not posted (2)
src/catalog/src/information_schema/tables.rs (1)

67-67: Visibility change approved.

The ENGINE constant is now public, which aligns with the new SHOW TABLE STATUS feature requirements.

src/frontend/src/instance.rs (1)

523-525: New permission check for ShowTableStatus approved.

The new ShowTableStatus statement is now included in the check_permission function, ensuring proper permission validation.

Copy link
Member

@sunng87 sunng87 left a comment

Choose a reason for hiding this comment

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

look good!

@sunng87 sunng87 enabled auto-merge July 6, 2024 02:04
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 9b9602b and 180dda1.

Files selected for processing (3)
  • src/common/wal/src/config.rs (2 hunks)
  • src/common/wal/src/config/kafka/datanode.rs (1 hunks)
  • src/common/wal/src/config/kafka/standalone.rs (1 hunks)
Additional comments not posted (4)
src/common/wal/src/config/kafka/datanode.rs (1)

49-49: Changed default compression setting for Kafka WAL configurations.

The default compression setting has been changed from Compression::Lz4 to Compression::NoCompression. This might impact the performance and storage efficiency. Ensure this change aligns with the overall system requirements.

src/common/wal/src/config/kafka/standalone.rs (1)

70-70: Changed default compression setting for standalone Kafka WAL configurations.

The default compression setting has been changed from Compression::Lz4 to Compression::NoCompression. This might impact the performance and storage efficiency. Ensure this change aligns with the overall system requirements.

src/common/wal/src/config.rs (2)

210-210: Changed compression setting for Kafka WAL configurations in test cases.

The compression setting for Kafka WAL configurations in the test cases has been changed from Compression::Lz4 to Compression::NoCompression. This might impact the performance and storage efficiency. Ensure this change aligns with the overall system requirements.


232-232: Changed compression setting for standalone Kafka WAL configurations in test cases.

The compression setting for standalone Kafka WAL configurations in the test cases has been changed from Compression::Lz4 to Compression::NoCompression. This might impact the performance and storage efficiency. Ensure this change aligns with the overall system requirements.

@killme2008
Copy link
Contributor Author

I have to revert #4294 , otherwise the sqlness with remote WAL always fails #4304 . @WenyXu

@WenyXu
Copy link
Member

WenyXu commented Jul 8, 2024

I have to revert #4294 , otherwise the sqlness with remote WAL always fails #4304 . @WenyXu

Let's do, I will take a look ASAP🥹

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

@sunng87 sunng87 added this pull request to the merge queue Jul 8, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 8, 2024
@killme2008 killme2008 added this pull request to the merge queue Jul 8, 2024
Merged via the queue into GreptimeTeam:main with commit bb32230 Jul 8, 2024
54 checks passed
@killme2008 killme2008 deleted the feature/show-table-status branch July 8, 2024 04:50
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.

4 participants