rich7420 commented on code in PR #3537:
URL: https://github.com/apache/iceberg-rust/pull/3537#discussion_r4775323940
##########
crates/iceberg/src/writer/file_writer/parquet_writer.rs:
##########
@@ -371,29 +385,44 @@ impl MinMaxColAggregator {
));
};
- if value.min_is_exact() {
- let Some(min_datum) = get_parquet_stat_min_as_datum(&ty, value)?
else {
- return Err(Error::new(
- ErrorKind::Unexpected,
- format!("Statistics {value} is not match with field type
{ty}."),
- ));
+ // A truncated string or binary min is a prefix of the min, and a
+ // truncated max is a prefix with its last character incremented, so
+ // both are still bounds. A truncated fixed value has the wrong length.
+ let truncated_is_bound = matches!(ty, PrimitiveType::String |
PrimitiveType::Binary);
Review Comment:
Should `truncated_is_bound` also check `!value.is_min_max_deprecated()`?
Legacy Parquet `BYTE_ARRAY` `min` and `max` used signed byte ordering, so
accepting them for `String` or `Binary` can write inverted bounds on non-ASCII
values.
##########
crates/iceberg/src/writer/file_writer/parquet_writer.rs:
##########
@@ -486,6 +521,8 @@ impl ParquetWriter {
}
min_max_agg.update(field_id, statistics)?;
+ } else {
+ min_max_agg.drop_bounds(field_id);
Review Comment:
After rebasing on `main` (#3342), could missing stats and empty or all-null
row groups live inside `MinMaxColAggregator::update(&ColumnChunkMetaData)`
instead of calling `drop_bounds` here? That keeps geospatial columns clean and
lets us share one bound-update helper.
##########
crates/iceberg/src/writer/file_writer/parquet_writer.rs:
##########
@@ -371,29 +385,44 @@ impl MinMaxColAggregator {
));
};
- if value.min_is_exact() {
- let Some(min_datum) = get_parquet_stat_min_as_datum(&ty, value)?
else {
- return Err(Error::new(
- ErrorKind::Unexpected,
- format!("Statistics {value} is not match with field type
{ty}."),
- ));
+ // A truncated string or binary min is a prefix of the min, and a
+ // truncated max is a prefix with its last character incremented, so
+ // both are still bounds. A truncated fixed value has the wrong length.
+ let truncated_is_bound = matches!(ty, PrimitiveType::String |
PrimitiveType::Binary);
+
+ if value.min_bytes_opt().is_some() {
Review Comment:
What if a non-all-null row group has `Some(Statistics)` with
`min_bytes_opt()` or `max_bytes_opt()` absent? Right now these `if` guards skip
that side instead of dropping the file bound, leaving partial bounds from other
row groups.
--
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]