Xuanwo commented on code in PR #169: URL: https://github.com/apache/iceberg-rust/pull/169#discussion_r1505328726
########## crates/iceberg/src/expr/mod.rs: ########## @@ -18,25 +18,126 @@ //! This module contains expressions. mod term; + +use std::fmt::{Display, Formatter}; + pub use term::*; mod predicate; pub use predicate::*; /// Predicate operators used in expressions. #[allow(missing_docs)] +#[derive(Debug, Clone, Copy)] +#[repr(u16)] pub enum PredicateOperator { - IsNull, - NotNull, - IsNan, - NotNan, - LessThan, - LessThanOrEq, - GreaterThan, - GreaterThanOrEq, - Eq, - NotEq, - In, - NotIn, - StartsWith, - NotStartsWith, + // Unary operators + IsNull = 101, Review Comment: How about adding a link for the meaning of those number? ########## crates/iceberg/src/spec/values.rs: ########## @@ -31,12 +32,20 @@ use serde_bytes::ByteBuf; use serde_json::{Map as JsonMap, Number, Value as JsonValue}; use uuid::Uuid; -use crate::{Error, ErrorKind}; +use crate::{ensure_data_valid, Error, ErrorKind}; use super::datatypes::{PrimitiveType, Type}; +use crate::spec::values::date::{date_from_naive_date, days_to_date, unix_epoch}; +use crate::spec::values::time::microseconds_to_time; +use crate::spec::values::timestamp::microseconds_to_datetime; +use crate::spec::values::timestamptz::microseconds_to_datetimetz; +use crate::spec::MAX_DECIMAL_PRECISION; pub use _serde::RawLiteral; +/// Maximum value for [`PrimitiveType::Time`] type. +const MAX_TIME_VALUE: i64 = + 23 * 60 * 60 * 1_000_000i64 + 59 * 60 * 1_000_000i64 + 59 * 1_000_000i64 + 999_999i64; Review Comment: The const is a bit confusing for the first look. How about `24 * 60 * 60 * 1_000_000i64 - 1`? ########## crates/iceberg/src/expr/term.rs: ########## @@ -17,21 +17,91 @@ //! Term definition. -use crate::spec::NestedFieldRef; +use crate::expr::{BinaryExpression, Predicate, PredicateOperator}; +use crate::spec::{Datum, NestedField, NestedFieldRef}; +use std::fmt::{Display, Formatter}; /// Unbound term before binding to a schema. -pub type UnboundTerm = UnboundReference; +pub type Term = Reference; /// A named reference in an unbound expression. /// For example, `a` in `a > 10`. -pub struct UnboundReference { +#[derive(Debug, Clone)] +pub struct Reference { name: String, } +impl Reference { + /// Create a new unbound reference. + pub fn new(name: impl ToString) -> Self { Review Comment: `ToString` always need an extra alloc, we can use `impl Into<String>` instead. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org