Skip to content

Commit

Permalink
Fix DWRF selective flat map reader fast path crash with all inlined s…
Browse files Browse the repository at this point in the history
…tring keys (facebookincubator#8952)

Summary: Pull Request resolved: facebookincubator#8952

Differential Revision: D54511991
  • Loading branch information
Yuhta authored and facebook-github-bot committed Mar 4, 2024
1 parent 603554b commit 684f6ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/reader/SelectiveFlatMapColumnReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ class SelectiveFlatMapReader : public SelectiveStructColumnReaderBase {
keyBuffer->template asMutable<T>());

std::vector<BufferPtr> keyStrings;
if constexpr (std::is_same_v<T, StringView>) {
if (std::is_same_v<T, StringView> && keyStrings_) {
keyStrings.push_back(keyStrings_);
}
auto keyVector = std::make_shared<FlatVector<T>>(
Expand Down
19 changes: 19 additions & 0 deletions velox/dwio/dwrf/test/ReaderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3104,3 +3104,22 @@ TEST_F(TestReader, selectiveStringDirect) {
});
assertEqualVectors(expected, actual);
}

TEST_F(TestReader, selectiveFlatMapFastPathAllInlinedStringKeys) {
auto maps = makeMapVector<std::string, int64_t>(
{{{"a", 0}, {"b", 0}}, {{"a", 1}, {"b", 1}}});
auto row = makeRowVector({"c0"}, {maps});
auto config = std::make_shared<dwrf::Config>();
config->set(dwrf::Config::FLATTEN_MAP, true);
config->set(dwrf::Config::MAP_FLAT_COLS, {0});
auto [writer, reader] = createWriterReader({row}, pool(), config);
auto schema = asRowType(row->type());
auto spec = std::make_shared<common::ScanSpec>("<root>");
spec->addAllChildFields(*schema);
RowReaderOptions rowReaderOpts;
rowReaderOpts.setScanSpec(spec);
auto rowReader = reader->createRowReader(rowReaderOpts);
VectorPtr batch = BaseVector::create(schema, 0, pool());
ASSERT_EQ(rowReader->next(10, batch), 2);
assertEqualVectors(batch, row);
}

0 comments on commit 684f6ef

Please sign in to comment.