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.
Example:
std::vector<std::shared_ptr<Field>> fields;
for (int32_t i = 0; i <= UnionType::kMaxTypeCode; i++) {
fields.push_back(field(std::to_string(i), int32()));
}
auto type = dense_union(fields); // Error
The validation here will not be passed because type_codes is empty for fields.size() == 128, but fields is not empty.
Otherwise:
- I can create
dense_union type with non-empty type_codes vector created by std::iota(0, 128), check the example below.
- Unions from
pyarrow support at most 128 codes and not 127.
std::vector<std::shared_ptr<Field>> fields;
for (int32_t i = 0; i <= UnionType::kMaxTypeCode; i++) {
fields.push_back(field(std::to_string(i), int32()));
}
std::vector<int8_t> type_codes(fields.size());
std::iota(type_codes.begin(), type_codes.end(), 0);
auto type = dense_union(fields, type_codes); // OK
Component(s)
C++
There is a bug for creating union types with empty
type_codes. Iffields.size() == 128(kMaxTypeCode+ 1) andtype_codesis empty, static_cast<int8_t> returns -128 andinternal::Iotagenerates an empty vector of type codes, but the expected vector is [0, 1, 2, ..., 127], where 127 iskMaxTypeCode.Example:
The validation here will not be passed because
type_codesis empty forfields.size() == 128, butfieldsis not empty.Otherwise:
dense_uniontype with non-emptytype_codesvector created by std::iota(0, 128), check the example below.pyarrowsupport at most 128 codes and not 127.Component(s)
C++