ianmcook commented on code in PR #51807:
URL: https://github.com/apache/arrow/pull/51807#discussion_r4226345213
##########
cpp/src/arrow/ipc/message_internal_test.cc:
##########
@@ -114,6 +115,29 @@ TEST(TestMessageInternal, TestEndiannessRoundtrip) {
}
}
+// GH-51779: Schema.fbs allows DictionaryEncoding.indexType to be omitted, in
+// which case the indices are signed int32.
+TEST(TestMessageInternal, DictionaryEncodingWithoutIndexType) {
+ FBB fbb;
+ auto name = fbb.CreateString("f0");
+ auto value_type = flatbuf::CreateUtf8(fbb);
+ auto encoding = flatbuf::CreateDictionaryEncoding(fbb, /*id=*/0,
/*indexType=*/0);
+ auto fb_field = flatbuf::CreateField(fbb, name, /*nullable=*/true,
flatbuf::Type_Utf8,
+ value_type.Union(), encoding);
+ auto fb_schema = flatbuf::CreateSchema(fbb, flatbuf::Endianness_Little,
+ fbb.CreateVector({fb_field}));
+ fbb.Finish(flatbuf::CreateMessage(fbb, flatbuf::MetadataVersion_V5,
+ flatbuf::MessageHeader_Schema,
fb_schema.Union()));
+ auto metadata = Buffer::FromString(
+ std::string(reinterpret_cast<const char*>(fbb.GetBufferPointer()),
fbb.GetSize()));
+
+ ASSERT_OK_AND_ASSIGN(auto message, Message::Open(metadata,
/*body=*/nullptr));
+ DictionaryMemo memo;
+ ASSERT_OK_AND_ASSIGN(auto schema, ReadSchema(*message, &memo));
Review 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:
```cpp
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);
```
--
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]