Skip to content

Commit

Permalink
Ensure QueryAssertions::materialize() supports lazies (facebookincuba…
Browse files Browse the repository at this point in the history
…tor#10667)

Summary:
Pull Request resolved: facebookincubator#10667

Ensure the QueryAssertions::materialize() utility correctly handles
lazy vectors. Previsouly it would blindly try to upcast it to a simple vector,
which would fail by returning a null pointer and crashing inside variantAt().

Reviewed By: mbasmanova

Differential Revision: D60779568
  • Loading branch information
pedroerp authored and facebook-github-bot committed Aug 5, 2024
1 parent a2824a1 commit db4103d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions velox/exec/tests/utils/QueryAssertions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,14 +879,20 @@ std::vector<MaterializedRow> materialize(const RowVectorPtr& vector) {
std::vector<MaterializedRow> rows;
rows.reserve(size);

auto& rowType = vector->type()->as<TypeKind::ROW>();
auto numColumns = vector->childrenSize();
std::vector<VectorPtr> simpleVectors(numColumns);

// variantAt() assumes you can upcast to SimpleVector, so we need to take
// the inner vector out of lazies first.
for (size_t i = 0; i < numColumns; ++i) {
simpleVectors[i] = BaseVector::loadedVectorShared(vector->childAt(i));
}

for (size_t i = 0; i < size; ++i) {
auto numColumns = rowType.size();
MaterializedRow row;
row.reserve(numColumns);
for (size_t j = 0; j < numColumns; ++j) {
row.push_back(variantAt(vector->childAt(j), i));
row.push_back(variantAt(simpleVectors[j], i));
}
rows.push_back(row);
}
Expand Down

0 comments on commit db4103d

Please sign in to comment.