Skip to content

Commit ec12473

Browse files
mbasmanovameta-codesync[bot]
authored andcommitted
refactor: Extract helper method verifyOutputNames in PlanConsistencyChecker (facebookincubator#15370)
Summary: Pull Request resolved: facebookincubator#15370 Reviewed By: amitkdutta Differential Revision: D86072214 fbshipit-source-id: 2f1c9006d372fd11f27254f97f4f74e5e9a131ff
1 parent cc305d4 commit ec12473

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

velox/core/PlanConsistencyChecker.cpp

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,7 @@ class Checker : public PlanNodeVisitor {
4545
}
4646
}
4747

48-
// Verify that output column names are not empty and unique.
49-
std::unordered_set<std::string> names;
50-
for (const auto& name : node.outputType()->names()) {
51-
VELOX_USER_CHECK(!name.empty(), "Output column name cannot be empty");
52-
VELOX_USER_CHECK(
53-
names.insert(name).second, "Duplicate output column: {}", name);
54-
}
48+
verifyOutputNames(node);
5549

5650
visitSources(&node, ctx);
5751
}
@@ -180,13 +174,7 @@ class Checker : public PlanNodeVisitor {
180174
checkInputs(expr, rowType);
181175
}
182176

183-
// Verify that output column names are not empty and unique.
184-
std::unordered_set<std::string> names;
185-
for (const auto& name : node.outputType()->names()) {
186-
VELOX_USER_CHECK(!name.empty(), "Output column name cannot be empty");
187-
VELOX_USER_CHECK(
188-
names.insert(name).second, "Duplicate output column: {}", name);
189-
}
177+
verifyOutputNames(node);
190178

191179
visitSources(&node, ctx);
192180
}
@@ -209,15 +197,10 @@ class Checker : public PlanNodeVisitor {
209197

210198
void visit(const TableScanNode& node, PlanNodeVisitorContext& ctx)
211199
const override {
212-
// Verify that output column names are not empty and unique.
213-
std::unordered_set<std::string> names;
214-
for (const auto& name : node.outputType()->names()) {
215-
VELOX_USER_CHECK(!name.empty(), "Output column name cannot be empty");
216-
VELOX_USER_CHECK(
217-
names.insert(name).second, "Duplicate output column: {}", name);
218-
}
200+
verifyOutputNames(node);
219201

220202
// Verify assignments match outputType 1:1.
203+
const auto& names = node.outputType()->names();
221204
VELOX_USER_CHECK_EQ(
222205
names.size(),
223206
node.assignments().size(),
@@ -281,6 +264,16 @@ class Checker : public PlanNodeVisitor {
281264
}
282265
}
283266

267+
// Verify that output column names are not empty and unique.
268+
static void verifyOutputNames(const PlanNode& node) {
269+
folly::F14FastSet<std::string_view> names;
270+
for (const auto& name : node.outputType()->names()) {
271+
VELOX_USER_CHECK(!name.empty(), "Output column name cannot be empty");
272+
VELOX_USER_CHECK(
273+
names.emplace(name).second, "Duplicate output column: {}", name);
274+
}
275+
}
276+
284277
static void checkInputs(
285278
const core::TypedExprPtr& expr,
286279
const RowTypePtr& rowType) {

0 commit comments

Comments
 (0)