Repository navigation
feat(transform): support truncate for LargeBinary arrays - #3120
jaideeppyne wants to merge 2 commits into
Conversation
The spec lists binary as a valid source type for truncate[W], and Transform::result_type accepts it, but TransformFunction for Truncate rejects it in both paths: transform_literal has no Binary arm, and transform handles DataType::Binary but not DataType::LargeBinary, which is what schema_to_arrow_schema produces for an Iceberg binary column. Closes apache#3119
b41907c to
e5aaa87
Compare
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
|
This is still relevant and ready for review. The branch remains mergeable, and all CI checks are green. Please keep the PR open. |
# Conflicts: # crates/iceberg/src/transform/truncate.rs
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
|
This is still relevant and ready for review. It adds truncate for LargeBinary arrays. Tests, clippy, and the platform builds are green. |
Which issue does this PR close?
What changes are included in this PR?
The spec lists
binaryunder the source types fortruncate[W], and the Truncate Transform Details table givesv.subarray(0, L).Transform::result_typealready acceptsPrimitiveType::Binary, so a binary truncate partition field is legal, but neither half ofTransformFunction for Truncatecould actually handle one:transform_literalhad noPrimitiveLiteral::Binaryarm, soTransform::projectandstrict_projectreturnedFeatureUnsupportedfor every operator.InclusiveProjectioninscan/cache.rspropagates that, so a scan with a filter on such a column errors instead of pruning.transformhandledDataType::Binarybut notDataType::LargeBinary, andschema_to_arrow_schemamaps IcebergbinarytoLargeBinary. So the array path failed on the exact arrow type this crate produces for a binary column.truncate_binaryalready existed and was correct, it just was not reachable from either entry point. I added the two arms.fixedstays rejected, since the spec does not list it as a truncate source type, and the literal arm is guarded on the datum type so aFixeddatum (also backed byPrimitiveLiteral::Binary) still errors.Are these changes tested?
Yes, unit tests in
truncate.rs: array truncation forBinaryArrayandLargeBinaryArray, literal truncation (longer than width, shorter than width, empty), inclusive projection for</<=/>/>=/=/STARTS WITH/IN, strict projection for!=, and thatfixedis still rejected. Reverting just the two source arms and keeping the tests fails the 4 new tests and leaves the 16 pre-existing truncate tests passing. Fullcargo test -p icebergis green (1617 tests), fmt and clippy clean.I found this with a differential harness over
bucket[N],truncate[W],year/month/day/houron a 781-value corpus (spec test vectors plus randoms and boundary values across every source type), running the same inputs through pyiceberg 0.11.1, iceberg-go and this crate's literal and array paths. Of 9333 comparisons, 49 were binary truncate literals where pyiceberg and iceberg-go return a value and this crate errored. TheLargeBinaryhalf is not visible that way, I hit it after checking whatschema_to_arrow_schemaactually emits forbinary.Not covered:
BinaryView, which no path in this crate currently produces, and whichbucketdoes not handle either.AI Disclosure
Claude Code wrote the differential harness and drafted the patch and tests. I checked the spec clauses, verified every claim above against real test output, and reviewed the final diff.