use of io.cdap.cdap.proto.metadata.lineage.DatasetField in project cdap by caskdata.
the class FieldLineageAdmin method convertSummaryToDatasetField.
private Set<DatasetField> convertSummaryToDatasetField(Set<EndPointField> summary) {
Map<DatasetId, Set<String>> endPointFields = convertSummaryToDatasetMap(summary);
Set<DatasetField> result = new HashSet<>();
for (Map.Entry<DatasetId, Set<String>> entry : endPointFields.entrySet()) {
result.add(new DatasetField(entry.getKey(), entry.getValue()));
}
return result;
}
use of io.cdap.cdap.proto.metadata.lineage.DatasetField in project cdap by caskdata.
the class FieldLineageAdminTest method testSummary.
@Test
public void testSummary() {
FieldLineageAdmin fieldLineageAdmin = new FieldLineageAdmin(new FakeFieldLineageReader(Collections.emptySet(), summary(), Collections.emptySet()), metadataAdmin);
EndPoint endPoint = EndPoint.of("ns", "file");
DatasetField datasetField = new DatasetField(new DatasetId("ns", "file"), new HashSet<>(Arrays.asList("a", "b", "c")));
DatasetField anotherDatasetField = new DatasetField(new DatasetId("ns", "anotherfile"), new HashSet<>(Arrays.asList("x", "y", "z")));
Set<DatasetField> expected = new HashSet<>();
expected.add(datasetField);
expected.add(anotherDatasetField);
// input args to the getFieldLineage below does not matter since data returned is mocked
FieldLineageSummary summary = fieldLineageAdmin.getFieldLineage(Constants.FieldLineage.Direction.INCOMING, new EndPointField(endPoint, "somefield"), 0, Long.MAX_VALUE);
Assert.assertEquals(expected, summary.getIncoming());
Assert.assertNull(summary.getOutgoing());
summary = fieldLineageAdmin.getFieldLineage(Constants.FieldLineage.Direction.OUTGOING, new EndPointField(endPoint, "somefield"), 0, Long.MAX_VALUE);
Assert.assertEquals(expected, summary.getOutgoing());
Assert.assertNull(summary.getIncoming());
summary = fieldLineageAdmin.getFieldLineage(Constants.FieldLineage.Direction.BOTH, new EndPointField(endPoint, "somefield"), 0, Long.MAX_VALUE);
Assert.assertEquals(expected, summary.getOutgoing());
Assert.assertEquals(expected, summary.getIncoming());
}
Aggregations