feat: respect randomizeFilePrefixes and randomPrefixLength in write_dir#2513
Open
CynicDog wants to merge 1 commit intodelta-io:mainfrom
Open
feat: respect randomizeFilePrefixes and randomPrefixLength in write_dir#2513CynicDog wants to merge 1 commit intodelta-io:mainfrom
CynicDog wants to merge 1 commit intodelta-io:mainfrom
Conversation
WriteContext::write_dir() now emits a random alphanumeric prefix whenever column mapping is on or delta.randomizeFilePrefixes is set, and the prefix length is driven by delta.randomPrefixLength (default 2). When a random prefix is used on a partitioned table, Hive-style path components are suppressed; partition values are still recorded in add.partitionValues. This matches Delta-Spark's getRandomPrefix / DelayedCommitProtocol behavior so kernel writers produce a compatible on-disk layout.
Contributor
Author
|
@scottsand-db wanted to flag one thing I wasn't sure about: for the My read of Spark's The change would be a small tweak in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WriteContext::write_dir() now emits a random alphanumeric prefix whenever column mapping is on or delta.randomizeFilePrefixes is set, and the prefix length is driven by delta.randomPrefixLength (default 2). When a random prefix is used on a partitioned table, Hive-style path components are suppressed; partition values are still recorded in add.partitionValues. This matches Delta-Spark's getRandomPrefix / DelayedCommitProtocol behavior so kernel writers produce a compatible on-disk layout.
Closes #2357.
What changes are proposed in this pull request?
WriteContext::write_dir()previously emitted a random 2-char alphanumeric prefix only when column mapping was enabled. This PR makes it also respect the two table properties Delta-Spark uses for the same purpose:delta.randomizeFilePrefixes(bool, defaultfalse) — whentrue, a random prefix is emitted regardless of column mapping mode.delta.randomPrefixLength(positive int, default2) — controls the prefix length for both the column-mapping path and the new randomize path.Both properties were already deserialized into
TableProperties; the implementation is purely in the write path:Transaction::shared_write_statereads the two properties fromeffective_table_config.table_properties()and stores resolved values onSharedWriteState.random_alphanumeric_prefix(len)is now parameterized by length.write_dir()uses a singleshould_prefixdecision: a random prefix is used iff column mapping is on orrandomizeFilePrefixesis set.When a random prefix is used on a partitioned table, Hive-style path components are suppressed; partition values are still recorded in
add.partitionValues.How was this change tested?
write_contextunit tests pass unchanged (make_write_contextis now a thin wrapper around a new helper that also accepts the randomize parameters).kernel/src/transaction/write_context.rs:test_write_dir_with_randomize_property— cartesian overcm_mode × randomize × is_partitioned.test_write_dir_random_prefix_length_property— verifies prefix length is honored for lengths 1, 2, and 16 in both the CM-on andrandomize=truepaths.test_write_dir_cm_off_randomize_suppresses_hive— pins the decision flagged in "Open question" above so a future flip is deliberate.test_random_alphanumeric_prefix_formatextended to loop over multiple lengths (1, 2, 8, 32).cargo +nightly fmtcargo clippy --workspace --benches --tests --all-features -- -D warningscargo doc --workspace --all-features --no-depscargo nextest run --workspace --all-features(one unrelated pre-existing FFI trybuild failure onmain).