omerhadari commented on code in PR #945:
URL: https://github.com/apache/iceberg-rust/pull/945#discussion_r1954101136
##########
crates/integrations/datafusion/src/physical_plan/expr_to_predicate.rs:
##########
@@ -119,7 +122,53 @@ fn to_iceberg_predicate(expr: &Expr) -> TransformedResult {
_ => TransformedResult::NotTransformed,
}
}
- Expr::Cast(c) => to_iceberg_predicate(&c.expr),
+ Expr::Cast(c) => {
+ if DataType::Date32 == c.data_type || DataType::Date64 ==
c.data_type {
+ match c.expr.as_ref() {
+ Expr::Literal(ScalarValue::Utf8(Some(literal))) => {
+ let date = literal.split('T').next();
+ if let Some(date) = date {
+ return
TransformedResult::Literal(Datum::string(date));
+ }
+ }
+ _ => return TransformedResult::NotTransformed,
+ }
+ }
+ to_iceberg_predicate(&c.expr)
+ }
+ Expr::ScalarFunction(func) => {
+ if func
+ .func
+ .inner()
+ .as_any()
+ .downcast_ref::<ToTimestampFunc>()
Review Comment:
Let's continue the discussion in your other comment, to have it in one place
:)
##########
crates/integrations/datafusion/src/physical_plan/expr_to_predicate.rs:
##########
@@ -403,4 +452,55 @@ mod tests {
Reference::new("ts").greater_than_or_equal_to(Datum::string("2023-01-05T00:00:00"));
assert_eq!(predicate, expected_predicate);
}
+
+ #[test]
+ fn test_to_timestamp_comparison_creates_predicate() {
+ 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);
+ }
Review Comment:
removed
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]