Skip to content

Commit

Permalink
feat: add jobVersion field to Run in Java client
Browse files Browse the repository at this point in the history
Signed-off-by: David Goss <david@davidgoss.co>
  • Loading branch information
davidjgoss committed Apr 26, 2024
1 parent c553401 commit 0bc383f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clients/java/src/main/java/marquez/client/models/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public final class Run extends RunMeta {
@Nullable private final Instant startedAt;
@Nullable private final Long durationMs;
@Nullable private final Instant endedAt;
@Nullable private final JobVersionId jobVersion;
@Getter private final Map<String, Object> facets;
@Getter private final List<InputDatasetVersion> inputDatasetVersions;
@Getter private final List<OutputDatasetVersion> outputDatasetVersions;
Expand All @@ -43,6 +44,7 @@ public Run(
@Nullable final Instant endedAt,
@Nullable final Long durationMs,
@Nullable final Map<String, String> args,
@Nullable final JobVersionId jobVersion,
@Nullable final Map<String, Object> facets,
@Nullable final List<InputDatasetVersion> inputDatasetVersions,
@Nullable final List<OutputDatasetVersion> outputDatasetVersions) {
Expand All @@ -53,6 +55,7 @@ public Run(
this.startedAt = startedAt;
this.durationMs = durationMs;
this.endedAt = endedAt;
this.jobVersion = jobVersion;
this.facets = (facets == null) ? ImmutableMap.of() : ImmutableMap.copyOf(facets);
this.inputDatasetVersions =
(inputDatasetVersions == null) ? Collections.emptyList() : inputDatasetVersions;
Expand All @@ -72,6 +75,10 @@ public Optional<Long> getDurationMs() {
return Optional.ofNullable(durationMs);
}

public Optional<JobVersionId> getJobVersion() {
return Optional.ofNullable(jobVersion);
}

public boolean hasFacets() {
return !facets.isEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import marquez.client.models.JobId;
import marquez.client.models.JobMeta;
import marquez.client.models.JobType;
import marquez.client.models.JobVersionId;
import marquez.client.models.JsonGenerator;
import marquez.client.models.LineageEvent;
import marquez.client.models.Namespace;
Expand Down Expand Up @@ -243,6 +244,8 @@ public class MarquezClientTest {
private static final URL LOCATION = newLocation();
private static final JobType JOB_TYPE = newJobType();
private static final String JOB_DESCRIPTION = newDescription();
private static final JobVersionId JOB_VERSION =
new JobVersionId(JOB_ID.getNamespace(), JOB_ID.getName(), CURRENT_VERSION);
private static final Job JOB =
new Job(
JOB_ID,
Expand Down Expand Up @@ -287,6 +290,7 @@ public class MarquezClientTest {
ENDED_AT,
DURATION,
RUN_ARGS,
JOB_VERSION,
null,
INPUT_RUN_DATASET_FACETS,
OUTPUT_RUN_DATASET_FACETS);
Expand All @@ -302,6 +306,7 @@ public class MarquezClientTest {
ENDED_AT,
DURATION,
RUN_ARGS,
JOB_VERSION,
null,
INPUT_RUN_DATASET_FACETS,
OUTPUT_RUN_DATASET_FACETS);
Expand All @@ -317,6 +322,7 @@ public class MarquezClientTest {
ENDED_AT,
DURATION,
RUN_ARGS,
JOB_VERSION,
null,
INPUT_RUN_DATASET_FACETS,
OUTPUT_RUN_DATASET_FACETS);
Expand All @@ -332,6 +338,7 @@ public class MarquezClientTest {
ENDED_AT,
DURATION,
RUN_ARGS,
JOB_VERSION,
null,
INPUT_RUN_DATASET_FACETS,
OUTPUT_RUN_DATASET_FACETS);
Expand All @@ -347,6 +354,7 @@ public class MarquezClientTest {
ENDED_AT,
DURATION,
RUN_ARGS,
JOB_VERSION,
null,
INPUT_RUN_DATASET_FACETS,
OUTPUT_RUN_DATASET_FACETS);
Expand Down Expand Up @@ -377,6 +385,7 @@ public class MarquezClientTest {
ENDED_AT,
DURATION,
RUN_ARGS,
JOB_VERSION,
null,
INPUT_RUN_DATASET_FACETS,
OUTPUT_RUN_DATASET_FACETS),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,18 @@ private static ObjectNode toObj(final Run run) {
obj.put("startedAt", run.getStartedAt().map(ISO_INSTANT::format).orElse(null));
obj.put("endedAt", run.getEndedAt().map(ISO_INSTANT::format).orElse(null));
obj.put("durationMs", run.getDurationMs().orElse(null));
obj.set(
"jobVersion",
run.getJobVersion()
.map(
jobVersionId -> {
final ObjectNode jobVersion = MAPPER.createObjectNode();
jobVersion.put("namespace", jobVersionId.getNamespace());
jobVersion.put("name", jobVersionId.getName());
jobVersion.put("version", jobVersionId.getVersion().toString());
return jobVersion;
})
.orElse(null));
obj.putArray("inputDatasetVersions").addAll(inputDatasetVersions);
obj.putArray("outputDatasetVersions").addAll(outputDatasetVersions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public static Run newRun() {
newRunArgs(),
null,
null,
null,
null);
}

Expand Down

0 comments on commit 0bc383f

Please sign in to comment.