Repository navigation
Conversation
7aa4ef4 to
50703ec
Compare
| // Before date promotion, bounds were stored as days since the epoch. | ||
| const auto units_per_day = type_id == TypeId::kTimestamp ? internal::kMicrosPerDay | ||
| : internal::kNanosPerDay; | ||
| ICEBERG_ASSIGN_OR_RAISE(auto timestamp, MultiplyExact(value, units_per_day)); |
There was a problem hiding this comment.
A file containing only epoch day 0 can have a valid loose date upper bound of day 106752. After promotion to timestamp_ns, the row is still representable, but MultiplyExact rejects the upper bound and aborts planning. Could we treat this bound as unknown while retaining overflow errors for actual row values?
There was a problem hiding this comment.
Bounds are now decoded through an internal DeserializeBound() that returns
std::nullopt when a four-byte date bound does not fit the promoted type.
Callers treat it as a missing bound, so planning continues and the other bound
stays usable. Literal::Deserialize() still returns an error on overflow, and
malformed bounds are still propagated as errors.
e689e15 to
953a517
Compare
Read four-byte bounds for timestamp and timestamp_ns as epoch days. Treat date bounds outside the target range as unknown when evaluating file and manifest statistics, while propagating malformed bounds as errors.
3306bcc to
4bb3a9f
Compare
Require all four bounds for equality delete range checks. Keep partition summary evaluation on its existing path and cover timestamp source bounds in transformed aggregates and inclusive file pruning.
| auto primitive_type = internal::checked_pointer_cast<PrimitiveType>(type); | ||
| if (data_file_.upper_bounds.contains(id)) { | ||
| return Literal::Deserialize(data_file_.upper_bounds.at(id), primitive_type); | ||
| return internal::DeserializeBound(data_file_.upper_bounds.at(id), primitive_type); |
There was a problem hiding this comment.
A date upper bound of 89,478,486 days fits in timestamp micros, but its hour count wraps to a negative int32. This makes hour(ts) >= 0 prune a file containing epoch. Skip hour-based pruning when the transformed range can wrap.
There was a problem hiding this comment.
Good catch, I reproduced the same issue with ordinary 8-byte timestamp bounds. The upper bound wraps to a negative hour, so hour(ts) >= 0 can skip a file containing the epoch. I opened #1176 to fix this for both timestamp and timestamptz.
| return bound; | ||
| } | ||
| SingleValueStructLike data(std::move(*bound)); | ||
| return term.Evaluate(data); |
There was a problem hiding this comment.
The later of the two timestamp examples in Appendix B maps to bucket 0, while the earlier one maps to bucket 1. Taking the bucket of the upper bound returns the wrong MAX. Require an order-preserving transform before deriving an extremum from one endpoint.
| ICEBERG_UNWRAP_OR_FAIL(auto upper, | ||
| Literal::Timestamp(2 * internal::kMicrosPerDay + 1).Serialize()); | ||
| DataFile file{.record_count = 1, .upper_bounds = {{1, upper}}}; | ||
| EXPECT_TRUE(max_day->HasValue(file)); |
There was a problem hiding this comment.
A file containing only day 1 may have an upper bound on day 2. What guarantees this bound is exact? Please cover that case and fall back when the metrics cannot establish the MAX.
There was a problem hiding this comment.
Nothing in DataFile says whether a bound is exact, so the aggregate cannot
detect this case. This is the same contract as Java's MaxAggregate, which
returns the bound as is and leaves it to the caller to decide whether bounds can
be trusted. This PR does not change that; the test only checks that the bound is
decoded with the source column type.
| // https://iceberg.apache.org/spec/#schema-evolution | ||
| auto timestamp = PromoteDate(value, type_id); | ||
| if (!timestamp) { | ||
| return InvalidArgument("Date {} is outside the range of {}", value, |
There was a problem hiding this comment.
ManifestEvaluator still reaches this error for partition summaries. An old identity-date manifest may contain day 1 with a loose upper bound of day 106752. After promotion to timestamp_ns, keep that manifest for ts > epoch and distinguish an unrepresentable bound from an all-null summary.
There was a problem hiding this comment.
I think promoting an identity-partitioned date to timestamp_ns is disallowed because it changes the partition value. The day, month, and year transforms keep the same partition values across the promotion.
After a
datecolumn is promoted totimestamportimestamp_ns, existing fileskeep four-byte bounds in days. Per the spec's schema evolution rules, decode them
as midnight in the target unit instead of reading the day count as micros/nanos.
Without this, inclusive pruning can drop files that contain matching rows, and
strict evaluation can report that all rows match when they do not.
Changes:
Conversions::FromBytesscales four-byte bounds fortimestampandtimestamp_ns, and returns an error on overflow.time,timestamptz, andtimestamptz_nsare nowrejected; the spec does not allow date promotion to those types.
internal
DeserializeBoundthat treats an out-of-range date bound as unknownrather than failing planning. Malformed bounds are still errors.
type-changing transforms such as
max(day(ts)).Related to #1156 and #1153.