-
Notifications
You must be signed in to change notification settings - Fork 313
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: support show views statement #4360
Conversation
WalkthroughThe changes introduce support for Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant SQL Parser
participant Statement Executor
participant Database
User->>CLI: Input SHOW VIEWS;
CLI->>SQL Parser: Parse SHOW VIEWS statement
SQL Parser->>Statement Executor: Create ShowViews statement
Statement Executor->>Database: Query views information
Database-->>Statement Executor: Return views list
Statement Executor-->>CLI: Display views list
CLI-->>User: Show views list
Possibly related issues
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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
Outside diff range, codebase verification and nitpick comments (1)
src/query/src/sql.rs (1)
746-746
: Consider replacing hardcoded string.It would be great if we can replace the hardcoded string
"VIEW"
with a constant or an enum value for better maintainability.const VIEW_TYPE: &str = "VIEW";
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (9)
- 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 (4 hunks)
- src/sql/src/parsers/show_parser.rs (4 hunks)
- src/sql/src/statements/show.rs (2 hunks)
- src/sql/src/statements/statement.rs (3 hunks)
- tests/cases/standalone/common/view/view.result (2 hunks)
- tests/cases/standalone/common/view/view.sql (2 hunks)
Files skipped from review due to trivial changes (2)
- tests/cases/standalone/common/view/view.result
- tests/cases/standalone/common/view/view.sql
Additional comments not posted (11)
src/sql/src/statements/statement.rs (2)
94-95
: Addition ofShowViews
variant toStatement
enum looks good.The
ShowViews
variant is correctly added to theStatement
enum.
137-137
: Addition ofShowViews
match arm toDisplay
implementation looks good.The
ShowViews
match arm is correctly added to theDisplay
implementation.src/operator/src/statement/show.rs (1)
155-164
: Addition ofshow_views
method toStatementExecutor
looks good.The
show_views
method is correctly added and follows the pattern of othershow_*
methods.src/sql/src/statements/show.rs (2)
203-208
: Addition ofShowViews
struct looks good.The
ShowViews
struct is correctly added with fieldskind
anddatabase
.
210-220
: Addition ofDisplay
implementation forShowViews
looks good.The
Display
implementation forShowViews
is correctly added.src/operator/src/statement.rs (1)
139-140
: Addition ofShowViews
match arm toexecute_sql
method looks good.The
ShowViews
match arm is correctly added to theexecute_sql
method.src/frontend/src/instance.rs (1)
509-511
: LGTM!The addition of handling for
Statement::ShowViews
in thecheck_permission
function is consistent with the handling for other similar statements.src/sql/src/parsers/show_parser.rs (3)
47-48
: LGTM!The addition of handling for
SHOW VIEWS
statements in theparse_show
function is consistent with the handling for other similar statements.
436-462
: LGTM!The new
parse_show_views
function correctly parsesSHOW VIEWS
statements and is consistent with the parsing of other similar statements.
977-1008
: LGTM!The new test cases comprehensively cover the parsing of
SHOW VIEWS
statements.src/query/src/sql.rs (1)
729-764
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that the new
show_views
function is correctly used and tested in the codebase.Verification successful
The
show_views
function is correctly used and tested in the codebase.
src/operator/src/statement.rs
- The function is invoked here.src/operator/src/statement/show.rs
- Another function callsshow_views
here.- Related test functions and parsing functions are present in
src/sql/src/statements/show.rs
andsrc/sql/src/parsers/show_parser.rs
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the new `show_views` function in the codebase. # Test: Search for the function usage. Expect: Occurrences of the new function usage. rg --type rust -A 5 $'show_views'Length of output: 4008
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4360 +/- ##
==========================================
- Coverage 85.15% 84.87% -0.29%
==========================================
Files 1063 1063
Lines 189987 190116 +129
==========================================
- Hits 161782 161358 -424
- Misses 28205 28758 +553 |
There was a problem hiding this 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
Files selected for processing (9)
- 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 (2 hunks)
- src/sql/src/statements/statement.rs (3 hunks)
- tests/cases/standalone/common/view/view.result (2 hunks)
- tests/cases/standalone/common/view/view.sql (2 hunks)
Files skipped from review due to trivial changes (1)
- src/query/src/sql.rs
Files skipped from review as they are similar to previous changes (6)
- src/frontend/src/instance.rs
- src/operator/src/statement.rs
- src/operator/src/statement/show.rs
- src/sql/src/statements/show.rs
- src/sql/src/statements/statement.rs
- tests/cases/standalone/common/view/view.sql
Additional context used
Learnings (1)
tests/cases/standalone/common/view/view.result (1)
Learnt from: killme2008 PR: GreptimeTeam/greptimedb#4231 File: tests/cases/standalone/common/view/show_create.sql:37-37 Timestamp: 2024-07-09T20:51:21.719Z Learning: The SQL located in `tests/cases` represents test cases designed to target specific corner cases. Suggestions such as using `DROP VIEW IF EXISTS` to avoid errors should not be applied in this context.
Additional comments not posted (5)
tests/cases/standalone/common/view/view.result (2)
55-62
: LGTM! AddedSHOW VIEWS
statement and its result are correct.The
SHOW VIEWS
statement correctly lists the views in the database, and the expected result format is accurate.
92-96
: LGTM! AddedSHOW VIEWS
statement and its result are correct.The
SHOW VIEWS
statement correctly lists the views in the database, and the expected result format is accurate.src/sql/src/parsers/show_parser.rs (3)
436-456
: LGTM! Addedparse_show_views
function is correct.The
parse_show_views
function correctly parses theSHOW VIEWS
statement and returns the correspondingStatement
.
971-985
: LGTM! Addedtest_show_views
function is correct.The
test_show_views
function correctly tests the parsing of theSHOW VIEWS
statement.
987-1002
: LGTM! Addedtest_show_views_in_db
function is correct.The
test_show_views_in_db
function correctly tests the parsing of theSHOW VIEWS IN <database>
statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
There was a problem hiding this 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
Files selected for processing (9)
- 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 (4 hunks)
- src/sql/src/parsers/show_parser.rs (4 hunks)
- src/sql/src/statements/show.rs (2 hunks)
- src/sql/src/statements/statement.rs (3 hunks)
- tests/cases/standalone/common/view/view.result (2 hunks)
- tests/cases/standalone/common/view/view.sql (2 hunks)
Files skipped from review due to trivial changes (1)
- tests/cases/standalone/common/view/view.result
Files skipped from review as they are similar to previous changes (7)
- src/frontend/src/instance.rs
- src/operator/src/statement.rs
- src/operator/src/statement/show.rs
- src/sql/src/parsers/show_parser.rs
- src/sql/src/statements/show.rs
- src/sql/src/statements/statement.rs
- tests/cases/standalone/common/view/view.sql
Additional comments not posted (2)
src/query/src/sql.rs (2)
73-73
: LGTM!The addition of the constant
VIEWS_COLUMN
aligns with the existing pattern for other columns.
730-764
: LGTM! But add documentation.The implementation of the
show_views
function is well-structured and consistent with othershow
functions.Ensure that the new
show_views
function is documented, explaining its purpose and usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
#4338
What's changed and what's your intention?
!!! DO NOT LEAVE THIS BLOCK EMPTY !!!
Please explain IN DETAIL what the changes are in this PR and why they are needed:
Checklist
Summary by CodeRabbit
New Features
SHOW VIEWS
SQL statements to display views in the database.SHOW VIEWS
andSHOW VIEWS IN <database>
commands.Tests
SHOW VIEWS
andSHOW VIEWS IN <database>
statements to ensure correctness.