Commit 55587ef
authored
### 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
* GitHub Issue: #47859
Lead-authored-by: Daniil Timizhev <[email protected]>
Co-authored-by: Daniil Timižev <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 4cedc9d commit 55587ef
File tree
4 files changed
+45
-8
lines changed- cpp/src/arrow
- util
- docs/source/format
4 files changed
+45
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3270 | 3270 | | |
3271 | 3271 | | |
3272 | 3272 | | |
3273 | | - | |
| 3273 | + | |
3274 | 3274 | | |
3275 | 3275 | | |
3276 | 3276 | | |
3277 | 3277 | | |
3278 | 3278 | | |
3279 | 3279 | | |
3280 | 3280 | | |
3281 | | - | |
| 3281 | + | |
3282 | 3282 | | |
3283 | 3283 | | |
3284 | 3284 | | |
| |||
3310 | 3310 | | |
3311 | 3311 | | |
3312 | 3312 | | |
3313 | | - | |
| 3313 | + | |
3314 | 3314 | | |
3315 | 3315 | | |
3316 | 3316 | | |
| |||
3320 | 3320 | | |
3321 | 3321 | | |
3322 | 3322 | | |
3323 | | - | |
| 3323 | + | |
3324 | 3324 | | |
3325 | 3325 | | |
3326 | 3326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
2191 | 2192 | | |
2192 | 2193 | | |
2193 | 2194 | | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
2194 | 2225 | | |
2195 | 2226 | | |
2196 | 2227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
36 | | - | |
37 | | - | |
38 | | - | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
880 | 880 | | |
881 | 881 | | |
882 | 882 | | |
883 | | - | |
| 883 | + | |
884 | 884 | | |
885 | 885 | | |
886 | 886 | | |
| |||
0 commit comments