Skip to content

Commit

Permalink
refactor(special form): use constants for special form names (#11617)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #11617

Reviewed By: kevinwilfong, xiaoxmeng

Differential Revision: D66309395

fbshipit-source-id: 66ec11d278e31f7e68d0ea5c7a2901799e35d9dd
  • Loading branch information
Mingyu Zhang authored and facebook-github-bot committed Dec 11, 2024
1 parent 78bb289 commit f6b9f22
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
5 changes: 4 additions & 1 deletion velox/expression/ConjunctExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

namespace facebook::velox::exec {

constexpr const char* kAnd = "and";
constexpr const char* kOr = "or";

class ConjunctExpr : public SpecialForm {
public:
ConjunctExpr(
Expand All @@ -31,7 +34,7 @@ class ConjunctExpr : public SpecialForm {
: SpecialForm(
std::move(type),
std::move(inputs),
isAnd ? "and" : "or",
isAnd ? kAnd : kOr,
inputsSupportFlatNoNullsFastPath,
false /* trackCpuUsage */),
isAnd_(isAnd) {
Expand Down
16 changes: 8 additions & 8 deletions velox/expression/RegisterSpecialForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@
namespace facebook::velox::exec {
void registerFunctionCallToSpecialForms() {
registerFunctionCallToSpecialForm(
"and", std::make_unique<ConjunctCallToSpecialForm>(true /* isAnd */));
kAnd, std::make_unique<ConjunctCallToSpecialForm>(true /* isAnd */));
registerFunctionCallToSpecialForm(
"cast", std::make_unique<CastCallToSpecialForm>());
kCast.str(), std::make_unique<CastCallToSpecialForm>());
registerFunctionCallToSpecialForm(
"try_cast", std::make_unique<TryCastCallToSpecialForm>());
kTryCast.str(), std::make_unique<TryCastCallToSpecialForm>());
registerFunctionCallToSpecialForm(
"coalesce", std::make_unique<CoalesceCallToSpecialForm>());
kCoalesce, std::make_unique<CoalesceCallToSpecialForm>());
registerFunctionCallToSpecialForm(
"if", std::make_unique<IfCallToSpecialForm>());
kIf, std::make_unique<IfCallToSpecialForm>());
registerFunctionCallToSpecialForm(
"or", std::make_unique<ConjunctCallToSpecialForm>(false /* isAnd */));
kOr, std::make_unique<ConjunctCallToSpecialForm>(false /* isAnd */));
registerFunctionCallToSpecialForm(
"switch", std::make_unique<SwitchCallToSpecialForm>());
kSwitch, std::make_unique<SwitchCallToSpecialForm>());
registerFunctionCallToSpecialForm(
"try", std::make_unique<TryCallToSpecialForm>());
kTry, std::make_unique<TryCallToSpecialForm>());
registerFunctionCallToSpecialForm(
RowConstructorCallToSpecialForm::kRowConstructor,
std::make_unique<RowConstructorCallToSpecialForm>());
Expand Down
3 changes: 3 additions & 0 deletions velox/expression/SwitchExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

namespace facebook::velox::exec {

constexpr const char* kIf = "if";
constexpr const char* kSwitch = "switch";

/// CASE expression:
///
/// case
Expand Down
4 changes: 3 additions & 1 deletion velox/expression/TryExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@

namespace facebook::velox::exec {

constexpr const char* kTry = "try";

class TryExpr : public SpecialForm {
public:
/// Try expression adds nulls, hence, doesn't support flat-no-nulls fast path.
TryExpr(TypePtr type, ExprPtr&& input)
: SpecialForm(
std::move(type),
{std::move(input)},
"try",
kTry,
false /* supportsFlatNoNullsFastPath */,
false /* trackCpuUsage */) {}

Expand Down

0 comments on commit f6b9f22

Please sign in to comment.