From dacfabd44ba52ad0511518d336330ed07942bbc1 Mon Sep 17 00:00:00 2001 From: Noel Kwan Date: Thu, 14 Nov 2024 10:56:32 +0800 Subject: [PATCH] panic if doing unsupported ops --- .../optimizer/plan_node/batch_iceberg_scan.rs | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/optimizer/plan_node/batch_iceberg_scan.rs b/src/frontend/src/optimizer/plan_node/batch_iceberg_scan.rs index 00f81df2b943c..815b711faa296 100644 --- a/src/frontend/src/optimizer/plan_node/batch_iceberg_scan.rs +++ b/src/frontend/src/optimizer/plan_node/batch_iceberg_scan.rs @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +use std::hash::{Hash, Hasher}; use std::rc::Rc; -use educe::Educe; use iceberg::expr::Predicate as IcebergPredicate; use pretty_xmlish::{Pretty, XmlNode}; use risingwave_pb::batch_plan::plan_node::NodeBody; @@ -31,15 +31,38 @@ use crate::error::Result; use crate::optimizer::plan_node::expr_visitable::ExprVisitable; use crate::optimizer::property::{Distribution, Order}; -#[derive(Educe, Debug, Clone, PartialEq)] -#[educe(Eq, Hash)] +#[derive(Debug, Clone)] pub struct BatchIcebergScan { pub base: PlanBase, pub core: generic::Source, - #[educe(Hash(ignore))] pub predicate: IcebergPredicate, } +impl PartialEq for BatchIcebergScan { + fn eq(&self, other: &Self) -> bool { + if self.predicate == IcebergPredicate::AlwaysTrue + && other.predicate == IcebergPredicate::AlwaysTrue + { + self.base == other.base && self.core == other.core + } else { + panic!("BatchIcebergScan::eq: comparing non-AlwaysTrue predicates is not supported") + } + } +} + +impl Eq for BatchIcebergScan {} + +impl Hash for BatchIcebergScan { + fn hash(&self, state: &mut H) { + if self.predicate != IcebergPredicate::AlwaysTrue { + panic!("BatchIcebergScan::hash: hashing non-AlwaysTrue predicates is not supported") + } else { + self.base.hash(state); + self.core.hash(state); + } + } +} + impl BatchIcebergScan { pub fn new(core: generic::Source) -> Self { let base = PlanBase::new_batch_with_core(