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

feat(meta): dependency check for drop function #19399

Merged
merged 13 commits into from
Nov 21, 2024
Merged

Conversation

stdrc
Copy link
Member

@stdrc stdrc commented Nov 15, 2024

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

What's changed and what's your intention?

This PR introduces dependencies field in CreateMaterializedViewRequest and CreateSinkRequest, and records dependencies upon UDFs uniformly with dependencies upon relations through this field.

Fixes #17263.

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.

Copy link
Member Author

stdrc commented Nov 15, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@stdrc stdrc changed the title change Binder::included_relations() to return reference instead of a clone feat(meta): dependency check for function Nov 15, 2024
@stdrc stdrc changed the title feat(meta): dependency check for function feat(meta): dependency check for drop function Nov 15, 2024
@stdrc stdrc marked this pull request as ready for review November 15, 2024 07:13
@stdrc stdrc marked this pull request as draft November 15, 2024 07:20
@stdrc stdrc marked this pull request as ready for review November 15, 2024 07:46
@graphite-app graphite-app bot requested a review from a team November 15, 2024 08:08
@stdrc stdrc force-pushed the rc/drop-function-dep-check branch from 162de40 to 8323c2d Compare November 15, 2024 08:32
Copy link
Member

@xxchan xxchan left a comment

Choose a reason for hiding this comment

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

Generally LGTM

Comment on lines +302 to 303
// TODO: to be removed, pass all objects uniformly through `dependencies` field instead.
pub fn dependent_relations(&self) -> Vec<u32> {
Copy link
Member

Choose a reason for hiding this comment

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

It seems table.dependent_relations is not set any more. Will it break sth to call this function?

Copy link
Member

Choose a reason for hiding this comment

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

Oh. The caller uses extend

Copy link
Member

Choose a reason for hiding this comment

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

I would be in favor of removing this field together now to avoid mistakes. Can put in an upstack PR and merge them together.

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems table.dependent_relations is not set any more. Will it break sth to call this function?

I merged the result of this method and the new dependencies field to avoid breaking. And now it basically return empty vector for MaterializedView and Sink, and remain the same for Table and Index.

Since this PR is mainly for drop function check, I only changed the behavior of MaterializedView and Sink. Added TODO comments for the remaining ones.

src/meta/src/controller/streaming_job.rs Show resolved Hide resolved
@stdrc stdrc force-pushed the rc/drop-function-dep-check branch from 23e9181 to 42fa721 Compare November 17, 2024 17:21
e2e_test/udf/drop_function.slt Outdated Show resolved Hide resolved
proto/ddl_service.proto Outdated Show resolved Hide resolved
@@ -86,6 +86,8 @@ message CreateSinkRequest {
stream_plan.StreamFragmentGraph fragment_graph = 2;
// It is used to provide a replace plan for the downstream table in `create sink into table` requests.
optional ReplaceTablePlan affected_table_change = 3;
// The list of object IDs that this materialized view depends on.
repeated uint32 dependencies = 4;
Copy link
Member

Choose a reason for hiding this comment

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

Is it accurately direct dependencies? I suppose the meta service can recursively resolve all dependencies.

@@ -104,7 +103,7 @@ impl SinkDesc {
downstream_pk: self.downstream_pk,
distribution_key: self.distribution_key,
owner,
dependent_relations,
dependent_relations: vec![], // TODO(rc): to be deprecated
Copy link
Member

Choose a reason for hiding this comment

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

Are we going to deprecate all dependent_relations fields in different catalogs? Are they referenced anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think these dependent_relations fields are used elsewhere except when creating meta objects. cc @yezizp2012 can you confirm?

Copy link
Member

Choose a reason for hiding this comment

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

IIUC that's the only usage when creating meta objects. Previouly the process of detecting dependency cycles for sink into table relies on it in v1, but that functionality has been transferred to the meta side. However, the code related to this in the FE remains and can be removed for clarity.

Copy link
Member

@yezizp2012 yezizp2012 Nov 19, 2024

Choose a reason for hiding this comment

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

FYI, @shanicky will rise a PR to clean that part.

src/frontend/src/handler/create_mv.rs Show resolved Hide resolved
@stdrc stdrc force-pushed the rc/drop-function-dep-check branch from c0592b3 to 5a4b40b Compare November 19, 2024 06:04
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.

LGTM! Thx for the PR. Please help to unify the behaviors for other relations like index, source as well.
Additionally, following this PR, we can provide syntax support for granting and revoking function privileges to enhance user experience.

@@ -241,6 +242,7 @@ impl DdlService for DdlServiceImpl {
fragment_graph,
CreateType::Foreground,
None,
HashSet::new(), // TODO(rc): pass dependencies through this field instead of `PbSource`
Copy link
Member

Choose a reason for hiding this comment

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

👍 connection and secret are handled in separated fields now and can be unified into dependencies. This also applies to the connection for the sink.

Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Richard Chien <[email protected]>
stdrc and others added 5 commits November 21, 2024 15:48
Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Richard Chien <[email protected]>
@stdrc stdrc force-pushed the rc/drop-function-dep-check branch from 5a4b40b to 502aa21 Compare November 21, 2024 12:52
@stdrc stdrc enabled auto-merge November 21, 2024 12:58
@stdrc stdrc added this pull request to the merge queue Nov 21, 2024
@graphite-app graphite-app bot requested a review from a team November 21, 2024 13:37
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Nov 21, 2024
@stdrc stdrc added this pull request to the merge queue Nov 21, 2024
Merged via the queue into main with commit 37e108c Nov 21, 2024
34 of 35 checks passed
@stdrc stdrc deleted the rc/drop-function-dep-check branch November 21, 2024 15:35
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.

udf: drop function should perform dependency check
4 participants