vera-rubin opened a new pull request, #1662: URL: https://github.com/apache/arrow-go/pull/1662
### Rationale for this change When one or both inputs are dictionary-encoded decimals, comparison and arithmetic functions skip the decimal scale promotion. For example, with a dictionary<int8, decimal128(3, 0)> array `[1]` and a decimal128(3, 1) array `[1.0]` (dictionary or plain), `equal` returns false, `less` returns true, `add` returns 11 and `divide` returns 0. The same values without dictionary encoding give true, false, 2.0 and 1.0000. The same happens for decimal256. The cause is the order in `DispatchBest`: `compareFunction` and `arithmeticFunction` run the decimal promotion (`castBinaryDecimalArgs` / `checkDecimals`) before `ensureDictionaryDecoded`, so the promotion sees dictionary types, does nothing, and the kernels then run on the unscaled values. ### What changes are included in this PR? `ensureDictionaryDecoded` is now called before the decimal promotion in `compareFunction.DispatchBest` and `arithmeticFunction.DispatchBest`, so dictionary value types take part in it like plain decimal inputs. ### Are these changes tested? Yes. `TestBinaryArithmetic/TestDictionaryPromotion` checks `equal`, `less`, `add` and `divide` for decimal128 and decimal256 with dictionary/dictionary, dictionary/plain and plain/dictionary inputs `["1", null, "2"]` (scale 0) and `["1.0", null, "0.5"]` (scale 1), including the result types. All 24 cases fail without the fix and pass with it; the `./arrow/compute/...` and decimal package tests pass. ### Are there any user-facing changes? Yes. Comparisons and arithmetic on dictionary-encoded decimals now return the same values and decimal result types as on the decoded inputs. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
