CaptainAni187 commented on code in PR #51807:
URL: https://github.com/apache/arrow/pull/51807#discussion_r4233465218
##########
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()));
Review Comment:
Done in 7453d8a, and the `<string>` include is gone.
##########
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:
Added in 7453d8a: the test now checks the field ID and that the dictionary
value type is `utf8()`.
--
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]