Skip to content

Instantly share code, notes, and snippets.

@serihiro
Created September 6, 2018 20:52
Show Gist options
  • Save serihiro/e4c7a346f43f2ebc20601544b20f7d16 to your computer and use it in GitHub Desktop.
Save serihiro/e4c7a346f43f2ebc20601544b20f7d16 to your computer and use it in GitHub Desktop.
temporary patch
diff --git a/digdag-standards/src/main/java/io/digdag/standards/operator/td/BaseTdJobOperator.java b/digdag-standards/src/main/java/io/digdag/standards/operator/td/BaseTdJobOperator.java
index 386a1499e..15c22ecd4 100644
--- a/digdag-standards/src/main/java/io/digdag/standards/operator/td/BaseTdJobOperator.java
+++ b/digdag-standards/src/main/java/io/digdag/standards/operator/td/BaseTdJobOperator.java
@@ -61,7 +61,10 @@ abstract class BaseTdJobOperator
// Set last_job_id param
taskResult.getStoreParams()
.getNestedOrSetEmpty("td")
- .set("last_job_id", job.getJobId());
+ .set("last_job_id", job.getJobId()) // for compatibility with old style
+ .getNestedOrSetEmpty("last_job")
+ .set("id", job.getJobId())
+ .set("num_records", job.getJobInfo().getNumRecords());
return taskResult;
}
diff --git a/digdag-tests/src/test/java/acceptance/td/TdIT.java b/digdag-tests/src/test/java/acceptance/td/TdIT.java
index 3f7977661..562208885 100644
--- a/digdag-tests/src/test/java/acceptance/td/TdIT.java
+++ b/digdag-tests/src/test/java/acceptance/td/TdIT.java
@@ -50,6 +50,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import static acceptance.td.Secrets.ENCRYPTION_KEY;
+import static acceptance.td.Secrets.TD_API_ENDPOINT;
import static acceptance.td.Secrets.TD_API_KEY;
import static acceptance.td.Secrets.TD_SECRETS_ENABLED_PROP_KEY;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONNECTION;
@@ -111,6 +112,7 @@ public class TdIT
env.put("TD_CONFIG_PATH", noTdConf);
client = TDClient.newBuilder(false)
+ .setEndpoint(TD_API_ENDPOINT)
.setApiKey(TD_API_KEY)
.build();
database = "tmp_" + UUID.randomUUID().toString().replace('-', '_');
@@ -172,6 +174,8 @@ public class TdIT
assertWorkflowRunsSuccessfully();
JsonNode result = objectMapper().readTree(outfile.toFile());
assertThat(result.get("last_job_id").asInt(), is(not(0)));
+ assertThat(result.get("last_job").get("id").asInt(), is(not(0)));
+ assertThat(result.get("last_job").get("num_records").asInt(), is(1));
assertThat(result.get("last_results").isObject(), is(true));
assertThat(result.get("last_results").isEmpty(objectMapper().getSerializerProvider()), is(false));
assertThat(result.get("last_results").get("a").asInt(), is(1));
@@ -186,6 +190,8 @@ public class TdIT
assertWorkflowRunsSuccessfully();
JsonNode result = objectMapper().readTree(outfile.toFile());
assertThat(result.get("last_job_id").asInt(), is(not(0)));
+ assertThat(result.get("last_job").get("id").asInt(), is(not(0)));
+ assertThat(result.get("last_job").get("num_records").asInt(), is(0));
assertThat(result.get("last_results").isObject(), is(true));
assertThat(result.get("last_results").isEmpty(objectMapper().getSerializerProvider()), is(true));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment