Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: day transform compute #796

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion bindings/python/tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_month_transform():
def test_day_transform():
arr = pa.array([date(1970, 1, 1), date(2000, 4, 1)])
result = transform.day(arr)
expected = pa.array([0, 11048], type=pa.int32())
expected = pa.array([0, 11048], type=pa.date32())
assert result == expected


Expand Down
2 changes: 1 addition & 1 deletion crates/iceberg/src/expr/visitors/inclusive_projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ mod tests {
let mut inclusive_projection = InclusiveProjection::new(arc_partition_spec);
let result = inclusive_projection.project(&bound_predicate).unwrap();

let expected = "day <= 19722".to_string();
let expected = "day <= 2023-12-31".to_string();

assert_eq!(result.to_string(), expected);
}
Expand Down
20 changes: 18 additions & 2 deletions crates/iceberg/src/spec/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,30 @@ impl Transform {
| PredicateOperator::LessThanOrEq
| PredicateOperator::In => {
if v < 0 {
return Some(AdjustedProjection::Single(Datum::int(v + 1)));
// # TODO
// An ugly hack to fix. Refine the increment and decrement logic later.
match self {
Transform::Day => {
return Some(AdjustedProjection::Single(Datum::date(v + 1)))
}
_ => {
return Some(AdjustedProjection::Single(Datum::int(v + 1)));
}
}
};
}
PredicateOperator::Eq => {
if v < 0 {
let new_set = FnvHashSet::from_iter(vec![
transformed.to_owned(),
Datum::int(v + 1),
// # TODO
// An ugly hack to fix. Refine the increment and decrement logic later.
{
match self {
Transform::Day => Datum::date(v + 1),
_ => Datum::int(v + 1),
}
},
]);
return Some(AdjustedProjection::Set(new_set));
}
Expand Down
Loading
Loading