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

fix: error on show databases in non-default catalog #4316

Merged

Conversation

sunng87
Copy link
Member

@sunng87 sunng87 commented Jul 8, 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?

Fixes issue introduced in #4174 that throws error on non-default catalog when running show databases. Reproducible tests included.

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

  • Bug Fixes

    • Improved schema options retrieval logic, ensuring more accurate handling of schema information.
  • Tests

    • Added new integration test test_show_databases to validate SQL queries for showing databases.

@sunng87 sunng87 requested a review from a team as a code owner July 8, 2024 10:08
Copy link
Contributor

coderabbitai bot commented Jul 8, 2024

Walkthrough

The recent changes involve updates to schema handling and testing functions. In the schemata.rs file, the SchemaNotFoundSnafu context was removed, and schema options retrieval logic was adjusted accordingly. In instance_test.rs, a new test function test_show_databases was added and some import statements were updated to facilitate this new test.

Changes

Files Change Summary
src/catalog/src/information_schema/schemata.rs Removed SchemaNotFoundSnafu, adjusted schema options retrieval from table_metadata_manager, modified InformationSchemaSchemataBuilder.
tests-integration/src/tests/instance_test.rs Imported DEFAULT_SCHEMA_NAME, added test_show_databases function, updated import to include both OutputData and DEFAULT_SCHEMA_NAME.

Poem

In the land of schema's dance,
A change is set to enhance.
Options fetched with utmost care,
And tests to show the databases there.
🐰 In code we trust, improvements blend,
Hopping forward without an end! ✨


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 8, 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 59afa70 and 4c33457.

Files selected for processing (2)
  • src/catalog/src/information_schema/schemata.rs (2 hunks)
  • tests-integration/src/tests/instance_test.rs (2 hunks)
Additional comments not posted (4)
src/catalog/src/information_schema/schemata.rs (2)

36-36: Removal of SchemaNotFoundSnafu from imports.

The SchemaNotFoundSnafu import has been removed, indicating that this error is no longer being handled. Ensure that this change does not affect the overall error handling logic in the code.


175-182: Verify correctness of schema options retrieval logic.

The schema options retrieval logic has been updated to handle the absence of table_metadata_manager and format schema_opts. Ensure that the new logic correctly handles these cases and that the formatted schema_opts are as expected.

Verification successful

Verify correctness of schema options retrieval logic.

The schema options retrieval logic has been updated to handle the absence of table_metadata_manager and format schema_opts. Ensure that the new logic correctly handles these cases and that the formatted schema_opts are as expected.


Verified correctness of schema options retrieval logic.

The schema options retrieval logic correctly handles the absence of table_metadata_manager and formats schema_opts as expected.

  • The table_metadata_manager is checked for Some before proceeding.
  • The schema options are formatted using format!("{schema_opts}").
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of schema options retrieval logic.

# Test: Search for the usage of `table_metadata_manager` and `schema_opts` formatting.
rg --type rust 'table_metadata_manager|schema_opts'

Length of output: 34474


Script:

#!/bin/bash
# Extract the implementation of the make_schemata method and related methods from schemata.rs
ast-grep --lang rust --pattern 'impl $_ {
  fn make_schemata($$) -> $_ {
    $$$
  }
}' > make_schemata_impl.txt

Length of output: 89


Script:

#!/bin/bash
# Search for the make_schemata method directly and include context lines
rg --type rust 'fn make_schemata' -A 10 -B 10 src/catalog/src/information_schema/schemata.rs

Length of output: 1257

tests-integration/src/tests/instance_test.rs (2)

19-19: Import DEFAULT_SCHEMA_NAME from client module.

This import is necessary to use the default schema name in the test function.


1883-1917: LGTM! Verify the function integration within the test suite.

The code changes are approved.

However, ensure that the new test function test_show_databases is properly integrated and executed within the test suite.

Copy link

codecov bot commented Jul 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.86%. Comparing base (aa4d10e) to head (1ced67e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4316      +/-   ##
==========================================
- Coverage   85.13%   84.86%   -0.28%     
==========================================
  Files        1061     1061              
  Lines      187834   187830       -4     
==========================================
- Hits       159911   159395     -516     
- Misses      27923    28435     +512     

Copy link
Collaborator

@zyy17 zyy17 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

LGTM

@killme2008 killme2008 added this pull request to the merge queue Jul 8, 2024
Merged via the queue into GreptimeTeam:main with commit 81308b9 Jul 8, 2024
52 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