Skip to content

Commit

Permalink
Fix column case
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Feb 27, 2024
1 parent a57b102 commit f93d05c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions velox/exec/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,13 @@ void updateKRowsOffsetsColumn(
// moves ahead.
int precedingFactor = isKPreceding ? -1 : 1;
for (auto i = 0; i < numRows; i++) {
rawFrameBounds[i] =
(startRow + i) + vector_size_t(precedingFactor * offsets[i]);
auto startValue = (int64_t)(startRow + i) + precedingFactor * offsets[i];
// Considers integer overflow case.
if (startValue != (int32_t)startValue) {
rawFrameBounds[i] = startValue < 0 ? 0 : numRows - 1;
} else {
rawFrameBounds[i] = startValue;
}
}
}

Expand All @@ -301,12 +306,12 @@ void Window::updateKRowsFrameBounds(
auto constantOffset = frameArg.constant.value();
auto startValue =
(isKPreceding ? -constantOffset : constantOffset) + startRow;
// std::iota(rawFrameBounds, rawFrameBounds + numRows, startValue);
for (int i = 0; i < numRows; i++) {
// Considers integer overflow case.
if (startValue != (int32_t)startValue) {
*(rawFrameBounds + i) = startValue < 0 ? 0 : numRows - 1;
rawFrameBounds[i] = startValue < 0 ? 0 : numRows - 1;
} else {
*(rawFrameBounds + i) = startValue;
rawFrameBounds[i] = startValue;
}
startValue = startValue + 1;
}
Expand Down

0 comments on commit f93d05c

Please sign in to comment.