Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions crates/iceberg/src/expr/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,16 @@ impl<T: Bind> Bind for UnaryExpression<T> {
}

impl<T> UnaryExpression<T> {
pub(crate) fn new(op: PredicateOperator, term: T) -> Self {
/// Creates a unary expression with the given operator and term.
///
/// # Example
///
/// ```rust
/// use iceberg::expr::{PredicateOperator, Reference, UnaryExpression};
///
/// UnaryExpression::new(PredicateOperator::IsNull, Reference::new("c"));
/// ```
pub fn new(op: PredicateOperator, term: T) -> Self {
debug_assert!(op.is_unary());
Self { op, term }
}
Expand Down Expand Up @@ -171,7 +180,21 @@ impl<T: Debug> Debug for BinaryExpression<T> {
}

impl<T> BinaryExpression<T> {
pub(crate) fn new(op: PredicateOperator, term: T, literal: Datum) -> Self {
/// Creates a binary expression with the given operator, term and literal.
///
/// # Example
///
/// ```rust
/// use iceberg::expr::{BinaryExpression, PredicateOperator, Reference};
/// use iceberg::spec::Datum;
///
/// BinaryExpression::new(
/// PredicateOperator::LessThanOrEq,
/// Reference::new("a"),
/// Datum::int(10),
/// );
/// ```
pub fn new(op: PredicateOperator, term: T, literal: Datum) -> Self {
debug_assert!(op.is_binary());
Self { op, term, literal }
}
Expand Down
Loading