Repository navigation
fix(spec): format dropped-source integer partition values - #3432
Conversation
|
Thanks for picking this up! I ran the same setup on this branch with other source types. int/long/date/bool/binary now work, but I missed these in #3381, sorry. uuid could reuse the |
|
Following up on the decimal/uuid part, I checked what Java writes here (iceberg-api, JDK 21). Once the source is dropped, Java sees
uuid should be easy to match by formatting the |
|
@JeonDaehong thanks for checking these and for the Java table, that helped a lot. We pushed b765bbf so uuid and decimal no longer panic. uuid prints like Java ( |
JeonDaehong
left a comment
There was a problem hiding this comment.
Checked b765bbf: it merges cleanly with main, and the spec::partition and spec::values tests pass (167). No more unreachable!() for dropped decimal/uuid sources, and uuid matches Java.
Printing the unscaled decimal is fine with me. The scale is not lost everywhere, though: a manifest is decoded with the schema stored in it, where the source still exists, so the value arrives as Int128 and only the path formatting (which uses the current schema) has no scale. Matching Java exactly would mean formatting with the manifest's schema, which is a separate change. LGTM.
|
@laskoviymishka CI is green and JeonDaehong approved this. Could you take a look and merge if it’s ready? |
|
@jopdorp - let's me get one more pass, and i think there is new conflict. Will try to make it on a weekend |
laskoviymishka
left a comment
There was a problem hiding this comment.
Thanks @JeonDaehong for the Java table. With a dropped source, int, long and uuid now print what Java and Go print. Decimal is the one I'd like changed before merge, and I'm taking @jopdorp up on the offer to handle it differently. Java's formatter and Go both keep the scale, so p=123 would leave Rust as the only client writing that value. Details inline. This also needs a rebase on main for the new conflict.
| write!(f, "{}", decimal_from_i128_with_scale(*val, *scale)) | ||
| } | ||
| // The scale lives on the dropped source type, so only the unscaled value is left. | ||
| (PrimitiveType::Unknown, PrimitiveLiteral::Int128(val)) => write!(f, "{val}"), |
There was a problem hiding this comment.
Could we format decimal with a schema that still has the source, or leave the decimal arm out of this PR? Java's toHumanString falls back to value.toString(), which keeps the BigDecimal scale. Go's manifest reader keeps the Avro scale in DecimalLiteral and prints it scaled. Both give p=1.23 where this writes p=123.
To me, @JeonDaehong's manifest-schema point is the fix, not a follow-up. PartitionSpec has no schema, but a caller holding the manifest can pass ManifestMetadata::schema(). Int, long and uuid don't need to wait on this.
There was a problem hiding this comment.
Took the first option: the commit path now formats deleted files with the newest schema that still has their partition sources, so a dropped decimal source prints p=1.23 like Java and Go, in 1401292. The unscaled arm stays only so a direct partition_to_path call with a schema missing the source does not panic, happy to drop it if you would rather.
There was a problem hiding this comment.
One more in 00309a0: with the older schema picked, a sibling source promoted int to long could pair a long literal with an int type and hit the unreachable!(), so the int and long arms now print across the promotion either way. The test covers it.
…-format # Conflicts: # crates/iceberg/src/spec/partition.rs
|
@laskoviymishka decimal keeps its scale now and main is merged in for the conflict. Ready for your pass. |
laskoviymishka
left a comment
There was a problem hiding this comment.
Thanks @jopdorp, picking the newest schema that still has the sources keeps the decimal scale, and the widened int/long arms also fix the (Long, Int) panic main hits today for files written before an int→long promotion.
One ask on the test, then this is good to merge.
| scale: 2, | ||
| }), | ||
| ); | ||
| let x = NestedField::required(1, "x", Type::Primitive(PrimitiveType::Int)); |
There was a problem hiding this comment.
Could this build the history in the order a real table would? x is long in the minimal table, so with_d declaring it int is a long→int demotion Iceberg doesn't allow, and the test only exercises (Int, Long). The realistic case is a file written before the promotion: {d, x: int} → promote x to long → drop d, with Literal::int(5) for x, which hits (Long, Int). The same d=1.23/x=5 assertion should hold.
There was a problem hiding this comment.
Rebuilt the test in 5510b0b the way a real table gets there: {d: decimal(9,2), x: int} under the original spec, then x promoted to long, then d dropped, with the deleted file carrying Literal::int(5) so it hits (Long, Int). Still expects partitions.d=1.23/x=5.
| // A dropped source column keeps its type, such as a decimal's scale, only in an | ||
| // older schema. | ||
| let schema = table_metadata | ||
| .schemas_iter() |
There was a problem hiding this comment.
nit: this only depends on the spec, so it could be resolved once per partition_spec_id instead of per removed file. A large delete rescans every schema for every file.
There was a problem hiding this comment.
Good point, 1c126a2 resolves the schema once per partition_spec_id and reuses it for every removed file of that spec.
…-format # Conflicts: # crates/iceberg/src/transaction/snapshot.rs
|
@laskoviymishka both in, and main merged again (the snapshot module moved, so the change now lives in transaction/snapshot/mod.rs). |
Which issue does this PR close?
Addresses #3381.
What changes are included in this PR?
We format partition values whose source column has been dropped instead of panicking, for the identity and truncate cases in the issue and for uuid and decimal. Decimal prints the unscaled value, since the scale only lived on the dropped column.
Are these changes tested?
the regression panics without the fix. the library suite, fmt and clippy pass.
AI Disclosure
The implementation and regression test were generated with an AI coding assistant and reviewed by a second coding assistant. The regression reproduces the panic without the fix; the library suite, fmt and clippy pass.