Skip to content

Commit

Permalink
Fix name of op
Browse files Browse the repository at this point in the history
  • Loading branch information
liurenjie1024 committed Feb 28, 2024
1 parent e22c502 commit 9b83e4c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
40 changes: 20 additions & 20 deletions crates/iceberg/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ impl PredicateOperator {
///
/// ```rust
/// use iceberg::expr::PredicateOperator;
/// assert!(PredicateOperator::IsNull.unary());
/// assert!(PredicateOperator::IsNull.is_unary());
/// ```
pub fn unary(self) -> bool {
pub fn is_unary(self) -> bool {
(self as u16) < (PredicateOperator::LessThan as u16)
}

Expand All @@ -91,9 +91,9 @@ impl PredicateOperator {
///
/// ```rust
/// use iceberg::expr::PredicateOperator;
/// assert!(PredicateOperator::LessThan.binary());
/// assert!(PredicateOperator::LessThan.is_binary());
/// ```
pub fn binary(self) -> bool {
pub fn is_binary(self) -> bool {
((self as u16) > (PredicateOperator::NotNan as u16))
&& ((self as u16) < (PredicateOperator::In as u16))
}
Expand All @@ -104,9 +104,9 @@ impl PredicateOperator {
///
/// ```rust
/// use iceberg::expr::PredicateOperator;
/// assert!(PredicateOperator::In.set());
/// assert!(PredicateOperator::In.is_set());
/// ```
pub fn set(self) -> bool {
pub fn is_set(self) -> bool {
(self as u16) > (PredicateOperator::NotStartsWith as u16)
}
}
Expand All @@ -117,27 +117,27 @@ mod tests {

#[test]
fn test_unary() {
assert!(PredicateOperator::IsNull.unary());
assert!(PredicateOperator::NotNull.unary());
assert!(PredicateOperator::IsNan.unary());
assert!(PredicateOperator::NotNan.unary());
assert!(PredicateOperator::IsNull.is_unary());
assert!(PredicateOperator::NotNull.is_unary());
assert!(PredicateOperator::IsNan.is_unary());
assert!(PredicateOperator::NotNan.is_unary());
}

#[test]
fn test_binary() {
assert!(PredicateOperator::LessThan.binary());
assert!(PredicateOperator::LessThanOrEq.binary());
assert!(PredicateOperator::GreaterThan.binary());
assert!(PredicateOperator::GreaterThanOrEq.binary());
assert!(PredicateOperator::Eq.binary());
assert!(PredicateOperator::NotEq.binary());
assert!(PredicateOperator::StartsWith.binary());
assert!(PredicateOperator::NotStartsWith.binary());
assert!(PredicateOperator::LessThan.is_binary());
assert!(PredicateOperator::LessThanOrEq.is_binary());
assert!(PredicateOperator::GreaterThan.is_binary());
assert!(PredicateOperator::GreaterThanOrEq.is_binary());
assert!(PredicateOperator::Eq.is_binary());
assert!(PredicateOperator::NotEq.is_binary());
assert!(PredicateOperator::StartsWith.is_binary());
assert!(PredicateOperator::NotStartsWith.is_binary());
}

#[test]
fn test_set() {
assert!(PredicateOperator::In.set());
assert!(PredicateOperator::NotIn.set());
assert!(PredicateOperator::In.is_set());
assert!(PredicateOperator::NotIn.is_set());
}
}
4 changes: 2 additions & 2 deletions crates/iceberg/src/expr/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<T: Display> Display for UnaryExpression<T> {

impl<T> UnaryExpression<T> {
pub(crate) fn new(op: PredicateOperator, term: T) -> Self {
debug_assert!(op.unary());
debug_assert!(op.is_unary());
Self { op, term }
}
}
Expand All @@ -105,7 +105,7 @@ impl<T: Debug> Debug for BinaryExpression<T> {

impl<T> BinaryExpression<T> {
pub(crate) fn new(op: PredicateOperator, term: T, literal: Datum) -> Self {
debug_assert!(op.binary());
debug_assert!(op.is_binary());
Self { op, term, literal }
}
}
Expand Down

0 comments on commit 9b83e4c

Please sign in to comment.