-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
working on lineage es integration #14181
Merged
Merged
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
f880e28
working on lineage es integration
07Himank 2ca0d14
os change
07Himank 7e463b7
Merge branch 'main' into lineageEsIntegration
karanh37 6c70458
Merge branch 'main' into lineageEsIntegration
07Himank aa2cf35
working
07Himank c0d3269
working on lineage es integration
07Himank 9db0635
Merge branch 'main' into lineageEsIntegration
07Himank e7c79ab
add curremt lineage, special character handling, delete lineage
07Himank f716d18
Merge branch 'lineageEsIntegration' of https://github.com/open-metada…
07Himank 4a1942d
remove test code
07Himank 8cc9868
update lineage index work done
07Himank 83347d7
fix: add lineage ui changes
karanh37 1dd5fa3
fix: lineage add edit
karanh37 dd6ee2a
fix: center on load
karanh37 79f5357
fix: add remove edges
karanh37 9499b6d
Merge branch 'main' into lineageEsIntegration
karanh37 563c07e
fix: column lineage issues
karanh37 6467ddb
use reactflow controls
karanh37 06451f2
add collapse
karanh37 5f8c9ba
added upstream and downstream depth diffrently
07Himank d0d703b
resolved conflicts
07Himank f91521c
depth and collapse
karanh37 f47f7cf
fix loading of dialog
karanh37 6e51586
add includeDeleted in API
karanh37 0036951
cleanup
karanh37 9bff7d0
Merge branch 'lineageEsIntegration' of https://github.com/open-metada…
07Himank 4c9a75d
cleanup
karanh37 68b3a7f
cleanup
karanh37 1f82245
initial unit tests
karanh37 618cf74
Merge branch 'lineageEsIntegration' of https://github.com/open-metada…
07Himank bc4535d
main merge
07Himank ac62f3f
fix tests
karanh37 be25483
cleanup
karanh37 35f646b
Merge branch 'main' into lineageEsIntegration
karanh37 f248598
update filter query
karanh37 87d57a6
Merge branch 'main' of https://github.com/open-metadata/OpenMetadata …
07Himank d98bee1
fix: allow sql query to update
karanh37 ce56981
use input instead of select
karanh37 cc34ca6
unit tests
karanh37 62173fa
Merge branch 'main' into lineageEsIntegration
karanh37 ccbdbb3
unit tests
karanh37 098aee4
fix edge removal
karanh37 ade1383
cleanup
karanh37 3c0ff57
description and deleted
07Himank ed8296a
Merge branch 'lineageEsIntegration' of https://github.com/open-metada…
07Himank 9365069
fix: initial lineage tests
karanh37 ae26c1e
Merge branch 'main' into lineageEsIntegration
karanh37 c7289d3
fix unit tests
karanh37 b7c5ef0
Merge branch 'main' into lineageEsIntegration
karanh37 083b0f3
fix: review comments
karanh37 e7cf223
Merge branch 'main' into lineageEsIntegration
karanh37 1ba671f
added edgedescription
07Himank 97e9f2a
Merge branch 'lineageEsIntegration' of https://github.com/open-metada…
07Himank 5761b7b
refactor custom nodes
karanh37 fea3185
refactor condition
karanh37 0554029
Merge branch 'main' into lineageEsIntegration
karanh37 26757ab
add pipeline status color
karanh37 9437778
fix unit tests
karanh37 f1e3f6f
Merge branch 'main' into lineageEsIntegration
karanh37 6a3aaad
cleanup
karanh37 795d23e
cleanup
karanh37 1075013
added opensearch code and changed endpoint
07Himank 015b7ac
Merge branch 'lineageEsIntegration' of https://github.com/open-metada…
07Himank b7ccc3c
fix: lineage url
karanh37 0da8c79
depth issue resolved
07Himank File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -111,6 +111,7 @@ | |
import org.apache.http.auth.UsernamePasswordCredentials; | ||
import org.apache.http.client.CredentialsProvider; | ||
import org.apache.http.impl.client.BasicCredentialsProvider; | ||
import org.openmetadata.common.utils.CommonUtil; | ||
import org.openmetadata.schema.DataInsightInterface; | ||
import org.openmetadata.schema.dataInsight.DataInsightChartResult; | ||
import org.openmetadata.schema.service.configuration.elasticsearch.ElasticSearchConfiguration; | ||
|
@@ -419,6 +420,95 @@ public Response search(SearchRequest request) throws IOException { | |
return Response.status(OK).entity(response).build(); | ||
} | ||
|
||
@Override | ||
public Response searchLineage( | ||
String fqn, int upstreamDepth, int downstreamDepth, String queryFilter, boolean deleted) | ||
throws IOException { | ||
Map<String, Object> responseMap = new HashMap<>(); | ||
List<Map<String, Object>> edges = new ArrayList<>(); | ||
Set<Map<String, Object>> nodes = new HashSet<>(); | ||
es.org.elasticsearch.action.search.SearchRequest searchRequest = | ||
new es.org.elasticsearch.action.search.SearchRequest(GLOBAL_SEARCH_ALIAS); | ||
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); | ||
searchSourceBuilder.query( | ||
QueryBuilders.boolQuery().must(QueryBuilders.termQuery("fullyQualifiedName", fqn))); | ||
searchRequest.source(searchSourceBuilder); | ||
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); | ||
for (var hit : searchResponse.getHits().getHits()) { | ||
responseMap.put("entity", hit.getSourceAsMap()); | ||
} | ||
getLineage( | ||
fqn, downstreamDepth, edges, nodes, queryFilter, "lineage.fromEntity.fqn.keyword", deleted); | ||
getLineage( | ||
fqn, upstreamDepth, edges, nodes, queryFilter, "lineage.toEntity.fqn.keyword", deleted); | ||
responseMap.put("edges", edges); | ||
responseMap.put("nodes", nodes); | ||
return Response.status(OK).entity(responseMap).build(); | ||
} | ||
|
||
private void getLineage( | ||
String fqn, | ||
int depth, | ||
List<Map<String, Object>> edges, | ||
Set<Map<String, Object>> nodes, | ||
String queryFilter, | ||
String direction, | ||
boolean deleted) | ||
throws IOException { | ||
if (depth <= 0) { | ||
return; | ||
} | ||
es.org.elasticsearch.action.search.SearchRequest searchRequest = | ||
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. can we move this into import 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. @harshach We have two SearchRequest one is internal that why we use it this way. |
||
new es.org.elasticsearch.action.search.SearchRequest(GLOBAL_SEARCH_ALIAS); | ||
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); | ||
searchSourceBuilder.query( | ||
QueryBuilders.boolQuery().must(QueryBuilders.termQuery(direction, fqn))); | ||
if (CommonUtil.nullOrEmpty(deleted)) { | ||
searchSourceBuilder.query( | ||
QueryBuilders.boolQuery() | ||
.must(QueryBuilders.termQuery(direction, fqn)) | ||
.must(QueryBuilders.termQuery("deleted", deleted))); | ||
} | ||
if (!nullOrEmpty(queryFilter) && !queryFilter.equals("{}")) { | ||
try { | ||
XContentParser filterParser = | ||
XContentType.JSON | ||
.xContent() | ||
.createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, queryFilter); | ||
QueryBuilder filter = SearchSourceBuilder.fromXContent(filterParser).query(); | ||
BoolQueryBuilder newQuery = | ||
QueryBuilders.boolQuery().must(searchSourceBuilder.query()).filter(filter); | ||
searchSourceBuilder.query(newQuery); | ||
} catch (Exception ex) { | ||
LOG.warn("Error parsing query_filter from query parameters, ignoring filter", ex); | ||
} | ||
} | ||
searchRequest.source(searchSourceBuilder); | ||
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); | ||
for (var hit : searchResponse.getHits().getHits()) { | ||
List<Map<String, Object>> lineage = | ||
(List<Map<String, Object>>) hit.getSourceAsMap().get("lineage"); | ||
nodes.add(hit.getSourceAsMap()); | ||
for (Map<String, Object> lin : lineage) { | ||
HashMap<String, String> fromEntity = (HashMap<String, String>) lin.get("fromEntity"); | ||
HashMap<String, String> toEntity = (HashMap<String, String>) lin.get("toEntity"); | ||
if (direction.equalsIgnoreCase("lineage.fromEntity.fqn.keyword")) { | ||
if (!edges.contains(lin) && fromEntity.get("fqn").equals(fqn)) { | ||
edges.add(lin); | ||
getLineage( | ||
toEntity.get("fqn"), depth - 1, edges, nodes, queryFilter, direction, deleted); | ||
} | ||
} else { | ||
if (!edges.contains(lin) && toEntity.get("fqn").equals(fqn)) { | ||
edges.add(lin); | ||
getLineage( | ||
fromEntity.get("fqn"), depth - 1, edges, nodes, queryFilter, direction, deleted); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public Response searchBySourceUrl(String sourceUrl) throws IOException { | ||
es.org.elasticsearch.action.search.SearchRequest searchRequest = | ||
|
@@ -1136,6 +1226,26 @@ public void updateChildren( | |
} | ||
} | ||
|
||
/** | ||
* @param indexName | ||
* @param fieldAndValue | ||
*/ | ||
@Override | ||
public void updateLineage( | ||
String indexName, Pair<String, String> fieldAndValue, Map<String, Object> lineageData) { | ||
if (isClientAvailable) { | ||
UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest(indexName); | ||
updateByQueryRequest.setQuery( | ||
new MatchQueryBuilder(fieldAndValue.getKey(), fieldAndValue.getValue()) | ||
.operator(Operator.AND)); | ||
Map<String, Object> params = Collections.singletonMap("lineageData", lineageData); | ||
Script script = | ||
new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, ADD_UPDATE_LINEAGE, params); | ||
updateByQueryRequest.setScript(script); | ||
updateElasticSearchByQuery(updateByQueryRequest); | ||
} | ||
} | ||
|
||
public void updateElasticSearch(UpdateRequest updateRequest) { | ||
if (updateRequest != null && isClientAvailable) { | ||
updateRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this could be pipeline or stored procedure as an edge cc @pmbrull
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.
@07Himank need to address this, it can be pipeline or stored procedure here
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.
@harshach just key name is pipeline but it works for both pipeline and stored procedure .. do you want to me change the key name?