Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ public void setup() throws Exception {
spannerAccessor = SpannerAccessor.getOrCreate(config);
projectId =
this.config.getProjectId() == null
|| this.config.getProjectId().get() == null
|| this.config.getProjectId().get().isEmpty()
? SpannerOptions.getDefaultProjectId()
: this.config.getProjectId().get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,8 @@ public void setup() {

projectId =
this.spannerConfig.getProjectId() == null
|| this.spannerConfig.getProjectId().get() == null
|| this.spannerConfig.getProjectId().get().isEmpty()
? SpannerOptions.getDefaultProjectId()
: this.spannerConfig.getProjectId().get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ public void runReadTestWithDefaultProject() throws Exception {
.withServiceFactory(serviceFactory));
}

@Test
public void runReadTestWithNullProject() throws Exception {
runReadTest(
SpannerConfig.create()
.withProjectId((String) null)
.withInstanceId("123")
.withDatabaseId("aaa")
.withServiceFactory(serviceFactory));
}

private void runReadTest(SpannerConfig spannerConfig) throws Exception {
Timestamp timestamp = Timestamp.ofTimeMicroseconds(12345);
TimestampBound timestampBound = TimestampBound.ofReadTimestamp(timestamp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,22 @@ public void singleMutationPipelineNoProjectId() throws Exception {
verifyBatches(batch(m(2L)));
}

@Test
public void singleMutationPipelineNullProjectId() throws Exception {
Mutation mutation = m(2L);
PCollection<Mutation> mutations = pipeline.apply(Create.of(mutation));

mutations.apply(
SpannerIO.write()
.withProjectId((String) null)
.withInstanceId("test-instance")
.withDatabaseId("test-database")
.withServiceFactory(serviceFactory));
pipeline.run();

verifyBatches(batch(m(2L)));
}

@Test
public void singleMutationGroupPipeline() throws Exception {
PCollection<MutationGroup> mutations =
Expand Down