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

fix(gms/patch): Fix Upstream lineage patching when path contained encoded slash #296

Closed
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 @@ -81,14 +81,13 @@ public static JsonNode populateTopLevelKeys(JsonNode transformedNode, JsonPatch
PatchOperationType.REMOVE.equals(operationPath.getFirst())
? keys.length
: keys.length - 1;

// Skip first as it will always be blank due to path starting with /
for (int i = 1; i < endIdx; i++) {
if (parent.get(keys[i]) == null) {
String decodedKey = decodeValue(keys[i]);
((ObjectNode) parent).set(decodedKey, instance.objectNode());
}
parent = parent.get(keys[i]);
parent = parent.get(decodeValue(keys[i]));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,29 @@ public void testPatchUpstream() throws Exception {
// New entry in array because of new transformation type
assertEquals(result4.getFineGrainedLineages().get(3), fineGrainedLineage4);

JsonPatchBuilder patchOperations5 = Json.createPatchBuilder();
String urn4 =
"urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:s3,test-bucket/hive/folder_1/folder_2/my_dataset,DEV),c2)";
UrnArray downstreamUrns5 = new UrnArray();
downstreamUrns5.add(Urn.createFromString(urn4));
patchOperations5.add(
"/fineGrainedLineages/TRANSFORM/urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:s3,test-bucket~1hive~1folder_1~1folder_2~1my_dataset,DEV),c2)/urn:li:query:anotherQuery/urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:bigquery,upstream_table_1,PROD),c2)",
finegrainedLineageNode5.build());
JsonPatch jsonPatch5 = patchOperations5.build();
UpstreamLineage result5 = upstreamLineageTemplate.applyPatch(result4, jsonPatch5);
// Hack because Jackson parses values to doubles instead of floats
DataMap dataMap5 = new DataMap();
dataMap5.put("confidenceScore", 1.0);
FineGrainedLineage fineGrainedLineage5 = new FineGrainedLineage(dataMap5);
fineGrainedLineage5.setUpstreams(upstreamUrns3);
fineGrainedLineage5.setDownstreams(downstreamUrns5);
fineGrainedLineage5.setTransformOperation("TRANSFORM");
fineGrainedLineage5.setUpstreamType(FineGrainedLineageUpstreamType.FIELD_SET);
fineGrainedLineage5.setDownstreamType(FineGrainedLineageDownstreamType.FIELD);
fineGrainedLineage5.setQuery(UrnUtils.getUrn("urn:li:query:anotherQuery"));
// New entry in array because of new transformation type
assertEquals(result5.getFineGrainedLineages().get(4), fineGrainedLineage5);

// Remove
JsonPatchBuilder removeOperations = Json.createPatchBuilder();
removeOperations.remove(
Expand Down
Loading