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
3 changes: 3 additions & 0 deletions crates/iceberg/src/spec/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3569,6 +3569,9 @@ mod tests {
let value = Datum::timestamp_from_str("2021-08-01T01:09:00.0899").unwrap();
assert_eq!(&format!("{value}"), "2021-08-01 01:09:00.089900");

let value = Datum::timestamp_from_str("2023-01-06T00:00:00").unwrap();
assert_eq!(&format!("{value}"), "2023-01-06 00:00:00");

let value = Datum::timestamp_from_str("2021-08-01T01:09:00.0899+0800");
assert!(value.is_err(), "Parse timestamp with timezone should fail!");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ fn to_iceberg_predicate(expr: &Expr) -> TransformedResult {
_ => TransformedResult::NotTransformed,
}
}
Expr::Cast(c) => to_iceberg_predicate(&c.expr),
_ => TransformedResult::NotTransformed,
}
}
Expand Down Expand Up @@ -211,7 +212,7 @@ fn scalar_value_to_datum(value: &ScalarValue) -> Option<Datum> {

#[cfg(test)]
mod tests {
use datafusion::arrow::datatypes::{DataType, Field, Schema};
use datafusion::arrow::datatypes::{DataType, Field, Schema, TimeUnit};
use datafusion::common::DFSchema;
use datafusion::logical_expr::utils::split_conjunction;
use datafusion::prelude::{Expr, SessionContext};
Expand All @@ -224,6 +225,7 @@ mod tests {
let arrow_schema = Schema::new(vec![
Field::new("foo", DataType::Int32, true),
Field::new("bar", DataType::Utf8, true),
Field::new("ts", DataType::Timestamp(TimeUnit::Second, None), true),
]);
DFSchema::try_from_qualified_schema("my_table", &arrow_schema).unwrap()
}
Expand Down Expand Up @@ -392,4 +394,13 @@ mod tests {
let expected_predicate = Reference::new("foo").less_than(Datum::long(0));
assert_eq!(predicate, expected_predicate);
}

#[test]
fn test_predicate_conversion_with_cast() {
let sql = "ts >= timestamp '2023-01-05T00:00:00'";
let predicate = convert_to_iceberg_predicate(sql).unwrap();
let expected_predicate =
Reference::new("ts").greater_than_or_equal_to(Datum::string("2023-01-05T00:00:00"));
assert_eq!(predicate, expected_predicate);
}
}
Loading