From e5f5a82fe52b748b343dffa91c9b5b0c25bdc4e0 Mon Sep 17 00:00:00 2001 From: John Joyce Date: Tue, 16 Jul 2024 16:14:51 -0700 Subject: [PATCH 1/4] Adding some new things --- .../search/SearchAcrossLineageResolver.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java index f342d251acd72..e0527434a2387 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java @@ -111,7 +111,7 @@ public CompletableFuture get(DataFetchingEnvironment @Nullable Long startTimeMillis = input.getStartTimeMillis() == null ? null : input.getStartTimeMillis(); @Nullable - Long endTimeMillis = input.getEndTimeMillis() == null ? null : input.getEndTimeMillis(); + Long endTimeMillis = getEndTimeMillis(input.getStartTimeMillis(), input.getEndTimeMillis()); final LineageFlags lineageFlags = LineageFlagsInputMapper.map(context, input.getLineageFlags()); if (lineageFlags.getStartTimeMillis() == null && startTimeMillis != null) { @@ -198,4 +198,18 @@ public CompletableFuture get(DataFetchingEnvironment this.getClass().getSimpleName(), "get"); } + + /** + * Simply resolves the end time filter for the search across lineage query. If the start time is + * provided, but end time is not provided, we will default to the current time. + */ + private Long getEndTimeMillis(@Nullable Long startTimeMillis, @Nullable Long endTimeMillis) { + if (endTimeMillis != null) { + return endTimeMillis; + } + if (startTimeMillis != null) { + return System.currentTimeMillis(); + } + return null; + } } From 8e8b57f5b599d75b439728418922a887593d6e25 Mon Sep 17 00:00:00 2001 From: John Joyce Date: Tue, 16 Jul 2024 16:21:06 -0700 Subject: [PATCH 2/4] oss changes --- .../search/ScrollAcrossLineageResolver.java | 3 ++- .../search/SearchAcrossLineageResolver.java | 17 ++--------------- .../graphql/resolvers/search/SearchUtils.java | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/ScrollAcrossLineageResolver.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/ScrollAcrossLineageResolver.java index 14b2d3b8f8420..541851eabde4d 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/ScrollAcrossLineageResolver.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/ScrollAcrossLineageResolver.java @@ -78,7 +78,8 @@ public CompletableFuture get(DataFetchingEnvironment @Nullable Long startTimeMillis = input.getStartTimeMillis() == null ? null : input.getStartTimeMillis(); @Nullable - Long endTimeMillis = input.getEndTimeMillis() == null ? null : input.getEndTimeMillis(); + Long endTimeMillis = + SearchUtils.getLineageEndTimeMillis(input.getStartTimeMillis(), input.getEndTimeMillis()); final LineageFlags lineageFlags = LineageFlagsInputMapper.map(context, input.getLineageFlags()); if (lineageFlags.getStartTimeMillis() == null && startTimeMillis != null) { diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java index e0527434a2387..9027d9a3b95f4 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java @@ -111,7 +111,8 @@ public CompletableFuture get(DataFetchingEnvironment @Nullable Long startTimeMillis = input.getStartTimeMillis() == null ? null : input.getStartTimeMillis(); @Nullable - Long endTimeMillis = getEndTimeMillis(input.getStartTimeMillis(), input.getEndTimeMillis()); + Long endTimeMillis = + SearchUtils.getLineageEndTimeMillis(input.getStartTimeMillis(), input.getEndTimeMillis()); final LineageFlags lineageFlags = LineageFlagsInputMapper.map(context, input.getLineageFlags()); if (lineageFlags.getStartTimeMillis() == null && startTimeMillis != null) { @@ -198,18 +199,4 @@ public CompletableFuture get(DataFetchingEnvironment this.getClass().getSimpleName(), "get"); } - - /** - * Simply resolves the end time filter for the search across lineage query. If the start time is - * provided, but end time is not provided, we will default to the current time. - */ - private Long getEndTimeMillis(@Nullable Long startTimeMillis, @Nullable Long endTimeMillis) { - if (endTimeMillis != null) { - return endTimeMillis; - } - if (startTimeMillis != null) { - return System.currentTimeMillis(); - } - return null; - } } diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchUtils.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchUtils.java index 04777c3fcdb4e..3febd94c25e30 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchUtils.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchUtils.java @@ -326,4 +326,19 @@ public static SearchResults createEmptySearchResults(final int start, final int result.setFacets(new ArrayList<>()); return result; } + + /** + * Simply resolves the end time filter for the search across lineage query. If the start time is + * provided, but end time is not provided, we will default to the current time. + */ + public static Long getLineageEndTimeMillis( + @Nullable Long startTimeMillis, @Nullable Long endTimeMillis) { + if (endTimeMillis != null) { + return endTimeMillis; + } + if (startTimeMillis != null) { + return System.currentTimeMillis(); + } + return null; + } } From 4edc5226e412e6604cf4c271bad19b0a982844df Mon Sep 17 00:00:00 2001 From: John Joyce Date: Wed, 17 Jul 2024 09:22:05 -0700 Subject: [PATCH 3/4] Adding this --- .../datahub/graphql/resolvers/ResolverUtils.java | 15 +++++++++++++++ .../load/EntityLineageResultResolver.java | 6 +++++- .../search/ScrollAcrossLineageResolver.java | 2 +- .../search/SearchAcrossLineageResolver.java | 2 +- .../graphql/resolvers/search/SearchUtils.java | 15 --------------- .../common/mappers/LineageFlagsInputMapper.java | 11 ++++++++--- 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java index 542745e014862..3617eb4725979 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java @@ -255,4 +255,19 @@ public static Filter viewFilter( Filter result = SearchUtils.combineFilters(null, viewInfo.getDefinition().getFilter()); return result; } + + /** + * Simply resolves the end time filter for the search across lineage query. If the start time is + * provided, but end time is not provided, we will default to the current time. + */ + public static Long getLineageEndTimeMillis( + @Nullable Long startTimeMillis, @Nullable Long endTimeMillis) { + if (endTimeMillis != null) { + return endTimeMillis; + } + if (startTimeMillis != null) { + return System.currentTimeMillis(); + } + return null; + } } diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/load/EntityLineageResultResolver.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/load/EntityLineageResultResolver.java index 51b00bbe7b799..d872ffad2783d 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/load/EntityLineageResultResolver.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/load/EntityLineageResultResolver.java @@ -18,6 +18,7 @@ import com.linkedin.datahub.graphql.generated.LineageInput; import com.linkedin.datahub.graphql.generated.LineageRelationship; import com.linkedin.datahub.graphql.generated.Restricted; +import com.linkedin.datahub.graphql.resolvers.ResolverUtils; import com.linkedin.datahub.graphql.types.common.mappers.UrnToEntityMapper; import com.linkedin.metadata.graph.SiblingGraphService; import graphql.schema.DataFetcher; @@ -63,7 +64,10 @@ public CompletableFuture get(DataFetchingEnvironment enviro @Nullable final Integer count = input.getCount(); // Optional! @Nullable final Boolean separateSiblings = input.getSeparateSiblings(); // Optional! @Nullable final Long startTimeMillis = input.getStartTimeMillis(); // Optional! - @Nullable final Long endTimeMillis = input.getEndTimeMillis(); // Optional! + @Nullable + final Long endTimeMillis = + ResolverUtils.getLineageEndTimeMillis( + input.getStartTimeMillis(), input.getEndTimeMillis()); // Optional! com.linkedin.metadata.graph.LineageDirection resolvedDirection = com.linkedin.metadata.graph.LineageDirection.valueOf(lineageDirection.toString()); diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/ScrollAcrossLineageResolver.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/ScrollAcrossLineageResolver.java index 541851eabde4d..1b719b6f78620 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/ScrollAcrossLineageResolver.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/ScrollAcrossLineageResolver.java @@ -79,7 +79,7 @@ public CompletableFuture get(DataFetchingEnvironment Long startTimeMillis = input.getStartTimeMillis() == null ? null : input.getStartTimeMillis(); @Nullable Long endTimeMillis = - SearchUtils.getLineageEndTimeMillis(input.getStartTimeMillis(), input.getEndTimeMillis()); + ResolverUtils.getLineageEndTimeMillis(input.getStartTimeMillis(), input.getEndTimeMillis()); final LineageFlags lineageFlags = LineageFlagsInputMapper.map(context, input.getLineageFlags()); if (lineageFlags.getStartTimeMillis() == null && startTimeMillis != null) { diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java index 9027d9a3b95f4..dc3a1fc17e4ec 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchAcrossLineageResolver.java @@ -112,7 +112,7 @@ public CompletableFuture get(DataFetchingEnvironment Long startTimeMillis = input.getStartTimeMillis() == null ? null : input.getStartTimeMillis(); @Nullable Long endTimeMillis = - SearchUtils.getLineageEndTimeMillis(input.getStartTimeMillis(), input.getEndTimeMillis()); + ResolverUtils.getLineageEndTimeMillis(input.getStartTimeMillis(), input.getEndTimeMillis()); final LineageFlags lineageFlags = LineageFlagsInputMapper.map(context, input.getLineageFlags()); if (lineageFlags.getStartTimeMillis() == null && startTimeMillis != null) { diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchUtils.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchUtils.java index 3febd94c25e30..04777c3fcdb4e 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchUtils.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/search/SearchUtils.java @@ -326,19 +326,4 @@ public static SearchResults createEmptySearchResults(final int start, final int result.setFacets(new ArrayList<>()); return result; } - - /** - * Simply resolves the end time filter for the search across lineage query. If the start time is - * provided, but end time is not provided, we will default to the current time. - */ - public static Long getLineageEndTimeMillis( - @Nullable Long startTimeMillis, @Nullable Long endTimeMillis) { - if (endTimeMillis != null) { - return endTimeMillis; - } - if (startTimeMillis != null) { - return System.currentTimeMillis(); - } - return null; - } } diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/common/mappers/LineageFlagsInputMapper.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/common/mappers/LineageFlagsInputMapper.java index 43c24c9630d64..3a4309194f22e 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/common/mappers/LineageFlagsInputMapper.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/common/mappers/LineageFlagsInputMapper.java @@ -6,6 +6,7 @@ import com.linkedin.datahub.graphql.QueryContext; import com.linkedin.datahub.graphql.generated.EntityTypeToPlatforms; import com.linkedin.datahub.graphql.generated.LineageFlags; +import com.linkedin.datahub.graphql.resolvers.ResolverUtils; import com.linkedin.datahub.graphql.types.entitytype.EntityTypeMapper; import com.linkedin.datahub.graphql.types.mappers.ModelMapper; import java.util.Collections; @@ -42,12 +43,16 @@ public com.linkedin.metadata.query.LineageFlags apply( if (lineageFlags.getIgnoreAsHops() != null) { result.setIgnoreAsHops(mapIgnoreAsHops(lineageFlags.getIgnoreAsHops())); } - if (lineageFlags.getEndTimeMillis() != null) { - result.setEndTimeMillis(lineageFlags.getEndTimeMillis()); - } if (lineageFlags.getStartTimeMillis() != null) { result.setStartTimeMillis(lineageFlags.getStartTimeMillis()); } + // Default to "now" if no end time is provided, but start time is provided. + Long endTimeMillis = + ResolverUtils.getLineageEndTimeMillis( + lineageFlags.getStartTimeMillis(), lineageFlags.getEndTimeMillis()); + if (endTimeMillis != null) { + result.setEndTimeMillis(lineageFlags.getEndTimeMillis()); + } if (lineageFlags.getEntitiesExploredPerHopLimit() != null) { result.setEntitiesExploredPerHopLimit(lineageFlags.getEntitiesExploredPerHopLimit()); } From 8c779b43eb3c0ac59d162adfba57366e6a213cf1 Mon Sep 17 00:00:00 2001 From: John Joyce Date: Wed, 17 Jul 2024 12:05:12 -0700 Subject: [PATCH 4/4] Adding this --- .../graphql/types/common/mappers/LineageFlagsInputMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/common/mappers/LineageFlagsInputMapper.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/common/mappers/LineageFlagsInputMapper.java index 3a4309194f22e..87664ef2af4c7 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/common/mappers/LineageFlagsInputMapper.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/common/mappers/LineageFlagsInputMapper.java @@ -51,7 +51,7 @@ public com.linkedin.metadata.query.LineageFlags apply( ResolverUtils.getLineageEndTimeMillis( lineageFlags.getStartTimeMillis(), lineageFlags.getEndTimeMillis()); if (endTimeMillis != null) { - result.setEndTimeMillis(lineageFlags.getEndTimeMillis()); + result.setEndTimeMillis(endTimeMillis); } if (lineageFlags.getEntitiesExploredPerHopLimit() != null) { result.setEntitiesExploredPerHopLimit(lineageFlags.getEntitiesExploredPerHopLimit());