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(lineage): fix lighting cache dataJob platform #10233

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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.google.common.collect.Lists;
import com.linkedin.common.UrnArrayArray;
import com.linkedin.common.urn.Urn;
import com.linkedin.common.urn.UrnUtils;
import com.linkedin.data.template.LongMap;
import com.linkedin.data.template.StringArray;
import com.linkedin.metadata.Constants;
Expand Down Expand Up @@ -469,10 +470,15 @@ private AggregationMetadata constructAggMetadata(String displayName, String name
.setFilterValues(new FilterValueArray());
}

private String getPlatform(String entityType, Urn entityUrn) {
@VisibleForTesting
String getPlatform(String entityType, Urn entityUrn) {
String platform = null;
if (PLATFORM_ENTITY_TYPES.contains(entityType)) {
platform = entityUrn.getEntityKey().get(0);
if (DATA_JOB_ENTITY_NAME.equals(entityType)) {
platform = UrnUtils.getUrn(entityUrn.getEntityKey().get(0)).getEntityKey().get(0);
} else {
platform = entityUrn.getEntityKey().get(0);
}
}
if ((platform != null) && (!platform.startsWith("urn:li:dataPlatform"))) {
platform = "urn:li:dataPlatform:" + platform;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1338,4 +1338,31 @@ public void testCanDoLightning() throws Exception {
filter = new Filter().setOr(conCritArr);
Assert.assertTrue(lineageSearchService.canDoLightning(lineageRelationships, "*", filter, null));
}

@Test
public void testPlatform() {
assertEquals(
lineageSearchService.getPlatform(
"dataset",
UrnUtils.getUrn(
"urn:li:dataset:(urn:li:dataPlatform:custom,file:///custom/path,PROD)")),
"urn:li:dataPlatform:custom");
assertEquals(
lineageSearchService.getPlatform(
"chart", UrnUtils.getUrn("urn:li:chart:(looker,foobar.1234)")),
"urn:li:dataPlatform:looker");
assertEquals(
lineageSearchService.getPlatform(
"dashboard", UrnUtils.getUrn("urn:li:dashboard:(looker,dashboards.1234)")),
"urn:li:dataPlatform:looker");
assertEquals(
lineageSearchService.getPlatform(
"dataFlow", UrnUtils.getUrn("urn:li:dataFlow:(airflow,foobar,PROD)")),
"urn:li:dataPlatform:airflow");
assertEquals(
lineageSearchService.getPlatform(
"dataJob",
UrnUtils.getUrn("urn:li:dataJob:(urn:li:dataFlow:(airflow,foobar,PROD),End)")),
"urn:li:dataPlatform:airflow");
}
}
Loading