dahbka-lis opened a new pull request, #47815: URL: https://github.com/apache/arrow/pull/47815
### Rationale for this change There is a bug for creating union types with empty `type_codes`. If `fields.size()` == 128 (`kMaxTypeCode` + 1) and `type_codes` is empty, static_cast<int8_t> returns -128 and `internal::Iota` generates an empty vector of type codes, but the expected vector is [0, 1, 2, ..., 127], where 127 is `kMaxTypeCode`. ### What changes are included in this PR? - Added a new `internal::Iota` function to generate vectors of size = `length` with values from `start`. - Changed `internal::Iota` call from old parameters to new for creating `dense_union` and `sparse_union` types. - Implemented a new test to detect this error. ### Are these changes tested? Yes, there is a new test. ### Are there any user-facing changes? No. **This PR contains a "Critical Fix".** (b) a bug that caused incorrect or invalid data to be produced If `fields.size()` == 128 (`kMaxTypeCode` + 1), `internal::Iota` returns an empty vector that cannot validate here: https://github.com/apache/arrow/blob/main/cpp/src/arrow/type.cc#L1232 -- 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]
