Repository navigation
test(arrow/array): make run-end-encoded concat tests valid on 32-bit platforms - #1408
Merged
Merged
Conversation
…platforms TestConcatRunEndEncodedInt64FinalRunEndClamp built its input with RunEndEncodedBuilder.Append(math.MaxInt64), which makes an array whose length is math.MaxInt64. Array lengths are ints, so on 386 the length wraps negative and NewSlice panics while building the input; the test never reached Concatenate on the 32-bit targets it was written for. Build the one-element input directly with a run end of math.MaxInt64 and logical length 1, and also check the concatenated run ends and values. TestConcatAlmostOverflowRunEndEncoding/int64 and TestConcatOverflowRunEndEncoding/int64 need inputs with logical lengths near 2^62, which cannot exist when int is 32 bits; skip them there.
lidavidm
approved these changes
Oct 24, 2026
zeroshade
added a commit
that referenced
this pull request
Oct 26, 2026
…ons (#1409) ### Rationale for this change Found while fixing the 32-bit test failures in #1408. Decimal conversions are wrong on 32-bit platforms. `decimal128.Num` and `decimal256.Num` use 64-bit limbs, but their `big.Int` conversions assumed `big.Word` is also 64 bits. On 386 it is 32 bits, so: - `decimal128.FromBigInt` read `b[0]`/`b[1]` as the low and high limbs (`decimal128.go:95–97`), misplacing words and dropping the rest; - `decimal128`'s `toBigIntPositive` built `[]big.Word{big.Word(n.lo), big.Word(n.hi)}` (`decimal128.go:362`), truncating each limb; - `decimal256.FromBigInt` copied word *i* into limb *i* (`decimal256.go:370`), misplacing words and panicking when a value needed more than four native words; - `decimal256`'s `toBigIntPositive` truncated its limbs the same way (`decimal256.go:379`). Anything going through `big.Int` (string formatting and parsing, rescaling, `GetOneForMarshal`, CSV decimal parsing) produced wrong values or spurious precision errors on 386, e.g. `TestDecimal128Slice` printed `-1717986918` instead of `-7.378697629e+18`, and `TestDecimal128GetOneForMarshal` turned `1234567890.123456789` into `437278697.08398250845211745659132109676`. The run-end-encoded validation fix that was originally part of this PR has moved to #1421. ### What changes are included in this PR? - **`arrow/decimal128`, `arrow/decimal256`:** when `bits.UintSize == 32`, combine pairs of 32-bit `big.Word`s into each 64-bit limb in `FromBigInt`, and split each limb into two words in `toBigIntPositive`. `bits.UintSize` is a constant, so 64-bit builds compile the existing code unchanged. Also corrects the `decimal128.FromBigInt` doc (it panics above 127 bits, as the code already does). - **CI:** the 386 job also runs the decimal packages' tests. ### Are these changes tested? Yes. - **On `GOARCH=386`:** `TestDecimal128Slice`, `TestDecimal128StringRoundTrip`, `TestDecimal128GetOneForMarshal`, `TestDecimal256Slice`, `TestDecimal256GetOneForMarshal`, all nine `TestDecimal/TestWithNulls#01` precisions, `TestDecimalScalarStringCastUsesExactScaling` and CSV's `TestReadCSVDecimalCols` all failed before and pass now. The `TestDecimalToBigInt` tests in both packages gain word-boundary cases with independently computed expectations, which fail on 386 without the fix (decimal256 panics). `arrow/decimal128`, `arrow/decimal256` and `arrow/decimal/...` pass in full on 386. - **amd64:** `arrow/decimal128`, `arrow/decimal256`, `arrow/decimal/...` pass. - `go vet` and `gofmt -l` are clean on the changed packages. ### Are there any user-facing changes? Yes: decimal values convert correctly on 32-bit platforms. No API changes.
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.
Rationale for this change
TestConcatRunEndEncodedInt64FinalRunEndClamppanics on 386 (GOARCH=386 go test ./arrow/array -run TestConcatRunEndEncodedInt64FinalRunEndClamp):The test builds its input with
RunEndEncodedBuilder.Append(math.MaxInt64), which makes an array whose length ismath.MaxInt64. Array lengths areint, so on 32-bit targets the length wraps negative andarray.NewSlice(big, 0, 1)panics while building the input: the test never reachesConcatenate. That is exactly the platform it was written for, since #1219's original bug (anint(e)conversion of the run end) only overflowed whenintis 32 bits.Two related tests,
TestConcatAlmostOverflowRunEndEncoding/int64andTestConcatOverflowRunEndEncoding/int64, have the same problem: they build inputs whose logical lengths are near 2^62, which cannot exist with 32-bitint.These panics are not visible in CI, which only cross-builds for 386.
What changes are included in this PR?
Test-only changes in
arrow/array/concat_test.go:TestConcatRunEndEncodedInt64FinalRunEndClampbuilds the one-element input directly withNewRunEndEncodedArray: run ends[math.MaxInt64], logical length 1. That is the same shape as a one-element slice of aMaxInt64-length run, and it is valid on 32-bit. The test now also checks the concatenated run ends ([5, 6]) and values ([1, 2]), not just the length.*OverflowRunEndEncodingtests skip theirint64case whentt.max > math.MaxInt, i.e. only where the inputs cannot be constructed. The int16 and int32 cases still run everywhere.Are these changes tested?
GOARCH=386 go test ./arrow/array -run Concat: ok (twoint64subtests skipped).go test ./arrow/array: ok on amd64, no skips.concat.gochange reverted it fails on amd64 (overflow in run-length-encoded run ends concat) and on 386 (wrong run ends).go vet ./arrow/arrayandgofmt -l: clean.Not addressed here:
arrow/arraystill has other, unrelated 386 failures in the decimal tests (e.g.TestDecimal128Slice,TestDecimal256Slice), which fail the same way on main.Are there any user-facing changes?
No.