diff --git a/velox/exec/HashProbe.cpp b/velox/exec/HashProbe.cpp index 026c356a4fa1..356c326a80cf 100644 --- a/velox/exec/HashProbe.cpp +++ b/velox/exec/HashProbe.cpp @@ -1107,7 +1107,7 @@ RowVectorPtr HashProbe::getOutputInternal(bool toSpillOutput) { accumulatedNumOutput < operatorCtx_->driverCtx() ->queryConfig() .preferredOutputBatchBytes() && - outputBatchSize - numOut > 0) { + outputBatchSize > numOut) { mapping = folly::Range( outputRowMapping_->asMutable() + accumulatedNumOutput, @@ -1151,13 +1151,9 @@ RowVectorPtr HashProbe::createFilterInput( vector_size_t size, vector_size_t offset) { BufferPtr outputRowMapping = outputRowMapping_; - if (offset > 0) { - outputRowMapping = BaseVector::sliceBuffer( - *INTEGER(), - outputRowMapping_, - offset, - outputTableRowsCapacity_ - offset, - pool()); + if (offset > 0 && outputRowMapping_) { + outputRowMapping = Buffer::slice( + outputRowMapping_, offset, outputTableRowsCapacity_ - offset, pool()); } std::vector filterColumns(filterInputType_->size()); for (auto projection : filterInputProjections_) {