Skip to content

Commit

Permalink
Rename tableScan to tpchTableScan in PlanBuilder (#7753)
Browse files Browse the repository at this point in the history
Summary:
A `tableScan` API in PlanBuilder is specific to the TPC-H connector.
Rename it to `tpchTableScan` to clarify the scope.

Pull Request resolved: #7753

Reviewed By: xiaoxmeng

Differential Revision: D51607502

Pulled By: mbasmanova

fbshipit-source-id: cff19b1c86e28d986d343f96d0cbc4783df32d43
  • Loading branch information
majetideepak authored and facebook-github-bot committed Nov 28, 2023
1 parent 26389ef commit b30c094
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion velox/connectors/tpch/tests/SpeedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class TpchSpeedTest {
core::PlanNodeId scanId;
auto plan =
PlanBuilder()
.tableScan(
.tpchTableScan(
table, folly::copy(getTableSchema(table)->names()), scaleFactor)
.capturePlanNodeId(scanId)
.planNode();
Expand Down
56 changes: 29 additions & 27 deletions velox/connectors/tpch/tests/TpchConnectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class TpchConnectorTest : public exec::test::OperatorTestBase {
// Simple scan of first 5 rows of "nation".
TEST_F(TpchConnectorTest, simple) {
auto plan = PlanBuilder()
.tableScan(
.tpchTableScan(
Table::TBL_NATION,
{"n_nationkey", "n_name", "n_regionkey", "n_comment"})
.limit(0, 5, false)
Expand Down Expand Up @@ -102,7 +102,8 @@ TEST_F(TpchConnectorTest, simple) {

// Extract single column from "nation".
TEST_F(TpchConnectorTest, singleColumn) {
auto plan = PlanBuilder().tableScan(Table::TBL_NATION, {"n_name"}).planNode();
auto plan =
PlanBuilder().tpchTableScan(Table::TBL_NATION, {"n_name"}).planNode();

auto output = getResults(plan, {makeTpchSplit()});
auto expected = makeRowVector({makeFlatVector<StringView>({
Expand All @@ -125,16 +126,17 @@ TEST_F(TpchConnectorTest, singleColumnWithAlias) {
auto outputType = ROW({aliasedName}, {VARCHAR()});
auto plan =
PlanBuilder()
.tableScan(
outputType,
std::make_shared<TpchTableHandle>(
kTpchConnectorId, Table::TBL_NATION),
{
{aliasedName, std::make_shared<TpchColumnHandle>("n_name")},
{"other_name", std::make_shared<TpchColumnHandle>("n_name")},
{"third_column",
std::make_shared<TpchColumnHandle>("n_regionkey")},
})
.startTableScan()
.outputType(outputType)
.tableHandle(std::make_shared<TpchTableHandle>(
kTpchConnectorId, Table::TBL_NATION))
.assignments({
{aliasedName, std::make_shared<TpchColumnHandle>("n_name")},
{"other_name", std::make_shared<TpchColumnHandle>("n_name")},
{"third_column",
std::make_shared<TpchColumnHandle>("n_regionkey")},
})
.endTableScan()
.limit(0, 1, false)
.planNode();

Expand All @@ -150,11 +152,11 @@ TEST_F(TpchConnectorTest, singleColumnWithAlias) {

void TpchConnectorTest::runScaleFactorTest(double scaleFactor) {
auto plan = PlanBuilder()
.tableScan(
ROW({}, {}),
std::make_shared<TpchTableHandle>(
kTpchConnectorId, Table::TBL_SUPPLIER, scaleFactor),
{})
.startTableScan()
.outputType(ROW({}, {}))
.tableHandle(std::make_shared<TpchTableHandle>(
kTpchConnectorId, Table::TBL_SUPPLIER, scaleFactor))
.endTableScan()
.singleAggregation({}, {"count(1)"})
.planNode();

Expand All @@ -179,11 +181,11 @@ TEST_F(TpchConnectorTest, lineitemTinyRowCount) {
// Lineitem row count depends on the orders.
// Verify against Java tiny result.
auto plan = PlanBuilder()
.tableScan(
ROW({}, {}),
std::make_shared<TpchTableHandle>(
kTpchConnectorId, Table::TBL_LINEITEM, 0.01),
{})
.startTableScan()
.outputType(ROW({}, {}))
.tableHandle(std::make_shared<TpchTableHandle>(
kTpchConnectorId, Table::TBL_LINEITEM, 0.01))
.endTableScan()
.singleAggregation({}, {"count(1)"})
.planNode();

Expand All @@ -195,7 +197,7 @@ TEST_F(TpchConnectorTest, unknownColumn) {
EXPECT_THROW(
{
PlanBuilder()
.tableScan(Table::TBL_NATION, {"does_not_exist"})
.tpchTableScan(Table::TBL_NATION, {"does_not_exist"})
.planNode();
},
VeloxUserError);
Expand All @@ -205,7 +207,7 @@ TEST_F(TpchConnectorTest, unknownColumn) {
// same dataset in the end.
TEST_F(TpchConnectorTest, multipleSplits) {
auto plan = PlanBuilder()
.tableScan(
.tpchTableScan(
Table::TBL_NATION,
{"n_nationkey", "n_name", "n_regionkey", "n_comment"})
.planNode();
Expand Down Expand Up @@ -237,14 +239,14 @@ TEST_F(TpchConnectorTest, join) {
core::PlanNodeId regionScanId;
auto plan =
PlanBuilder(planNodeIdGenerator)
.tableScan(
.tpchTableScan(
tpch::Table::TBL_NATION, {"n_regionkey"}, 1.0 /*scaleFactor*/)
.capturePlanNodeId(nationScanId)
.hashJoin(
{"n_regionkey"},
{"r_regionkey"},
PlanBuilder(planNodeIdGenerator)
.tableScan(
.tpchTableScan(
tpch::Table::TBL_REGION,
{"r_regionkey", "r_name"},
1.0 /*scaleFactor*/)
Expand All @@ -271,7 +273,7 @@ TEST_F(TpchConnectorTest, join) {

TEST_F(TpchConnectorTest, orderDateCount) {
auto plan = PlanBuilder()
.tableScan(Table::TBL_ORDERS, {"o_orderdate"}, 0.01)
.tpchTableScan(Table::TBL_ORDERS, {"o_orderdate"}, 0.01)
.filter("o_orderdate = '1992-01-01'::DATE")
.limit(0, 10, false)
.planNode();
Expand Down
6 changes: 3 additions & 3 deletions velox/docs/velox-in-10-min.rst
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ provide a split.
.. code-block:: c++

plan = PlanBuilder()
.tableScan(
.tpchTableScan(
tpch::Table::TBL_NATION,
{"n_nationkey", "n_name"},
1 /*scaleFactor*/)
Expand Down Expand Up @@ -367,14 +367,14 @@ IDs.
core::PlanNodeId nationScanId;
core::PlanNodeId regionScanId;
plan = PlanBuilder(planNodeIdGenerator)
.tableScan(
.tpchTableScan(
tpch::Table::TBL_NATION, {"n_regionkey"}, 1 /*scaleFactor*/)
.capturePlanNodeId(nationScanId)
.hashJoin(
{"n_regionkey"},
{"r_regionkey"},
PlanBuilder(planNodeIdGenerator)
.tableScan(
.tpchTableScan(
tpch::Table::TBL_REGION,
{"r_regionkey", "r_name"},
1 /*scaleFactor*/)
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/parquet/tests/ParquetTpchTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class ParquetTpchTest : public testing::Test {
auto tableSchema = tpch::getTableSchema(table);
auto columnNames = tableSchema->names();
auto plan = PlanBuilder()
.tableScan(table, std::move(columnNames), 0.01)
.tpchTableScan(table, std::move(columnNames), 0.01)
.planNode();
auto split =
exec::Split(std::make_shared<connector::tpch::TpchConnectorSplit>(
Expand Down
6 changes: 3 additions & 3 deletions velox/exec/tests/VeloxIn10MinDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void VeloxIn10MinDemo::run() {
// nation table and print first 10 rows.

plan = PlanBuilder()
.tableScan(
.tpchTableScan(
tpch::Table::TBL_NATION,
{"n_nationkey", "n_name"},
1 /*scaleFactor*/)
Expand All @@ -259,14 +259,14 @@ void VeloxIn10MinDemo::run() {
core::PlanNodeId nationScanId;
core::PlanNodeId regionScanId;
plan = PlanBuilder(planNodeIdGenerator)
.tableScan(
.tpchTableScan(
tpch::Table::TBL_NATION, {"n_regionkey"}, 1 /*scaleFactor*/)
.capturePlanNodeId(nationScanId)
.hashJoin(
{"n_regionkey"},
{"r_regionkey"},
PlanBuilder(planNodeIdGenerator)
.tableScan(
.tpchTableScan(
tpch::Table::TBL_REGION,
{"r_regionkey", "r_name"},
1 /*scaleFactor*/)
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/utils/PlanBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ PlanBuilder& PlanBuilder::tableScan(
.endTableScan();
}

PlanBuilder& PlanBuilder::tableScan(
PlanBuilder& PlanBuilder::tpchTableScan(
tpch::Table table,
std::vector<std::string>&& columnNames,
double scaleFactor) {
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/utils/PlanBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class PlanBuilder {
/// and scale factor.
/// @param columnNames The columns to be returned from that table.
/// @param scaleFactor The TPC-H scale factor.
PlanBuilder& tableScan(
PlanBuilder& tpchTableScan(
tpch::Table table,
std::vector<std::string>&& columnNames,
double scaleFactor = 1);
Expand Down

0 comments on commit b30c094

Please sign in to comment.