Repository navigation
Conversation
JeonDaehong
left a comment
There was a problem hiding this comment.
The fix is right, and I confirmed the new test fails on main.
Two things, both outside the change itself:
- Java doesn't allow this promotion yet.
TypeUtil.isPromotionAllowedin iceberg-java main has onlyint→long,float→doubleand decimal precision. So this follows the v3 spec table rather than Java. - On the out-of-range case you mention: the spec says those values "must result in a runtime failure". I tried
200_000days (year 2517) through this test. In the requiredtimestamp_nscolumn the read fails, but withColumn 'e' is declared as non-nullable but contains null values. That's a failure, but nothing points at the date. In an optional column it would read as NULL. Both come from the safe cast. Maybe worth a line in #3404 for whoever picks that up.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
What changed in this PR
Fixes Iceberg Arrow projection masking when promoting date columns to timestamp / timestamp_ns so promoted leaves aren’t dropped when projecting alongside other columns (closes #3404).
Changes:
- Add missing
date -> timestamp|timestamp_nsarms totype_promotion_is_validin the field-id projection path. - Add a regression test that reads a Parquet file with two
datecolumns promoted totimestamp/timestamp_nswhile projecting an additional unpromoted column.
| File | Description |
|---|---|
| crates/iceberg/src/arrow/reader/projection.rs | Extends promotion validation for date→timestamp* and adds a regression test covering multi-column projections. |
Review effort: Lite
| let tasks = Box::pin(futures::stream::iter( | ||
| vec![Ok(FileScanTask::builder() | ||
| .with_file_size_in_bytes(std::fs::metadata(&file_path).unwrap().len()) | ||
| .with_start(0) | ||
| .with_length(0) |
| let micros: Vec<i64> = days | ||
| .iter() | ||
| .map(|d| i64::from(*d) * 86_400_000_000) | ||
| .collect(); | ||
| let expected = RecordBatch::try_new( | ||
| Arc::new(schema_to_arrow_schema(&new_schema).unwrap()), | ||
| vec![ | ||
| Arc::new(TimestampMicrosecondArray::from(micros.clone())), | ||
| Arc::new(TimestampNanosecondArray::from( | ||
| micros.iter().map(|us| us * 1000).collect::<Vec<_>>(), |
| let tmp_dir = TempDir::new().unwrap(); | ||
| let file_path = format!("{}/date.parquet", tmp_dir.path().to_str().unwrap()); | ||
| let mut writer = | ||
| ArrowWriter::try_new(File::create(&file_path).unwrap(), old_batch.schema(), None) |
The promoted-date regression test built its `FileScanTask` with `length(0)` while reporting the real `file_size_in_bytes`, so a reader that trusts `length` would see an empty task; take both from the file's metadata. Route the day/microsecond/nanosecond conversions through named constants and build the temporary path with `Path::join` instead of string formatting, so the test stays readable and platform independent. Signed-off-by: yuwk <[email protected]>
|
The three test findings are addressed in
Local: |
JeonDaehong
left a comment
There was a problem hiding this comment.
Thanks @ump45nose, all three are addressed in fbe43f3 and the arrow tests pass. LGTM.


Which issue does this PR close?
What changes are included in this PR?
type_promotion_is_validin the field-id projection path had no arm for the v3date->timestamp/timestamp_nspromotions. When another column was projected in the same read, the date leaf was left out of the projection mask, so the column came back as NULL (or failed withMissing required fieldwhen required). Projecting it alone happened to work only because the mask fell back toProjectionMask::all().This adds the two promotions to the match, so the leaf is read and
RecordBatchTransformercasts it as it already does in the single-column case.The out-of-range case from the issue (a date that overflows
timestamp_nsreads as NULL instead of failing) comes from the safe cast in thePromotepath and is not addressed here.Are these changes tested?
Yes. A new test in
arrow::reader::projectionwrites a file with twodatecolumns and anintcolumn and reads it through a schema that promotes them to optionaltimestampand requiredtimestamp_ns, projecting all three. It fails on main (the required column is reported missing) and passes with the change. Theiceberglib tests and clippy pass locally.AI Disclosure
I used an AI assistant to help locate the cause and write the test, then reviewed and ran it myself. The fix follows the one suggested in the issue. One thing worth a look: the match does not check the table's format version, same as the existing int/float/decimal arms, so a pre-v3 table with this promotion would also be read rather than rejected.