-
Notifications
You must be signed in to change notification settings - Fork 10
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
DISC-378 : Create persona filters on hierachical qualifiedName filters #3399
Changes from 3 commits
b677d2f
9f5ea5f
03da5ca
dd3b077
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 |
---|---|---|
|
@@ -1529,6 +1529,20 @@ private EntityMutationResponse createOrUpdate(EntityStream entityStream, boolean | |
|
||
executePreProcessor(context); | ||
|
||
// Updating hierarchy after preprocessor is executed so that qualifiedName update during preprocessor is considered | ||
for (AtlasEntity entity : context.getCreatedEntities()) { | ||
createQualifiedNameHierarchyField(entity, context.getVertex(entity.getGuid())); | ||
} | ||
|
||
for (AtlasEntity entity : context.getUpdatedEntities()) { | ||
// If qualifiedName update is part of the update, update the qualifiedName hierarchy field | ||
AtlasEntity diffEntity = RequestContext.get().getDifferentialEntitiesMap().get(entity.getGuid()); | ||
if (diffEntity != null && diffEntity.hasAttribute(QUALIFIED_NAME)) { | ||
createQualifiedNameHierarchyField(entity, context.getVertex(entity.getGuid())); | ||
} | ||
} | ||
|
||
|
||
EntityMutationResponse ret = entityGraphMapper.mapAttributesAndClassifications(context, isPartialUpdate, | ||
replaceClassifications, replaceBusinessAttributes, isOverwriteBusinessAttribute); | ||
|
||
|
@@ -1802,6 +1816,41 @@ private AtlasStruct getStarredDetailsStruct(String assetStarredBy, long assetSta | |
return starredDetails; | ||
} | ||
|
||
private void createQualifiedNameHierarchyField(AtlasEntity entity, AtlasVertex vertex) { | ||
MetricRecorder metric = RequestContext.get().startMetricRecord("createQualifiedNameHierarchyField"); | ||
try { | ||
if (vertex == null) { | ||
nikhilbonte21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
vertex = AtlasGraphUtilsV2.findByGuid(graph, entity.getGuid()); | ||
} | ||
if (entity.hasAttribute(QUALIFIED_NAME)) { | ||
String qualifiedName = (String) entity.getAttribute(QUALIFIED_NAME); | ||
if (StringUtils.isNotEmpty(qualifiedName)) { | ||
nikhilbonte21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
vertex.removeProperty(QUALIFIED_NAME_HIERARCHY_PROPERTY_KEY); | ||
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. Minor: call this statement only if necessary as it is redundant in case of GCTs, Readme, Link |
||
String[] parts = qualifiedName.split("/"); | ||
StringBuilder currentPath = new StringBuilder(); | ||
nikhilbonte21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
for (int i = 0; i < parts.length; i++) { | ||
String part = parts[i]; | ||
if (StringUtils.isNotEmpty(part)) { | ||
if (i > 0) { | ||
currentPath.append("/"); | ||
} | ||
Comment on lines
+1835
to
+1837
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. Minor suggestion: 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. e.g.
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. Its there if there is no 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. All we are doing is |
||
currentPath.append(part); | ||
// i>1 reason: we don't want to add the first part of the qualifiedName as it is the entity name | ||
// Example qualifiedName : default/snowflake/123/db_name we only want `default/snowflake/123` and `default/snowflake/123/db_name` | ||
if (i > 1) { | ||
AtlasGraphUtilsV2.addEncodedProperty(vertex, QUALIFIED_NAME_HIERARCHY_PROPERTY_KEY, currentPath.toString()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} finally { | ||
RequestContext.get().endMetricRecord(metric); | ||
} | ||
} | ||
|
||
|
||
public PreProcessor getPreProcessor(String typeName) { | ||
PreProcessor preProcessor = null; | ||
|
||
|
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.
For asset value
default/redshift/1705171197/dev/public/*
isHierarchical will be
true
isWildcard will be
true
Given this, it will never go to else block & hence
metadataPolicyQualifiedNames.add(asset);
will not be executed instead it will createwildcard
asisWildcard
is trueIdeally in this case
asset
should be added intometadataPolicyQualifiedNames
(substring by -2) & no need of wildcard thenThere 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.
Also, honestly, I feel this logic is complex to understand & maintain, and different check for useHierarchicalQualifiedNameFilter
can we separate them by useHierarchicalQualifiedNameFilter?
like
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.
No
asset = asset.substring(0, asset.length() - 2);
will make sure we we cut/*
from the string and consider it then. So isWildcard will be false.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 code is like this because if we wanted to optimize for the case of
/*
in the end. If there is any we trim last part and proceed.And added extra 2 conditions if we have hierarchical flag enabled, when we enable it for everyone and remove flag condition the conditions will be simpler and easier to write code then. Its bit messy for the feature flag part actually. Otherwise its pretty simple.
Its already been tested a couple of time, I think we can proceed with this one.
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.
Understood