Skip to content
This repository was archived by the owner on Aug 31, 2022. It is now read-only.

Be able to pass success to BigQueryOperation #209

Closed
wants to merge 1 commit into from
Closed
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 @@ -61,6 +61,10 @@ static <T> BigQueryOperation<T> ofJob(Fn<JobInfo> job) {
return new BigQueryOperation<T>().job(job);
}

static <T> BigQueryOperation<T> ofJob(Fn<JobInfo> job, F1<JobInfo, T> success) {
return new BigQueryOperation<T>().job(job).success(success);
}

public static class Provider<T> implements Serializable {

private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -95,5 +99,9 @@ public BigQueryOperation<T> job(Fn<JobInfo> jobInfo) {
public BigQueryOperation<T> job(JobInfo jobInfo) {
return BigQueryOperation.ofJob(() -> jobInfo);
}

public BigQueryOperation<T> job(JobInfo jobInfo, F1<JobInfo, T> success) {
return BigQueryOperation.ofJob(() -> jobInfo, success);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,26 @@ public void shouldRunLoadJobInTestMode() throws Exception {
}
}

@Test
public void shouldRunLoadJobInTestModeWithSuccess() throws Exception {
final TableId dstTable = TableId.of("foo", "bar", "baz");
final String srcUri = "gs://foo/bar";

final Task<TableId> task = Task.named("task")
.ofType(TableId.class)
.operator(BigQueryOperator.create())
.process(bq -> bq.job(
JobInfo.of(LoadJobConfiguration.of(dstTable, srcUri)), response -> dstTable));

try (TestScope scope = FloTesting.scope()) {

final TableId result = FloRunner.runTask(task).future()
.get(30, SECONDS);

assertThat(result, is(dstTable));
}
}

@Test
public void shouldRunExtractJobInTestMode() throws Exception {
final TableId srcTable = TableId.of("foo", "bar", "baz");
Expand Down