[python] Honor sequence.field in primary-key writes - #10166
Conversation
8a6c994 to
2605de1
Compare
|
Reviewed the current head as a data-correctness change, including the writer sort/fold path, read-side comparator, native dispatch boundaries, and the earlier review findings. There is clear end-to-end value: without this, buffering Local verification on this head: 183 focused sequence/native tests passed (14 optional-Rust cases skipped locally); 156 adjacent write-buffer, partial-update, aggregation, and table-write tests passed, plus 6 subtests. I found no blocking regression. A Python-write/Java-read interoperability smoke test would add confidence in the shared-table contract, especially for floating sequences, but the current writer ordering and comparator agree with the Java path I inspected. |
Purpose
A primary-key table with
sequence.field=seqcan keep a stale row when a newer business version arrives before an older version in the same write buffer. Writing(seq=100, value='high')followed by(seq=50, value='low')persistslow, while committing the rows separately returnshigh.Sort buffered rows by primary key, configured sequence fields and generated sequence number before folding equal keys. Use Arrow's columnar sort with temporary integer keys for floating sequence fields. Both Python read and write paths follow Java Float/Double comparison: NaNs compare equal above positive infinity, and negative zero precedes positive zero. Nulls stay first in both directions; ties fall back to the next sequence field and generated sequence number.
Validate sequence configuration and supported types before native backend selection and Python writer initialization, so invalid configurations cannot bypass checks or mutate dynamic bucket indexes.
Use the Python writer for floating or descending sequences and the Python reader for floating sequences, which the current native backend cannot order consistently. Supported native paths remain available.
Tests
JavaPyE2ETest#testReadPythonFloatingSequenceon Java 8, with Checkstyle, Spotless and Enforcer enabled. A test-only mutation bypassing the IEEE sort keys triggers Java assertion failures for NaN and signed-zero winners.ChunkedArray.to_numpy(zero_copy_only=...)keyword on Arrow 6/12. The existing eight fixture tests pass on Linux Python 3.6.15 / Arrow 6.0.1 / NumPy 1.19.5 and on Python 3.10 / Arrow 12.0.1 / NumPy 1.23.5; Java 8 reads all eight tables from each environment successfully. Final Maven checks run withoutfast-build. Also passed 129 Arrow 16 sequence/merge-buffer tests and 28 Arrow 19 / NumPy 2 floating regressions.git diff --checkpassed.