-
Notifications
You must be signed in to change notification settings - Fork 334
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: adding information_schema.views table #4342
feat: adding information_schema.views table #4342
Conversation
WalkthroughThe changes introduce a new Changes
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 (
|
69cd5f3
to
f340e4a
Compare
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 (10)
- src/catalog/src/information_schema.rs (4 hunks)
- src/catalog/src/information_schema/table_names.rs (1 hunks)
- src/catalog/src/information_schema/views.rs (1 hunks)
- src/common/catalog/src/consts.rs (1 hunks)
- tests/cases/standalone/common/information_schema/views.result (1 hunks)
- tests/cases/standalone/common/information_schema/views.sql (1 hunks)
- tests/cases/standalone/common/show/show_databases_tables.result (4 hunks)
- tests/cases/standalone/common/system/information_schema.result (4 hunks)
- tests/cases/standalone/common/view/create.result (3 hunks)
- tests/cases/standalone/create/recover_created.result (1 hunks)
Files skipped from review due to trivial changes (3)
- src/catalog/src/information_schema/table_names.rs
- tests/cases/standalone/common/information_schema/views.result
- tests/cases/standalone/create/recover_created.result
Additional context used
Learnings (1)
tests/cases/standalone/common/information_schema/views.sql (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 (17)
tests/cases/standalone/common/information_schema/views.sql (1)
1-13
: SQL Test Cases Approved.The SQL statements for creating the table, view, and querying the
information_schema.views
table are correct and cover the necessary functionality.The
DROP VIEW
statement is commented out with a FIXME comment indicating it is not supported yet. This is acceptable for now, given the context.src/common/catalog/src/consts.rs (1)
96-97
: New Constant Addition Approved.The addition of the
INFORMATION_SCHEMA_VIEW_TABLE_ID
constant follows the existing pattern and is appropriate for the newviews
table in the information schema.src/catalog/src/information_schema/views.rs (1)
1-290
: Implementation ofInformationSchemaViews
Approved.The implementation of the
InformationSchemaViews
struct and its associated methods is comprehensive and follows best practices. The schema construction, data streaming, and builder methods are well-structured. Attention to error handling and the use of async/await for asynchronous operations are commendable.src/catalog/src/information_schema.rs (2)
28-28
: Integration ofviews
Module Approved.The integration of the
views
module into theInformationSchemaProvider
is seamless and consistent with the existing codebase. The use of macros for setting up memory tables and the lazy_static block for initializing memory tables are well-aligned with the overall architecture.
268-271
: Addition ofInformationSchemaViews
toinformation_table
Approved.The addition of the
InformationSchemaViews
to theinformation_table
method inInformationSchemaProvider
is correct and necessary for the newviews
table functionality.tests/cases/standalone/common/show/show_databases_tables.result (3)
59-59
: Approved: Addition ofviews
to the list of tables.The addition of the
views
table to the list of tables in theSHOW TABLES
result is correct and aligns with the PR objectives.
104-104
: Approved: Addition ofviews
to the list of full tables.The addition of the
views
table to the list of full tables in theSHOW FULL TABLES
result is correct and aligns with the PR objectives.
142-142
: Approved: Addition ofviews
to theSHOW TABLE STATUS
result.The addition of the
views
table to theSHOW TABLE STATUS
result is correct and aligns with the PR objectives.tests/cases/standalone/common/view/create.result (6)
93-93
: Approved: Addition ofmyview
view to theSHOW TABLE STATUS
from public section.The addition of the
myview
view to theSHOW TABLE STATUS
from public section is correct and aligns with the PR objectives.
112-112
: Approved: Addition ofviews
table to theSHOW TABLE STATUS
result.The addition of the
views
table to theSHOW TABLE STATUS
result is correct and aligns with the PR objectives.
121-121
: Approved: Addition ofmyview
andtest_view
views to theSELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'VIEW'
result.The addition of the
myview
andtest_view
views to theSELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'VIEW'
result is correct and aligns with the PR objectives.
Line range hint
169-169
:
Approved: Creation ofschema_for_view_test
andtest_view
.The creation of
schema_for_view_test
andtest_view
is correct and aligns with the PR objectives.
93-93
: Approved: Addition oftest_view
to theSHOW TABLES
result.The addition of the
test_view
view to theSHOW TABLES
result is correct and aligns with the PR objectives.
112-112
: Approved: Addition oftest_view
to theSHOW FULL TABLES
result.The addition of the
test_view
view to theSHOW FULL TABLES
result is correct and aligns with the PR objectives.tests/cases/standalone/common/system/information_schema.result (3)
45-46
: LGTM!The addition of
views
andmyview
entries in the information schema is correct.
392-401
: LGTM!The added columns related to views in the information schema are correct and consistent with the expected structure.
Line range hint
441-464
:
LGTM!The addition of
myview
entries in the information schema is correct and consistent.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4342 +/- ##
==========================================
- Coverage 85.18% 84.83% -0.35%
==========================================
Files 1061 1062 +1
Lines 189447 189632 +185
==========================================
- Hits 161372 160883 -489
- Misses 28075 28749 +674 |
f340e4a
to
0fa915f
Compare
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 (10)
- src/catalog/src/information_schema.rs (4 hunks)
- src/catalog/src/information_schema/table_names.rs (1 hunks)
- src/catalog/src/information_schema/views.rs (1 hunks)
- src/common/catalog/src/consts.rs (1 hunks)
- tests/cases/standalone/common/information_schema/views.result (1 hunks)
- tests/cases/standalone/common/information_schema/views.sql (1 hunks)
- tests/cases/standalone/common/show/show_databases_tables.result (4 hunks)
- tests/cases/standalone/common/system/information_schema.result (4 hunks)
- tests/cases/standalone/common/view/create.result (3 hunks)
- tests/cases/standalone/create/recover_created.result (1 hunks)
Files skipped from review due to trivial changes (1)
- src/catalog/src/information_schema.rs
Files skipped from review as they are similar to previous changes (8)
- src/catalog/src/information_schema/table_names.rs
- src/catalog/src/information_schema/views.rs
- src/common/catalog/src/consts.rs
- tests/cases/standalone/common/information_schema/views.result
- tests/cases/standalone/common/show/show_databases_tables.result
- tests/cases/standalone/common/system/information_schema.result
- tests/cases/standalone/common/view/create.result
- tests/cases/standalone/create/recover_created.result
Additional context used
Learnings (1)
tests/cases/standalone/common/information_schema/views.sql (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 (7)
tests/cases/standalone/common/information_schema/views.sql (7)
1-1
: Test header approved.The header comment correctly indicates the purpose of the test.
2-2
: Schema selection approved.The
USE public;
statement correctly sets the current schema topublic
.
4-4
: Table creation approved.The
create table t (ts timestamp time index, val int);
statement correctly creates a table with the specified columns.
6-6
: View creation approved.The
create view myview as select * from t where val > 5;
statement correctly creates a view with the specified query.
8-8
: Query statement approved.The
select table_catalog, table_schema, table_name, view_definition from information_schema.views;
statement correctly queries the information schema views.
13-13
: Table drop statement approved.The
drop table t;
statement correctly drops the table.
10-11
: Commented-out lines approved.The comments correctly indicate that
DROP VIEW
is not supported yet.
0fa915f
to
65c483c
Compare
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 (10)
- src/catalog/src/information_schema.rs (4 hunks)
- src/catalog/src/information_schema/table_names.rs (1 hunks)
- src/catalog/src/information_schema/views.rs (1 hunks)
- src/common/catalog/src/consts.rs (1 hunks)
- tests/cases/standalone/common/information_schema/views.result (1 hunks)
- tests/cases/standalone/common/information_schema/views.sql (1 hunks)
- tests/cases/standalone/common/show/show_databases_tables.result (4 hunks)
- tests/cases/standalone/common/system/information_schema.result (4 hunks)
- tests/cases/standalone/common/view/create.result (3 hunks)
- tests/cases/standalone/create/recover_created.result (1 hunks)
Files skipped from review as they are similar to previous changes (9)
- src/catalog/src/information_schema.rs
- src/catalog/src/information_schema/table_names.rs
- src/catalog/src/information_schema/views.rs
- tests/cases/standalone/common/information_schema/views.result
- tests/cases/standalone/common/information_schema/views.sql
- tests/cases/standalone/common/show/show_databases_tables.result
- tests/cases/standalone/common/system/information_schema.result
- tests/cases/standalone/common/view/create.result
- tests/cases/standalone/create/recover_created.result
Additional comments not posted (2)
src/common/catalog/src/consts.rs (2)
96-96
: Comment is consistent with existing comments.The comment indicating the ID for
information_schema.VIEWS
is consistent with the existing comments for other information_schema tables.
97-97
: Constant follows naming conventions and is correctly placed.The constant
INFORMATION_SCHEMA_VIEW_TABLE_ID
with a value of32
follows the naming conventions and is correctly placed within the file.
65c483c
to
e9d83e7
Compare
e9d83e7
to
f1d312e
Compare
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/catalog/src/information_schema.rs (4 hunks)
- src/catalog/src/information_schema/table_names.rs (1 hunks)
- src/catalog/src/information_schema/views.rs (1 hunks)
- src/common/catalog/src/consts.rs (1 hunks)
- tests/cases/standalone/common/information_schema/views.result (1 hunks)
- tests/cases/standalone/common/information_schema/views.sql (1 hunks)
- tests/cases/standalone/common/show/show_databases_tables.result (3 hunks)
- tests/cases/standalone/common/system/information_schema.result (2 hunks)
- tests/cases/standalone/common/view/create.result (1 hunks)
Files skipped from review as they are similar to previous changes (9)
- src/catalog/src/information_schema.rs
- src/catalog/src/information_schema/table_names.rs
- src/catalog/src/information_schema/views.rs
- src/common/catalog/src/consts.rs
- tests/cases/standalone/common/information_schema/views.result
- tests/cases/standalone/common/information_schema/views.sql
- tests/cases/standalone/common/show/show_databases_tables.result
- tests/cases/standalone/common/system/information_schema.result
- tests/cases/standalone/common/view/create.result
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/catalog/src/information_schema.rs (4 hunks)
- src/catalog/src/information_schema/table_names.rs (1 hunks)
- src/catalog/src/information_schema/views.rs (1 hunks)
- src/common/catalog/src/consts.rs (1 hunks)
- tests/cases/standalone/common/information_schema/views.result (1 hunks)
- tests/cases/standalone/common/information_schema/views.sql (1 hunks)
- tests/cases/standalone/common/show/show_databases_tables.result (3 hunks)
- tests/cases/standalone/common/system/information_schema.result (2 hunks)
- tests/cases/standalone/common/view/create.result (1 hunks)
Files skipped from review as they are similar to previous changes (9)
- src/catalog/src/information_schema.rs
- src/catalog/src/information_schema/table_names.rs
- src/catalog/src/information_schema/views.rs
- src/common/catalog/src/consts.rs
- tests/cases/standalone/common/information_schema/views.result
- tests/cases/standalone/common/information_schema/views.sql
- tests/cases/standalone/common/show/show_databases_tables.result
- tests/cases/standalone/common/system/information_schema.result
- tests/cases/standalone/common/view/create.result
f1d312e
to
bdc2927
Compare
…e provides information about views in databases.
bdc2927
to
1b38b6e
Compare
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/catalog/src/information_schema.rs (4 hunks)
- src/catalog/src/information_schema/table_names.rs (1 hunks)
- src/catalog/src/information_schema/views.rs (1 hunks)
- src/common/catalog/src/consts.rs (1 hunks)
- tests/cases/standalone/common/information_schema/views.result (1 hunks)
- tests/cases/standalone/common/information_schema/views.sql (1 hunks)
- tests/cases/standalone/common/show/show_databases_tables.result (3 hunks)
- tests/cases/standalone/common/system/information_schema.result (2 hunks)
- tests/cases/standalone/common/view/create.result (1 hunks)
Files skipped from review as they are similar to previous changes (9)
- src/catalog/src/information_schema.rs
- src/catalog/src/information_schema/table_names.rs
- src/catalog/src/information_schema/views.rs
- src/common/catalog/src/consts.rs
- tests/cases/standalone/common/information_schema/views.result
- tests/cases/standalone/common/information_schema/views.sql
- tests/cases/standalone/common/show/show_databases_tables.result
- tests/cases/standalone/common/system/information_schema.result
- tests/cases/standalone/common/view/create.result
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
@fengjiachun @sunng87 Please take a look. |
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
@lyang24 Thank you! |
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
#4339
What's changed and what's your intention?
adding information_schema.views table to display views.
Please explain IN DETAIL what the changes are in this PR and why they are needed:
This content is generated by iterate table information from catalog manager and with filter
table_type = VIEW
, and retrieve view definition from table id. A very simple sqlness test is added as well.Checklist
Summary by CodeRabbit
New Features
VIEWS
in the information schema, allowing users to manage and query views within the database.Enhancements
SHOW
queries to include theviews
table and relevant metadata.Tests