Skip to content

Commit

Permalink
Allow decimal types in switch expr
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo committed Oct 16, 2023
1 parent 94917a5 commit d46709e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions velox/expression/SwitchExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ SwitchExpr::SwitchExpr(

// Apply type checking.
auto typeExpected = resolveType(inputTypes);
VELOX_CHECK(
*typeExpected == *this->type(),
"Switch expression type different than then clause. Expected {} but got Actual {}.",
typeExpected->toString(),
this->type()->toString());
if (elseClauseType->isDecimal()) {
// Regard decimal types as the same regardless of precision and scale.
VELOX_CHECK(expressionType->isDecimal());
} else {
VELOX_CHECK(
*typeExpected == *this->type(),
"Switch expression type different than then clause. Expected {} but got Actual {}.",
typeExpected->toString(),
this->type()->toString());
}
}

void SwitchExpr::evalSpecialForm(
Expand Down

0 comments on commit d46709e

Please sign in to comment.