Skip to content

Commit 4e3cf23

Browse files
committed
Prevent exception when no input for update
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
1 parent 0299a29 commit 4e3cf23

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

presto-main/src/main/java/com/facebook/presto/operator/AbstractRowChangeOperator.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.facebook.presto.common.block.RunLengthEncodedBlock;
2020
import com.facebook.presto.execution.TaskId;
2121
import com.facebook.presto.spi.UpdatablePageSource;
22+
import com.facebook.presto.split.EmptySplitPageSource;
2223
import com.google.common.util.concurrent.ListenableFuture;
2324
import io.airlift.slice.Slice;
2425

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

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

0 commit comments

Comments
 (0)