Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add jobVersion field to Run in Java client #2808

Merged
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
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
Loading