-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(blame) - add schema history blame UI
- Loading branch information
aditya-radhakrishnan
committed
Apr 29, 2022
1 parent
c34a1ba
commit 00340fd
Showing
27 changed files
with
1,159 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...rc/main/java/com/linkedin/datahub/graphql/resolvers/timeline/ListSchemaBlameResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.linkedin.datahub.graphql.resolvers.timeline; | ||
|
||
import com.linkedin.common.urn.Urn; | ||
import com.linkedin.datahub.graphql.generated.ListSchemaBlameInput; | ||
import com.linkedin.datahub.graphql.generated.ListSchemaBlameResult; | ||
import com.linkedin.datahub.graphql.types.timeline.mappers.SchemaBlameMapper; | ||
import com.linkedin.metadata.timeline.TimelineService; | ||
import com.linkedin.metadata.timeline.data.ChangeCategory; | ||
import com.linkedin.metadata.timeline.data.ChangeTransaction; | ||
import graphql.schema.DataFetcher; | ||
import graphql.schema.DataFetchingEnvironment; | ||
import java.net.URISyntaxException; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.concurrent.CompletableFuture; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static com.linkedin.datahub.graphql.resolvers.ResolverUtils.*; | ||
|
||
|
||
@Slf4j | ||
public class ListSchemaBlameResolver implements DataFetcher<CompletableFuture<ListSchemaBlameResult>> { | ||
private final TimelineService _timelineService; | ||
|
||
private static final Logger _logger = LoggerFactory.getLogger(ListSchemaBlameResolver.class.getName()); | ||
|
||
public ListSchemaBlameResolver(TimelineService timelineService) { | ||
_timelineService = timelineService; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<ListSchemaBlameResult> get(final DataFetchingEnvironment environment) throws Exception { | ||
final ListSchemaBlameInput input = bindArgument(environment.getArgument("input"), ListSchemaBlameInput.class); | ||
|
||
final String datasetUrnString = input.getDatasetUrn() == null ? null : input.getDatasetUrn(); | ||
final long startTime = 0; | ||
final long endTime = 0; | ||
final String versionCutoff = input.getVersionCutoff() == null ? null : input.getVersionCutoff(); | ||
|
||
return CompletableFuture.supplyAsync(() -> { | ||
try { | ||
if (datasetUrnString == null) { | ||
return null; | ||
} | ||
final Set<ChangeCategory> changeCategorySet = new HashSet<>(); | ||
changeCategorySet.add(ChangeCategory.TECHNICAL_SCHEMA); | ||
Urn datasetUrn = Urn.createFromString(datasetUrnString); | ||
List<ChangeTransaction> changeTransactionList = | ||
_timelineService.getTimeline(datasetUrn, changeCategorySet, startTime, endTime, null, null, false); | ||
return SchemaBlameMapper.map(changeTransactionList, versionCutoff); | ||
} catch (URISyntaxException u) { | ||
_logger.debug( | ||
String.format("Failed to list schema blame data, likely due to the Urn %s being invalid", datasetUrnString), | ||
u); | ||
return null; | ||
} catch (Exception e) { | ||
_logger.debug("Failed to list schema blame data", e); | ||
return null; | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.