diff --git a/velox/dwio/dwrf/reader/SelectiveFlatMapColumnReader.cpp b/velox/dwio/dwrf/reader/SelectiveFlatMapColumnReader.cpp index 44dad5b9aaad..c25c6cae4beb 100644 --- a/velox/dwio/dwrf/reader/SelectiveFlatMapColumnReader.cpp +++ b/velox/dwio/dwrf/reader/SelectiveFlatMapColumnReader.cpp @@ -617,7 +617,7 @@ class SelectiveFlatMapReader : public SelectiveStructColumnReaderBase { keyBuffer->template asMutable()); std::vector keyStrings; - if constexpr (std::is_same_v) { + if (std::is_same_v && keyStrings_) { keyStrings.push_back(keyStrings_); } auto keyVector = std::make_shared>( diff --git a/velox/dwio/dwrf/test/ReaderTest.cpp b/velox/dwio/dwrf/test/ReaderTest.cpp index 7d28696b74b5..a10c4680a1ae 100644 --- a/velox/dwio/dwrf/test/ReaderTest.cpp +++ b/velox/dwio/dwrf/test/ReaderTest.cpp @@ -3104,3 +3104,22 @@ TEST_F(TestReader, selectiveStringDirect) { }); assertEqualVectors(expected, actual); } + +TEST_F(TestReader, selectiveFlatMapFastPathAllInlinedStringKeys) { + auto maps = makeMapVector( + {{{"a", 0}, {"b", 0}}, {{"a", 1}, {"b", 1}}}); + auto row = makeRowVector({"c0"}, {maps}); + auto config = std::make_shared(); + 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(""); + 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); +}