Skip to content

Commit

Permalink
test: A test case to guard against output order of LocalPartiton(kGat…
Browse files Browse the repository at this point in the history
…her) in serial execution mode (#11726)

Summary:
As title. The test case guards against the output data order of `LocalPartiton(kGather)` to match the input data order when serial execution is on.

Pull Request resolved: #11726

Reviewed By: gggrace14

Differential Revision: D66784276

Pulled By: xiaoxmeng

fbshipit-source-id: dddc5410476b2173f887bcba850dd906a0b56257
  • Loading branch information
zhztheplayer authored and facebook-github-bot committed Dec 5, 2024
1 parent 03f0894 commit eb49cea
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions velox/exec/tests/LocalPartitionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "velox/exec/tests/utils/AssertQueryBuilder.h"
#include "velox/exec/tests/utils/HiveConnectorTestBase.h"
#include "velox/exec/tests/utils/PlanBuilder.h"
#include "velox/functions/prestosql/window/WindowFunctionsRegistration.h"

using namespace facebook::velox;
using namespace facebook::velox::exec;
Expand All @@ -26,6 +27,7 @@ class LocalPartitionTest : public HiveConnectorTestBase {
protected:
void SetUp() override {
HiveConnectorTestBase::SetUp();
window::prestosql::registerAllWindowFunctions();
}

template <typename T>
Expand Down Expand Up @@ -149,6 +151,38 @@ TEST_F(LocalPartitionTest, gather) {
verifyExchangeSourceOperatorStats(task, 300, 3, 1);
}

TEST_F(LocalPartitionTest, gatherPreserveInputOrderWithSerialExecutionMode) {
const std::vector<RowVectorPtr> vectors = {
makeRowVector({makeFlatVector<int64_t>({10, 20})}),
makeRowVector({makeFlatVector<int64_t>({30, 40})}),
makeRowVector({makeFlatVector<int64_t>({50, 60})}),
makeRowVector({makeFlatVector<int64_t>({70, 80})}),
makeRowVector({makeFlatVector<int64_t>({90, 100})}),
makeRowVector({makeFlatVector<int64_t>({110, 120})})};

auto planNodeIdGenerator = std::make_shared<core::PlanNodeIdGenerator>();

auto valuesNode = [&](const std::vector<int>& indices) {
std::vector<RowVectorPtr> values;
for (const auto& index : indices) {
values.push_back(vectors[index]);
}
return PlanBuilder(planNodeIdGenerator).values(values).planNode();
};

auto op =
PlanBuilder(planNodeIdGenerator)
.localPartition(
{}, {valuesNode({0, 1, 2}), valuesNode({3}), valuesNode({4, 5})})
.window({"row_number() over () as r"})
.planNode();

AssertQueryBuilder(op, duckDbQueryRunner_)
.serialExecution(true)
.assertResults(
"VALUES (10, 1), (20, 2), (30, 3), (40, 4), (50, 5), (60, 6), (70, 7), (80, 8), (90, 9), (100, 10), (110, 11), (120, 12)");
}

TEST_F(LocalPartitionTest, partition) {
std::vector<RowVectorPtr> vectors = {
makeRowVector({makeFlatSequence<int32_t>(0, 100)}),
Expand Down

0 comments on commit eb49cea

Please sign in to comment.