risingwave_frontend/optimizer/plan_node/generic/
mod.rs1use std::borrow::Cow;
19use std::hash::Hash;
20
21use pretty_xmlish::XmlNode;
22use risingwave_common::catalog::Schema;
23
24use super::{EqJoinPredicate, PlanNodeId, stream};
25use crate::optimizer::optimizer_context::OptimizerContextRef;
26use crate::optimizer::property::{Distribution, FunctionalDependencySet};
27
28pub mod dynamic_filter;
29pub use dynamic_filter::*;
30mod hop_window;
31pub use hop_window::*;
32mod agg;
33pub use agg::*;
34mod project_set;
35pub use project_set::*;
36mod join;
37pub use join::*;
38mod project;
39pub use project::*;
40mod filter;
41pub use filter::*;
42mod expand;
43pub use expand::*;
44mod source;
45pub use source::*;
46mod table_scan;
47pub use table_scan::*;
48mod sys_scan;
49pub use sys_scan::*;
50mod log_scan;
51pub use log_scan::*;
52
53mod cdc_scan;
54pub use cdc_scan::*;
55
56mod union;
57pub use union::*;
58mod top_n;
59pub use top_n::*;
60mod share;
61pub use share::*;
62mod dedup;
63pub use dedup::*;
64mod intersect;
65pub use intersect::*;
66mod over_window;
67pub use over_window::*;
68mod except;
69pub use except::*;
70mod update;
71pub use update::*;
72mod delete;
73pub use delete::*;
74mod insert;
75pub use insert::*;
76mod limit;
77pub use limit::*;
78mod max_one_row;
79pub use max_one_row::*;
80mod cte_ref;
81pub use cte_ref::*;
82mod recursive_union;
83pub use recursive_union::*;
84mod changelog;
85pub use changelog::*;
86mod now;
87pub use now::*;
88
89mod file_scan;
90pub use file_scan::*;
91
92mod postgres_query;
93pub use postgres_query::*;
94
95mod mysql_query;
96pub use mysql_query::*;
97
98pub trait DistillUnit {
99 fn distill_with_name<'a>(&self, name: impl Into<Cow<'a, str>>) -> XmlNode<'a>;
100}
101
102macro_rules! impl_distill_unit_from_fields {
103 ($name:ident, $bound:path) => {
104 use std::borrow::Cow;
105
106 use pretty_xmlish::XmlNode;
107 use $crate::optimizer::plan_node::generic::DistillUnit;
108 impl<PlanRef: $bound> DistillUnit for $name<PlanRef> {
109 fn distill_with_name<'a>(&self, name: impl Into<Cow<'a, str>>) -> XmlNode<'a> {
110 XmlNode::simple_record(name, self.fields_pretty(), vec![])
111 }
112 }
113 };
114}
115pub(super) use impl_distill_unit_from_fields;
116
117#[auto_impl::auto_impl(&)]
118pub trait GenericPlanRef: Eq + Hash {
119 fn id(&self) -> PlanNodeId;
120 fn schema(&self) -> &Schema;
121 fn stream_key(&self) -> Option<&[usize]>;
122 fn functional_dependency(&self) -> &FunctionalDependencySet;
123 fn ctx(&self) -> OptimizerContextRef;
124}
125
126#[auto_impl::auto_impl(&)]
127pub trait PhysicalPlanRef: GenericPlanRef {
128 fn distribution(&self) -> &Distribution;
129}
130
131pub trait GenericPlanNode {
132 fn functional_dependency(&self) -> FunctionalDependencySet;
133 fn schema(&self) -> Schema;
134 fn stream_key(&self) -> Option<Vec<usize>>;
135 fn ctx(&self) -> OptimizerContextRef;
136}