Skip to content

Commit

Permalink
Fixed narrowing issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
EpsilonPrime committed Jul 5, 2023
1 parent f460187 commit 42a28d3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/substrait/textplan/parser/SubstraitPlanRelationVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1954,10 +1954,9 @@ int SubstraitPlanRelationVisitor::findFieldReferenceByName(
auto fieldPlacement =
generatedField - relationData->generatedFieldReferences.rbegin();
return static_cast<int32_t>(
(relationData->generatedFieldReferences.size() -
fieldPlacement) &
std::numeric_limits<int32_t>::max()) -
1 + fieldReferencesSize;
(fieldReferencesSize + relationData->generatedFieldReferences.size() -
fieldPlacement - 1) &
std::numeric_limits<int32_t>::max());
}

auto field = std::find_if(
Expand All @@ -1972,9 +1971,8 @@ int SubstraitPlanRelationVisitor::findFieldReferenceByName(
if (field != relationData->fieldReferences.rend()) {
auto fieldPlacement = field - relationData->fieldReferences.rbegin();
return static_cast<int32_t>(
(fieldReferencesSize - fieldPlacement) &
std::numeric_limits<int32_t>::max()) -
1;
(fieldReferencesSize - fieldPlacement - 1) &
std::numeric_limits<int32_t>::max());
}

errorListener_->addError(token, "Reference " + name + " does not exist.");
Expand Down

0 comments on commit 42a28d3

Please sign in to comment.