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

refactor(catalog): refactor system catalog using proc macro #14947

Merged
merged 8 commits into from
Feb 18, 2024

Conversation

wangrunji0408
Copy link
Contributor

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

resolve #13433 following #14934

This PR refactors system catalog using the proc macro proposed in #13433, but in a slightly different way.

Instead of #[derive(Catalog)], this PR introduces #[system_catalog] macro (proposed by #13433 (comment)), which can be put on a function to define system table, or put on a struct to define system view.

// define a dummy system view
#[system_catalog(view, "pg_catalog.pg_am")]
#[derive(Fields)]
struct PgAmColumn { ... }

// define a system view with SQL query
#[system_catalog(view, "information_schema.tables", "SELECT ...")]
#[derive(Fields)]
struct Table { ... }

// define a system table
#[system_catalog(table, "rw_catalog.rw_types")]
fn read_rw_types(reader: &SysCatalogReaderImpl) -> Result<Vec<RwType>> { ... }

Similar to #[function], these tables & views will be automatically registered into the global SYS_CATALOGS.

Table/view ids are generated in lexicographic order of their name. Thus ids are unstable across different versions. Not sure if this is safe. Or we should assign static ids to them?

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@BugenZhao
Copy link
Member

Wow, this is a huge project. I'm curious how did you do such refactor efficiently? 😄

@stdrc stdrc self-requested a review February 2, 2024 04:55
@wangrunji0408
Copy link
Contributor Author

Wow, this is a huge project. I'm curious how did you do such refactor efficiently? 😄

Thanks to Github Copilot. 😄

WX20240202-142538@2x

Signed-off-by: Runji Wang <[email protected]>
Base automatically changed from wrj/derive-fields to main February 5, 2024 11:19
@wangrunji0408
Copy link
Contributor Author

Holy

image

Copy link
Member

@yezizp2012 yezizp2012 left a comment

Choose a reason for hiding this comment

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

LSTM!! rubber stamp for all writes on system catalog files.

src/common/src/types/fields.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@TennyZhuang TennyZhuang left a comment

Choose a reason for hiding this comment

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

Approved as lock team member.

Signed-off-by: Runji Wang <[email protected]>
@wangrunji0408 wangrunji0408 added this pull request to the merge queue Feb 18, 2024
Merged via the queue into main with commit 16ae65b Feb 18, 2024
27 of 28 checks passed
@wangrunji0408 wangrunji0408 deleted the wrj/catalog-macro branch February 18, 2024 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: #[Catalog] derive proc macro
4 participants