This is an automated email from the ASF dual-hosted git repository.
marong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 6e49a6f906 remove validateLiteral & codestyle (#8780)
6e49a6f906 is described below
commit 6e49a6f9068a1a48afe65137d27d6e557e5a57fc
Author: Rong Ma <[email protected]>
AuthorDate: Wed Feb 19 18:35:40 2025 +0000
remove validateLiteral & codestyle (#8780)
---
.../substrait/SubstraitToVeloxPlanValidator.cc | 88 ++++++++++------------
.../substrait/SubstraitToVeloxPlanValidator.h | 3 -
2 files changed, 38 insertions(+), 53 deletions(-)
diff --git a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
index cfc8498555..0b92a76148 100644
--- a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
+++ b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
@@ -213,9 +213,11 @@ bool SubstraitToVeloxPlanValidator::validateScalarFunction(
if (name == "round") {
return validateRound(scalarFunction, inputType);
- } else if (name == "extract") {
+ }
+ if (name == "extract") {
return validateExtractExpr(params);
- } else if (name == "concat") {
+ }
+ if (name == "concat") {
for (const auto& type : types) {
if (type.find("struct") != std::string::npos || type.find("map") !=
std::string::npos ||
type.find("list") != std::string::npos) {
@@ -238,27 +240,6 @@ bool SubstraitToVeloxPlanValidator::validateScalarFunction(
return true;
}
-bool SubstraitToVeloxPlanValidator::validateLiteral(
- const ::substrait::Expression_Literal& literal,
- const RowTypePtr& inputType) {
- if (literal.has_list()) {
- for (auto child : literal.list().values()) {
- if (!validateLiteral(child, inputType)) {
- // the error msg has been set, so do not need to set it again.
- return false;
- }
- }
- } else if (literal.has_map()) {
- for (auto child : literal.map().key_values()) {
- if (!validateLiteral(child.key(), inputType) ||
!validateLiteral(child.value(), inputType)) {
- // the error msg has been set, so do not need to set it again.
- return false;
- }
- }
- }
- return true;
-}
-
bool SubstraitToVeloxPlanValidator::validateCast(
const ::substrait::Expression::Cast& castExpr,
const RowTypePtr& inputType) {
@@ -334,9 +315,6 @@ bool SubstraitToVeloxPlanValidator::validateSingularOrList(
LOG_VALIDATION_MSG("Option is expected as Literal.");
return false;
}
- if (!validateLiteral(option.literal(), inputType)) {
- return false;
- }
}
return validateExpression(singularOrList.value(), inputType);
@@ -349,8 +327,6 @@ bool SubstraitToVeloxPlanValidator::validateExpression(
switch (typeCase) {
case ::substrait::Expression::RexTypeCase::kScalarFunction:
return validateScalarFunction(expression.scalar_function(), inputType);
- case ::substrait::Expression::RexTypeCase::kLiteral:
- return validateLiteral(expression.literal(), inputType);
case ::substrait::Expression::RexTypeCase::kCast:
return validateCast(expression.cast(), inputType);
case ::substrait::Expression::RexTypeCase::kIfThen:
@@ -745,9 +721,8 @@ bool SubstraitToVeloxPlanValidator::validate(const
::substrait::WindowGroupLimit
if (exprField == nullptr) {
LOG_VALIDATION_MSG("Only field is supported for partition key in Window
Group Limit Operator!");
return false;
- } else {
- expressions.emplace_back(expression);
}
+ expressions.emplace_back(expression);
}
// Try to compile the expressions. If there is any unregistered function or
// mismatched type, exception will be thrown.
@@ -1319,46 +1294,58 @@ bool SubstraitToVeloxPlanValidator::validate(const
::substrait::ReadRel& readRel
bool SubstraitToVeloxPlanValidator::validate(const ::substrait::Rel& rel) {
if (rel.has_aggregate()) {
return validate(rel.aggregate());
- } else if (rel.has_project()) {
+ }
+ if (rel.has_project()) {
return validate(rel.project());
- } else if (rel.has_filter()) {
+ }
+ if (rel.has_filter()) {
return validate(rel.filter());
- } else if (rel.has_join()) {
+ }
+ if (rel.has_join()) {
return validate(rel.join());
- } else if (rel.has_cross()) {
+ }
+ if (rel.has_cross()) {
return validate(rel.cross());
- } else if (rel.has_read()) {
+ }
+ if (rel.has_read()) {
return validate(rel.read());
- } else if (rel.has_sort()) {
+ }
+ if (rel.has_sort()) {
return validate(rel.sort());
- } else if (rel.has_expand()) {
+ }
+ if (rel.has_expand()) {
return validate(rel.expand());
- } else if (rel.has_generate()) {
+ }
+ if (rel.has_generate()) {
return validate(rel.generate());
- } else if (rel.has_fetch()) {
+ }
+ if (rel.has_fetch()) {
return validate(rel.fetch());
- } else if (rel.has_top_n()) {
+ }
+ if (rel.has_top_n()) {
return validate(rel.top_n());
- } else if (rel.has_window()) {
+ }
+ if (rel.has_window()) {
return validate(rel.window());
- } else if (rel.has_write()) {
+ }
+ if (rel.has_write()) {
return validate(rel.write());
- } else if (rel.has_windowgrouplimit()) {
+ }
+ if (rel.has_windowgrouplimit()) {
return validate(rel.windowgrouplimit());
- } else if (rel.has_set()) {
+ }
+ if (rel.has_set()) {
return validate(rel.set());
- } else {
- LOG_VALIDATION_MSG("Unsupported relation type: " + rel.GetTypeName());
- return false;
}
+ LOG_VALIDATION_MSG("Unsupported relation type: " + rel.GetTypeName());
+ return false;
}
bool SubstraitToVeloxPlanValidator::validate(const ::substrait::RelRoot&
relRoot) {
if (relRoot.has_input()) {
return validate(relRoot.input());
- } else {
- return false;
}
+ return false;
}
bool SubstraitToVeloxPlanValidator::validate(const ::substrait::Plan& plan) {
@@ -1370,7 +1357,8 @@ bool SubstraitToVeloxPlanValidator::validate(const
::substrait::Plan& plan) {
for (const auto& rel : plan.relations()) {
if (rel.has_root()) {
return validate(rel.root());
- } else if (rel.has_rel()) {
+ }
+ if (rel.has_rel()) {
return validate(rel.rel());
}
}
diff --git a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.h
b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.h
index befc884a42..100c4dc95d 100644
--- a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.h
+++ b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.h
@@ -141,9 +141,6 @@ class SubstraitToVeloxPlanValidator {
/// Validate Substrait expression.
bool validateExpression(const ::substrait::Expression& expression, const
RowTypePtr& inputType);
- /// Validate Substrait literal.
- bool validateLiteral(const ::substrait::Expression_Literal& literal, const
RowTypePtr& inputType);
-
/// Validate Substrait if-then expression.
bool validateIfThen(const ::substrait::Expression_IfThen& ifThen, const
RowTypePtr& inputType);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]