-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(graph) Add createdOn, createdActor, updatedOn, updatedActor to graph edges #6615
feat(graph) Add createdOn, createdActor, updatedOn, updatedActor to graph edges #6615
Conversation
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.
LGTM! Just some small comments
@Nullable | ||
private static List<Urn> getActorList(@Nullable final String path, @Nonnull final RecordTemplate aspect) { | ||
List<Urn> actorList = null; | ||
if (path != 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.
I actually think this would read cleaner without excessive nesting. So something like
if (path == null) {return null};
if (!value.isPresent() {return null;)
Because then it becomes a bit more obvious in the cases this returns null. Same for the below functions
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 sure makes sense!
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.
Sweet!
@@ -231,7 +231,8 @@ private void updateFineGrainedEdgesAndRelationships( | |||
// for every downstream, create an edge with each of the upstreams | |||
for (Urn downstream : fineGrainedLineage.getDownstreams()) { | |||
for (Urn upstream : fineGrainedLineage.getUpstreams()) { | |||
edgesToAdd.add(new Edge(downstream, upstream, DOWNSTREAM_OF)); | |||
// TODO: add edges uniformly across aspects |
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.
What does this todo mean exactly?
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.
yeah it's just that we're adding edges differently for InputFields and fineGrainedLineages right now (like this method and the one below it) and once we add some changes to specifying what the source is, we should be able to remove these methods and just create edges properly along with all the other edges
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.
Okay cool
FieldExtractor.extractFields(upstreamLineage, aspectSpec.getRelationshipFieldSpecs()); | ||
|
||
for (Map.Entry<RelationshipFieldSpec, List<Object>> entry : extractedFields.entrySet()) { | ||
if (entry.getKey().getPath().toString().equals("/upstreams/*/dataset")) { |
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.
where is this path coming from? is this a constant somewhere?
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.
yeah it's just the path I deduced from this specific UpstreamLineage aspect - not a constant anywhere (however I can make it a constant in this test file for readability)
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.
Sg!
} | ||
|
||
@Test | ||
public void testExtractGraphEdgesDefault() { |
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.
Do you think there are any other test cases that should be added besides for the default?
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.
I certainly will add more once I start adding changes to relationship annotations on aspects (and add tests for those aspects). I could write one where there's an invalid urn to make sure we don't add that edge.. otherwise other than testing different aspects and checking the types of edges we get are correct I'm not sure.
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.
Okay no worries!
} | ||
|
||
@Nullable | ||
private static List<Long> getTimestampList(@Nullable final String path, @Nonnull final RecordTemplate aspect) { |
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.
Really nice functions. I like how tight you were able to break them up!
|
||
@BeforeMethod | ||
public void setupTest() { | ||
_createdActorUrn = UrnUtils.getUrn(CREATED_ACTOR_URN); |
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.
Sweet test! No need to refactor, but I think the firstt 5 of these vars could also be static final variables up top
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.
ah yeah I actually tried doing that first but I think creating an urn from a string up there was causing issues and the build was failing (with a pretty unhelpful error message) - i'm sure there's a different way I could be going about it though 🤷
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 major comments! Nice.
Aside from build failing :) |
This PR adds the mechanism to define what the
createdOn
andupdatedOn
timestamps are on a graph index edge as well as thecreatedActor
andupdatedActor
. In order to specify, all you need to do is set the path to the field on the aspect inside of the Relationship annotation. As an example, this is what you can do to set these fields onUpstream
inUpstreamLineage
This also sets a default
createdOn
andcreatedActor
on all new graph edges being created using themetadataChangeLog.systemMetadata.lastObserved
timestamp and themetadataChangeLog.created.actor
for those fields.Checklist