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 10, 2023
1 parent d6b41e2 commit 48e2cf4
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 @@ -1953,10 +1953,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 @@ -1971,9 +1970,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 48e2cf4

Please sign in to comment.