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

Adds information_schema.views #4339

Closed
killme2008 opened this issue Jul 10, 2024 · 4 comments
Closed

Adds information_schema.views #4339

killme2008 opened this issue Jul 10, 2024 · 4 comments
Assignees
Labels
C-enhancement Category Enhancements good first issue Good for newcomers help wanted Extra attention is needed

Comments

@killme2008
Copy link
Contributor

killme2008 commented Jul 10, 2024

What type of enhancement is this?

API improvement, Configuration, User experience

What does the enhancement do?

Part of #2931 #3729

Implements information_schema.views to provide information about views in databases.

Refer to https://dev.mysql.com/doc/refman/8.4/en/information-schema-views-table.html

Implementation challenges

The implement detail notes:

  1. Refer to information_schema.tables for example to implement the views:
  2. Register it to information_schema:
  3. Adds unit tests and sqlness tests https://github.com/GreptimeTeam/greptimedb/tree/main/tests/cases/standalone/common/information_schema
@killme2008 killme2008 added C-enhancement Category Enhancements good first issue Good for newcomers help wanted Extra attention is needed labels Jul 10, 2024
@lyang24
Copy link
Collaborator

lyang24 commented Jul 10, 2024

Hi, I would like to work on this. Do we store the view definition statements somewhere? i checked ViewInfoManager it stores the raw plan logical info as bytes we probably don't want to display that to users?

This is what i found on mysql example link
+----------------------------------+
| VIEW_DEFINITION |
+----------------------------------+
| select concat('a','b') AS col1 |
+----------------------------------+

@killme2008
Copy link
Contributor Author

@lyang24 Great, thanks a lot.

There is a field definition which is the view definition:

pub definition: String,

Retrieving the view_info by ViewInfoCache:

pub type ViewInfoCache = CacheContainer<TableId, Arc<ViewInfoValue>, CacheIdent>;

ViewInfoCache can be retrieved by:

pub fn view_info_cache(&self) -> Result<ViewInfoCacheRef> {

@killme2008
Copy link
Contributor Author

One way to obtain the ViewInfoCache is by incorporating a function similar to the following:

pub fn table_meta_manager(

During runtime, the catalog_manager is consistently KvBackendCatalogManager.

@killme2008
Copy link
Contributor Author

Another example to retrieve view info in catalog crate:

let view_info = catalog_manager
.view_info_cache()?
.get(table.table_info().ident.table_id)
.await
.context(GetViewCacheSnafu)?
.context(ViewInfoNotFoundSnafu {
name: &table.table_info().name,
})?;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category Enhancements good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants