Search in sources :

Example 1 with DatasetField

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;
}
Also used : HashSet(java.util.HashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) DatasetField(io.cdap.cdap.proto.metadata.lineage.DatasetField) HashMap(java.util.HashMap) Map(java.util.Map) DatasetId(io.cdap.cdap.proto.id.DatasetId) HashSet(java.util.HashSet)

Example 2 with DatasetField

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());
}
Also used : FieldLineageSummary(io.cdap.cdap.proto.metadata.lineage.FieldLineageSummary) EndPointField(io.cdap.cdap.data2.metadata.lineage.field.EndPointField) DatasetField(io.cdap.cdap.proto.metadata.lineage.DatasetField) EndPoint(io.cdap.cdap.api.lineage.field.EndPoint) DatasetId(io.cdap.cdap.proto.id.DatasetId) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

DatasetId (io.cdap.cdap.proto.id.DatasetId)2 DatasetField (io.cdap.cdap.proto.metadata.lineage.DatasetField)2 HashSet (java.util.HashSet)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 EndPoint (io.cdap.cdap.api.lineage.field.EndPoint)1 EndPointField (io.cdap.cdap.data2.metadata.lineage.field.EndPointField)1 FieldLineageSummary (io.cdap.cdap.proto.metadata.lineage.FieldLineageSummary)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 Test (org.junit.Test)1