Skip to content

Commit

Permalink
feat: add BoundPredicateEvaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
sdd committed Apr 4, 2024
1 parent 301a0af commit 05e6a54
Show file tree
Hide file tree
Showing 4 changed files with 392 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/iceberg/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
//! This module contains expressions.

mod term;

use std::fmt::{Display, Formatter};

pub use term::*;
mod predicate;
pub(crate) mod visitors;
pub use predicate::*;

use crate::spec::SchemaRef;
pub use predicate::*;
use std::fmt::{Display, Formatter};

/// Predicate operators used in expressions.
///
Expand Down
32 changes: 32 additions & 0 deletions crates/iceberg/src/expr/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ impl<T> UnaryExpression<T> {
debug_assert!(op.is_unary());
Self { op, term }
}

pub(crate) fn term(&self) -> &T {
&self.term
}

pub(crate) fn op(&self) -> &PredicateOperator {
&self.op
}
}

/// Binary predicate, for example, `a > 10`.
Expand Down Expand Up @@ -144,6 +152,18 @@ impl<T> BinaryExpression<T> {
debug_assert!(op.is_binary());
Self { op, term, literal }
}

pub(crate) fn term(&self) -> &T {
&self.term
}

pub(crate) fn op(&self) -> &PredicateOperator {
&self.op
}

pub(crate) fn literal(&self) -> &Datum {
&self.literal
}
}

impl<T: Display> Display for BinaryExpression<T> {
Expand Down Expand Up @@ -191,6 +211,18 @@ impl<T> SetExpression<T> {
debug_assert!(op.is_set());
Self { op, term, literals }
}

pub(crate) fn term(&self) -> &T {
&self.term
}

pub(crate) fn op(&self) -> &PredicateOperator {
&self.op
}

pub(crate) fn literals(&self) -> &FnvHashSet<Datum> {
&self.literals
}
}

impl<T: Bind> Bind for SetExpression<T> {
Expand Down

0 comments on commit 05e6a54

Please sign in to comment.