-
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
May 2, 2022
1 parent
1afbc49
commit fe8527d
Showing
25 changed files
with
1,577 additions
and
367 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
61 changes: 61 additions & 0 deletions
61
...src/main/java/com/linkedin/datahub/graphql/resolvers/timeline/GetSchemaBlameResolver.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,61 @@ | ||
package com.linkedin.datahub.graphql.resolvers.timeline; | ||
|
||
import com.linkedin.common.urn.Urn; | ||
import com.linkedin.datahub.graphql.generated.GetSchemaBlameInput; | ||
import com.linkedin.datahub.graphql.generated.GetSchemaBlameResult; | ||
import com.linkedin.datahub.graphql.types.timeline.mappers.SchemaFieldBlameMapper; | ||
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 static com.linkedin.datahub.graphql.resolvers.ResolverUtils.*; | ||
|
||
|
||
@Slf4j | ||
public class GetSchemaBlameResolver implements DataFetcher<CompletableFuture<GetSchemaBlameResult>> { | ||
private final TimelineService _timelineService; | ||
|
||
public GetSchemaBlameResolver(TimelineService timelineService) { | ||
_timelineService = timelineService; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<GetSchemaBlameResult> get(final DataFetchingEnvironment environment) throws Exception { | ||
final GetSchemaBlameInput input = bindArgument(environment.getArgument("input"), GetSchemaBlameInput.class); | ||
|
||
final String datasetUrnString = input.getDatasetUrn() == null ? null : input.getDatasetUrn(); | ||
final long startTime = 0; | ||
final long endTime = 0; | ||
final String version = input.getVersion() == null ? null : input.getVersion(); | ||
|
||
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 SchemaFieldBlameMapper.map(changeTransactionList, version); | ||
} catch (URISyntaxException u) { | ||
log.debug( | ||
String.format("Failed to list schema blame data, likely due to the Urn %s being invalid", datasetUrnString), | ||
u); | ||
return null; | ||
} catch (Exception e) { | ||
log.debug("Failed to list schema blame data", e); | ||
return null; | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.