Skip to content

Commit

Permalink
Prevent exception when no input for update
Browse files Browse the repository at this point in the history
Without this change, the UpdateOperator would throw an exception
stating that there was no valid page source. This occurs because the
driver which is responsible for setting the UpdateablePageSource
never calls the proper method due to never receiving any inputs.

This now handles the case where the page source is never set by
returning an EmptySplitPageSource
  • Loading branch information
ZacBlanco committed Feb 7, 2025
1 parent 003d86a commit 72be233
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.facebook.presto.common.block.RunLengthEncodedBlock;
import com.facebook.presto.execution.TaskId;
import com.facebook.presto.spi.UpdatablePageSource;
import com.facebook.presto.split.EmptySplitPageSource;
import com.google.common.util.concurrent.ListenableFuture;
import io.airlift.slice.Slice;

Expand All @@ -31,7 +32,6 @@
import static com.facebook.presto.common.type.BigintType.BIGINT;
import static com.facebook.presto.common.type.VarbinaryType.VARBINARY;
import static com.facebook.presto.operator.PageSinkCommitStrategy.NO_COMMIT;
import static com.google.common.base.Preconditions.checkState;
import static io.airlift.slice.Slices.wrappedBuffer;
import static java.util.Objects.requireNonNull;

Expand Down Expand Up @@ -170,7 +170,7 @@ public void setPageSource(Supplier<Optional<UpdatablePageSource>> pageSource)
protected UpdatablePageSource pageSource()
{
Optional<UpdatablePageSource> source = pageSource.get();
checkState(source.isPresent(), "UpdatablePageSource not set");
return source.get();
// empty source can occur if the source operator doesn't output any rows
return source.orElseGet(EmptySplitPageSource::new);
}
}

0 comments on commit 72be233

Please sign in to comment.