-
Notifications
You must be signed in to change notification settings - Fork 3k
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(model): fixes DashboardContainsDashboard relationship in DashboardInfo aspect #12433
base: master
Are you sure you want to change the base?
Changes from all commits
c2e0dac
cad0b37
7c92a0e
0fa4114
6479072
43072d5
3c33063
00adc98
a502458
49e0dc2
b582b47
08bb142
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.linkedin.datahub.upgrade.config.restoreindices; | ||
|
||
import com.linkedin.datahub.upgrade.config.SystemUpdateCondition; | ||
import com.linkedin.datahub.upgrade.system.NonBlockingSystemUpgrade; | ||
import com.linkedin.datahub.upgrade.system.restoreindices.dashboardinfo.ReindexDashboardInfo; | ||
import com.linkedin.metadata.entity.AspectDao; | ||
import com.linkedin.metadata.entity.EntityService; | ||
import io.datahubproject.metadata.context.OperationContext; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@Conditional(SystemUpdateCondition.NonBlockingSystemUpdateCondition.class) | ||
public class ReindexDashboardInfoConfig { | ||
|
||
@Bean | ||
public NonBlockingSystemUpgrade reindexDashboardInfo( | ||
final OperationContext opContext, | ||
final EntityService<?> entityService, | ||
final AspectDao aspectDao, | ||
@Value("${systemUpdate.dashboardInfo.enabled}") final boolean enabled, | ||
@Value("${systemUpdate.dashboardInfo.batchSize}") final Integer batchSize, | ||
@Value("${systemUpdate.dashboardInfo.delayMs}") final Integer delayMs, | ||
@Value("${systemUpdate.dashboardInfo.limit}") final Integer limit) { | ||
return new ReindexDashboardInfo( | ||
opContext, entityService, aspectDao, enabled, batchSize, delayMs, limit); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.linkedin.datahub.upgrade.system.restoreindices.dashboardinfo; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.linkedin.datahub.upgrade.UpgradeStep; | ||
import com.linkedin.datahub.upgrade.system.NonBlockingSystemUpgrade; | ||
import com.linkedin.metadata.entity.AspectDao; | ||
import com.linkedin.metadata.entity.EntityService; | ||
import io.datahubproject.metadata.context.OperationContext; | ||
import java.util.List; | ||
import javax.annotation.Nonnull; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
/** | ||
* A job that reindexes all dashboard info aspects as part of reindexing dashboards relationship. | ||
* This is required to fix the dashboards relationships for dashboards | ||
*/ | ||
@Slf4j | ||
public class ReindexDashboardInfo implements NonBlockingSystemUpgrade { | ||
|
||
private final List<UpgradeStep> _steps; | ||
|
||
public ReindexDashboardInfo( | ||
@Nonnull OperationContext opContext, | ||
EntityService<?> entityService, | ||
AspectDao aspectDao, | ||
boolean enabled, | ||
Integer batchSize, | ||
Integer batchDelayMs, | ||
Integer limit) { | ||
if (enabled) { | ||
_steps = | ||
ImmutableList.of( | ||
new ReindexDashboardInfoStep( | ||
opContext, entityService, aspectDao, batchSize, batchDelayMs, limit)); | ||
} else { | ||
_steps = ImmutableList.of(); | ||
Check warning on line 36 in datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/system/restoreindices/dashboardinfo/ReindexDashboardInfo.java Codecov / codecov/patchdatahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/system/restoreindices/dashboardinfo/ReindexDashboardInfo.java#L36
|
||
} | ||
} | ||
|
||
@Override | ||
public String id() { | ||
return this.getClass().getName(); | ||
Check warning on line 42 in datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/system/restoreindices/dashboardinfo/ReindexDashboardInfo.java Codecov / codecov/patchdatahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/system/restoreindices/dashboardinfo/ReindexDashboardInfo.java#L42
|
||
} | ||
|
||
@Override | ||
public List<UpgradeStep> steps() { | ||
return _steps; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.linkedin.datahub.upgrade.system.restoreindices.dashboardinfo; | ||
|
||
import static com.linkedin.metadata.Constants.*; | ||
|
||
import com.linkedin.datahub.upgrade.system.AbstractMCLStep; | ||
import com.linkedin.metadata.entity.AspectDao; | ||
import com.linkedin.metadata.entity.EntityService; | ||
import io.datahubproject.metadata.context.OperationContext; | ||
import javax.annotation.Nonnull; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@Slf4j | ||
public class ReindexDashboardInfoStep extends AbstractMCLStep { | ||
|
||
public ReindexDashboardInfoStep( | ||
OperationContext opContext, | ||
EntityService<?> entityService, | ||
AspectDao aspectDao, | ||
Integer batchSize, | ||
Integer batchDelayMs, | ||
Integer limit) { | ||
super(opContext, entityService, aspectDao, batchSize, batchDelayMs, limit); | ||
} | ||
|
||
@Override | ||
public String id() { | ||
return "dashboard-info-v1"; | ||
Check warning on line 28 in datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/system/restoreindices/dashboardinfo/ReindexDashboardInfoStep.java Codecov / codecov/patchdatahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/system/restoreindices/dashboardinfo/ReindexDashboardInfoStep.java#L28
|
||
} | ||
|
||
@Nonnull | ||
@Override | ||
protected String getAspectName() { | ||
return DASHBOARD_INFO_ASPECT_NAME; | ||
Check warning on line 34 in datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/system/restoreindices/dashboardinfo/ReindexDashboardInfoStep.java Codecov / codecov/patchdatahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/system/restoreindices/dashboardinfo/ReindexDashboardInfoStep.java#L34
|
||
} | ||
|
||
@Nullable | ||
@Override | ||
protected String getUrnLike() { | ||
return "urn:li:" + DASHBOARD_ENTITY_NAME + ":%"; | ||
Check warning on line 40 in datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/system/restoreindices/dashboardinfo/ReindexDashboardInfoStep.java Codecov / codecov/patchdatahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/system/restoreindices/dashboardinfo/ReindexDashboardInfoStep.java#L40
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -22,6 +22,7 @@ public class DashboardInfoTemplate implements ArrayMergingTemplate<DashboardInfo | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private static final String DATASETS_FIELD_NAME = "datasets"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private static final String CHARTS_FIELD_NAME = "charts"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private static final String DESTINATION_URN_FIELD_NAME = "destinationUrn"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private static final String DASHBOARDS_FIELD_NAME = "dashboards"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public DashboardInfo getSubtype(RecordTemplate recordTemplate) throws ClassCastException { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -74,6 +75,12 @@ public JsonNode transformFields(JsonNode baseNode) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DATASET_EDGES_FIELD_NAME, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Collections.singletonList(DESTINATION_URN_FIELD_NAME)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
transformedNode = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there isn't already a test for this let's create one, or if there is add in mapping this field There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had already added a test for The test operates on datahub/entity-registry/src/main/java/com/linkedin/metadata/aspect/patch/template/Template.java Lines 51 to 86 in 47134c2
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
arrayFieldToMap( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
transformedNode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DASHBOARDS_FIELD_NAME, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Collections.singletonList(DESTINATION_URN_FIELD_NAME)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
transformedNode = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
arrayFieldToMap(transformedNode, DATASETS_FIELD_NAME, Collections.emptyList()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -97,6 +104,12 @@ public JsonNode rebaseFields(JsonNode patched) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CHART_EDGES_FIELD_NAME, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Collections.singletonList(DESTINATION_URN_FIELD_NAME)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rebasedNode = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
transformedMapToArray( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rebasedNode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DASHBOARDS_FIELD_NAME, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Collections.singletonList(DESTINATION_URN_FIELD_NAME)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rebasedNode = transformedMapToArray(rebasedNode, DATASETS_FIELD_NAME, Collections.emptyList()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rebasedNode = transformedMapToArray(rebasedNode, CHARTS_FIELD_NAME, Collections.emptyList()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add tests for these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found these tests for
DashboardInfoPatchBuilder
datahub/metadata-integration/java/datahub-client/src/test/java/datahub/client/patch/PatchTest.java
Line 619 in 79aa40f
I will add it there, even if they are all
@Ignore
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in commit 49e0dc2