Skip to content

Commit abc038e

Browse files
authored
JobTracker reports enum values (#12885)
1 parent 6bbd715 commit abc038e

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

airbyte-scheduler/persistence/src/main/java/io/airbyte/scheduler/persistence/job_tracker/JobTracker.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ protected static Map<String, Object> configToMetadata(final String jsonPath, fin
209209
* array) then returns a map of {null: toMetadataValue(config)}.
210210
*/
211211
private static Map<String, Object> configToMetadata(final JsonNode config, final JsonNode schema) {
212-
if (schema.hasNonNull("const")) {
213-
// If this schema is a const, then just dump it into a map:
212+
if (schema.hasNonNull("const") || schema.hasNonNull("enum")) {
213+
// If this schema is a const or an enum, then just dump it into a map:
214214
// * If it's an object, flatten it
215215
// * Otherwise, do some basic conversions to value-ish data.
216216
// It would be a weird thing to declare const: null, but in that case we don't want to report null

airbyte-scheduler/persistence/src/main/resources/example_config.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
}
1717
},
1818
"const_null": null,
19+
"enum_string": "foo",
1920
"additionalPropertiesUnset": {
2021
"foo": "bar"
2122
},
@@ -27,5 +28,6 @@
2728
},
2829
"additionalPropertiesConst": {
2930
"foo": 42
30-
}
31+
},
32+
"additionalPropertiesEnumString": "foo"
3133
}

airbyte-scheduler/persistence/src/main/resources/example_config_schema.json

+8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
"const_null": {
4545
"const": null
4646
},
47+
"enum_string": {
48+
"type": "string",
49+
"enum": ["foo", "bar"]
50+
},
4751
"additionalPropertiesUnset": {
4852
"type": "object"
4953
},
@@ -62,6 +66,10 @@
6266
"additionalProperties": {
6367
"const": 42
6468
}
69+
},
70+
"additionalPropertiesEnumString": {
71+
"type": "string",
72+
"enum": ["foo", "bar"]
6573
}
6674
}
6775
}

airbyte-scheduler/persistence/src/test/java/io/airbyte/scheduler/persistence/job_tracker/JobTrackerTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,12 @@ void testConfigToMetadata() throws IOException {
320320
.put(JobTracker.CONFIG + ".const_object.sub_key", "bar")
321321
.put(JobTracker.CONFIG + ".const_object.sub_array", "[1,2,3]")
322322
.put(JobTracker.CONFIG + ".const_object.sub_object.sub_sub_key", "baz")
323+
.put(JobTracker.CONFIG + ".enum_string", "foo")
323324
.put(JobTracker.CONFIG + ".additionalPropertiesUnset.foo", JobTracker.SET)
324325
.put(JobTracker.CONFIG + ".additionalPropertiesBoolean.foo", JobTracker.SET)
325326
.put(JobTracker.CONFIG + ".additionalPropertiesSchema.foo", JobTracker.SET)
326327
.put(JobTracker.CONFIG + ".additionalPropertiesConst.foo", 42)
328+
.put(JobTracker.CONFIG + ".additionalPropertiesEnumString", "foo")
327329
.build();
328330

329331
final Map<String, Object> actual = JobTracker.configToMetadata(JobTracker.CONFIG, config, schema);

0 commit comments

Comments
 (0)