Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace tableScan API with tableScanBuilder #7769

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 42 additions & 18 deletions velox/connectors/fuzzer/tests/FuzzerConnectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ TEST_F(FuzzerConnectorTest, singleSplit) {
const size_t numRows = 100;
auto type = ROW({BIGINT(), DOUBLE(), VARCHAR()});

auto plan =
PlanBuilder().tableScan(type, makeFuzzerTableHandle(), {}).planNode();
auto plan = PlanBuilder()
.startTableScan()
.outputType(type)
.tableHandle(makeFuzzerTableHandle())
.endTableScan()
.planNode();

exec::test::AssertQueryBuilder(plan)
.split(makeFuzzerSplit(numRows))
Expand All @@ -43,8 +47,12 @@ TEST_F(FuzzerConnectorTest, floatingPoints) {
const size_t numRows = 1000;
auto type = ROW({REAL(), DOUBLE()});

auto plan =
PlanBuilder().tableScan(type, makeFuzzerTableHandle(), {}).planNode();
auto plan = PlanBuilder()
.startTableScan()
.outputType(type)
.tableHandle(makeFuzzerTableHandle())
.endTableScan()
.planNode();

exec::test::AssertQueryBuilder(plan)
.split(makeFuzzerSplit(numRows))
Expand All @@ -59,8 +67,12 @@ TEST_F(FuzzerConnectorTest, complexTypes) {
REAL(),
});

auto plan =
PlanBuilder().tableScan(type, makeFuzzerTableHandle(), {}).planNode();
auto plan = PlanBuilder()
.startTableScan()
.outputType(type)
.tableHandle(makeFuzzerTableHandle())
.endTableScan()
.planNode();

exec::test::AssertQueryBuilder(plan)
.split(makeFuzzerSplit(numRows))
Expand All @@ -72,8 +84,12 @@ TEST_F(FuzzerConnectorTest, multipleSplits) {
const size_t numSplits = 10;
auto type = ROW({BIGINT(), DOUBLE(), VARCHAR()});

auto plan =
PlanBuilder().tableScan(type, makeFuzzerTableHandle(), {}).planNode();
auto plan = PlanBuilder()
.startTableScan()
.outputType(type)
.tableHandle(makeFuzzerTableHandle())
.endTableScan()
.planNode();

exec::test::AssertQueryBuilder(plan)
.splits(makeFuzzerSplits(rowsPerSplit, numSplits))
Expand All @@ -89,8 +105,12 @@ TEST_F(FuzzerConnectorTest, randomTypes) {
for (size_t i = 0; i < iterations; ++i) {
auto type = VectorFuzzer({}, pool()).randRowType();

auto plan =
PlanBuilder().tableScan(type, makeFuzzerTableHandle(), {}).planNode();
auto plan = PlanBuilder()
.startTableScan()
.outputType(type)
.tableHandle(makeFuzzerTableHandle())
.endTableScan()
.planNode();
exec::test::AssertQueryBuilder(plan)
.splits(makeFuzzerSplits(rowsPerSplit, numSplits))
.assertTypeAndNumRows(type, rowsPerSplit * numSplits);
Expand All @@ -101,14 +121,18 @@ TEST_F(FuzzerConnectorTest, reproducible) {
const size_t numRows = 100;
auto type = ROW({BIGINT(), ARRAY(INTEGER()), VARCHAR()});

auto plan1 =
PlanBuilder()
.tableScan(type, makeFuzzerTableHandle(/*fuzerSeed=*/1234), {})
.planNode();
auto plan2 =
PlanBuilder()
.tableScan(type, makeFuzzerTableHandle(/*fuzerSeed=*/1234), {})
.planNode();
auto plan1 = PlanBuilder()
.startTableScan()
.outputType(type)
.tableHandle(makeFuzzerTableHandle(/*fuzerSeed=*/1234))
.endTableScan()
.planNode();
auto plan2 = PlanBuilder()
.startTableScan()
.outputType(type)
.tableHandle(makeFuzzerTableHandle(/*fuzerSeed=*/1234))
.endTableScan()
.planNode();

auto results1 = exec::test::AssertQueryBuilder(plan1)
.split(makeFuzzerSplit(numRows))
Expand Down
9 changes: 5 additions & 4 deletions velox/exec/tests/AssertQueryBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ TEST_F(AssertQueryBuilderTest, hiveSplits) {

AssertQueryBuilder(
PlanBuilder()
.tableScan(
ROW({"c0", "ds"}, {INTEGER(), VARCHAR()}),
makeTableHandle(),
assignments)
.startTableScan()
.outputType(ROW({"c0", "ds"}, {INTEGER(), VARCHAR()}))
.tableHandle(makeTableHandle())
.assignments(assignments)
.endTableScan()
.planNode(),
duckDbQueryRunner_)
.split(HiveConnectorSplitBuilder(file->path)
Expand Down
5 changes: 4 additions & 1 deletion velox/exec/tests/AsyncConnectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ TEST_F(AsyncConnectorTest, basic) {
auto tableHandle = std::make_shared<TestTableHandle>();
core::PlanNodeId scanId;
auto plan = PlanBuilder()
.tableScan(ROW({"a"}, {BIGINT()}), tableHandle, {})
.startTableScan()
.outputType(ROW({"a"}, {BIGINT()}))
.tableHandle(tableHandle)
.endTableScan()
.capturePlanNodeId(scanId)
.singleAggregation({}, {"min(a)"})
.planNode();
Expand Down
26 changes: 13 additions & 13 deletions velox/exec/tests/HashJoinTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4123,16 +4123,15 @@ TEST_F(HashJoinTest, dynamicFilters) {
assignments["b"] = regularColumn("c1", BIGINT());

core::PlanNodeId probeScanId;
auto op =
PlanBuilder(planNodeIdGenerator, pool_.get())
.tableScan(
scanOutputType,
makeTableHandle(common::test::SubfieldFiltersBuilder().build()),
assignments)
.capturePlanNodeId(probeScanId)
.hashJoin({"a"}, {"u_c0"}, buildSide, "", {"a", "b", "u_c1"})
.project({"a", "b + 1", "b + u_c1"})
.planNode();
auto op = PlanBuilder(planNodeIdGenerator, pool_.get())
.startTableScan()
.outputType(scanOutputType)
.assignments(assignments)
.endTableScan()
.capturePlanNodeId(probeScanId)
.hashJoin({"a"}, {"u_c0"}, buildSide, "", {"a", "b", "u_c1"})
.project({"a", "b + 1", "b + u_c1"})
.planNode();

HashJoinBuilder(*pool_, duckDbQueryRunner_, driverExecutor_.get())
.planNode(std::move(op))
Expand Down Expand Up @@ -4879,8 +4878,6 @@ TEST_F(HashJoinTest, dynamicFilterOnPartitionKey) {
.partitionKey("k", "0")
.build();
auto outputType = ROW({"n1_0", "n1_1"}, {BIGINT(), BIGINT()});
std::shared_ptr<connector::hive::HiveTableHandle> tableHandle =
makeTableHandle();
ColumnHandleMap assignments = {
{"n1_0", regularColumn("c0", BIGINT())},
{"n1_1", partitionKey("k", BIGINT())}};
Expand All @@ -4889,7 +4886,10 @@ TEST_F(HashJoinTest, dynamicFilterOnPartitionKey) {
auto planNodeIdGenerator = std::make_shared<core::PlanNodeIdGenerator>();
auto op =
PlanBuilder(planNodeIdGenerator)
.tableScan(outputType, tableHandle, assignments)
.startTableScan()
.outputType(outputType)
.assignments(assignments)
.endTableScan()
.capturePlanNodeId(probeScanId)
.hashJoin(
{"n1_1"},
Expand Down
Loading
Loading