Class SpannerSource
java.lang.Object
io.github.flink.gcp.connector.spanner.source.SpannerSource
Reads rows from a Cloud Spanner database.
Source<Singer, ?, ?> source =
SpannerSource.<Singer>builder()
.database(DatabaseDestination.of("my-project", "my-instance", "my-db"))
.readOperation(
SpannerReadOperation.query(
Statement.of("SELECT id, name FROM singers")))
.deserializer(mySingerDeserializer)
.build();
The read is bounded: the source reads the rows the operation names, at one snapshot, and finishes. That is not the same as batch-only — a bounded source runs inside a streaming pipeline and simply ends, which is what makes reading a Spanner table and joining it against an unbounded stream work.
Every subtask reads the same snapshot. The source asks Spanner to divide the read into partitions at one timestamp, and each subtask rejoins that transaction to read the partitions it was given. There is no column to split on and no bounds to supply: where the divisions fall is the service's decision, made from how the data is actually stored.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> SpannerSourceBuilder<T>builder()Returns a builder for a Spanner batch source.
-
Method Details
-
builder
Returns a builder for a Spanner batch source.- Type Parameters:
T- the record type produced- Returns:
- the builder
-