-
Notifications
You must be signed in to change notification settings - Fork 594
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(optimizer): type-safe plan base with compile-time convention check #13000
Conversation
c374187
to
93185e8
Compare
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
93185e8
to
e6c55fe
Compare
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
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
use super::utils::impl_distill_by_unit; | ||
use super::{ | ||
generic, ExprRewritable, PlanBase, PlanRef, PlanTreeNodeUnary, ToBatchPb, ToDistributedBatch, | ||
}; | ||
use crate::optimizer::plan_node::generic::PhysicalPlanRef; |
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.
Redundant import
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.
Will take a look later. Compile error rather than runtime panic sounds pretty cool!
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.
Rest LGTM!
impl<P> AnyPlanNodeMeta for P | ||
where | ||
P: PlanNodeMeta, | ||
{ | ||
fn node_type(&self) -> PlanNodeType { | ||
P::NODE_TYPE | ||
} | ||
|
||
fn plan_base(&self) -> PlanBaseRef<'_> { | ||
PlanNodeMeta::plan_base_ref(self) | ||
} | ||
|
||
fn convention(&self) -> Convention { | ||
P::Convention::value() | ||
} | ||
} | ||
} |
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.
I am wondering whether we can expose a different property fetching interface for PlanRef
to let developers know which (logical, batch or stream) properties they want to access explicitly. For example, plan_ref.batch_property().unwrap()
to access the batch property with an explicit unwrap.
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.
Because accessing a property in PlanRef
could panic underlying potentially might require a very high code coverage rate to ensure them work well. Exposing an Option
or Result
can help developers realize what are they doing right now and the potential result. At least we can throw an Error instead of panicking the whole system.
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.
let developers know which (logical, batch or stream) properties they want to access explicitly
Yeah, this is a good point. Several reasons for not doing this now:
- I want to make the changes minimal in this PR.
- We may first further explore if it's possible to constrain
PlanRef
to something likePlanRef<Convention>
, to reduce the usages of accessing on the convention-erased plan.
Because accessing a property in
PlanRef
could panic underlying potentially might require a very high code coverage rate to ensure them work well.
Agree.
At least we can throw an Error instead of panicking the whole system.
That's not a big problem. We always catch the panic when handling a SQL statement, so panicking will not affect other active sessions.
|
GitGuardian id | Secret | Commit | Filename | |
---|---|---|---|---|
7648795 | Generic CLI Secret | b57e395 | integration_tests/iceberg-cdc/run_test.sh | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Our GitHub checks need improvements? Share your feedbacks!
Codecov Report
@@ Coverage Diff @@
## main #13000 +/- ##
==========================================
- Coverage 68.33% 68.31% -0.03%
==========================================
Files 1496 1498 +2
Lines 252058 252102 +44
==========================================
- Hits 172253 172217 -36
- Misses 79805 79885 +80
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 5 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Signed-off-by: Bugen Zhao [email protected]
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Reviewing the following files should be sufficient:
Follow-up of #12980. This PR further makes
PlanBase
over a genericConventionMarker
.risingwave/src/frontend/src/optimizer/plan_node/plan_base.rs
Line 112 in 35172ec
As the result, the
base
field in the plan node struct will specify the correspondingConventionMarker
.risingwave/src/frontend/src/optimizer/plan_node/stream_hash_agg.rs
Lines 30 to 32 in 35172ec
Any attempts to access fields with a mismatched convention (like
logical_agg.emit_on_window_close()
orstream_hash_agg.plan_base().order()
) will be a compile error.Accessing the
PlanBase
throughPlanNodeMeta
trait will now also get a type with specific convention, which makes the trait not object-safe anymore.risingwave/src/frontend/src/optimizer/plan_node/mod.rs
Lines 95 to 102 in 35172ec
However, there're still a lot of places where
PlanRef
are directly worked on. To still allow erasing the type of a plan node, the originalPlanNodeMeta
turns intoAnyPlanNodeMeta
and is automatically implemented.risingwave/src/frontend/src/optimizer/plan_node/mod.rs
Lines 115 to 140 in 35172ec
Future work may further explore reducing the usage of type-erased
PlanRef
. For example, we can at least constrain the convention for it.Checklist
./risedev check
(or alias,./risedev c
)Documentation
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.
Signed-off-by: Bugen Zhao