Repository navigation
GH-51779: [C++][IPC] Read a DictionaryEncoding without indexType as int32 indices - #51807
CaptainAni187 wants to merge 2 commits into
Conversation
…e as int32 indices
|
|
|
|
| auto metadata = Buffer::FromString( | ||
| std::string(reinterpret_cast<const char*>(fbb.GetBufferPointer()), fbb.GetSize())); |
There was a problem hiding this comment.
The test copies the flatbuffer into a Buffer by hand through a std::string. internal::WriteFlatbufferBuilder(fbb) already does this (read_write_test.cc uses it) and would also make the new #include <string> unnecessary.
There was a problem hiding this comment.
Done in 7453d8a, and the <string> include is gone.
|
|
||
| ASSERT_OK_AND_ASSIGN(auto message, Message::Open(metadata, /*body=*/nullptr)); | ||
| DictionaryMemo memo; | ||
| ASSERT_OK_AND_ASSIGN(auto schema, ReadSchema(*message, &memo)); |
There was a problem hiding this comment.
Could we also check that the field was registered in memo? The schema comparison passes even if the new code path never registers the field. A reader needs that registration to match the field to the DictionaryBatch and RecordBatch that follow, and that's where #51779 failed. Something like:
ASSERT_OK_AND_EQ(0, memo.fields().GetFieldId({0}));
ASSERT_OK_AND_ASSIGN(auto dict_value_type, memo.GetDictionaryType(0));
AssertTypeEqual(utf8(), dict_value_type);There was a problem hiding this comment.
Added in 7453d8a: the test now checks the field ID and that the dictionary value type is utf8().
Rationale for this change
Schema.fbsallowsDictionaryEncoding.indexTypeto be omitted: "If this field is null, the indices must be signed int32." The C++ IPC reader required it instead, so C++ and PyArrow failed to read such a stream withIOError: Unexpected null field DictionaryEncoding.indexType in flatbuffer-encoded metadata.What changes are included in this PR?
FieldFromFlatbufferusesint32()as the index type whenindexTypeis absent, instead of failing the null check.Are these changes tested?
Yes.
TestMessageInternal.DictionaryEncodingWithoutIndexTypebuilds a schema message whose dictionary-encoded field has noindexTypeand checks thatReadSchemareturnsdictionary<values=string, indices=int32>. On main it fails with the error above. Thearrow-ipc-*tests pass locally.Are there any user-facing changes?
Streams that omit
indexTypecan now be read. Streams that include it are read as before.Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
PR code and description written by:
Reviewed before submission by: