diff --git a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc index 2709fcda1d68..3b74caf8ba5a 100644 --- a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc +++ b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc @@ -288,7 +288,12 @@ bool SubstraitToVeloxPlanValidator::validateIfThen( const ::substrait::Expression_IfThen& ifThen, const RowTypePtr& inputType) { for (const auto& subIfThen : ifThen.ifs()) { - return validateExpression(subIfThen.if_(), inputType) && validateExpression(subIfThen.then(), inputType); + if (!validateExpression(subIfThen.if_(), inputType) || !validateExpression(subIfThen.then(), inputType)) { + return false; + } + } + if (ifThen.has_else_() && !validateExpression(ifThen.else_(), inputType)) { + return false; } return true; }