Skip to content

Commit

Permalink
Updated Data Lineage
Browse files Browse the repository at this point in the history
  • Loading branch information
01110011011101010110010001101111 committed Jul 21, 2022
1 parent c1a7ce0 commit 0a457f2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
14 changes: 7 additions & 7 deletions Data-Lineage/db_scripts/queries/all_updates.gsql
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
CREATE QUERY all_updates(vertex<Contact> input) FOR GRAPH MyGraph {
CREATE QUERY all_updates(VERTEX<Contact> input) FOR GRAPH MyGraph {
/*
* Given an input Contact, find all of his/her updates.
* Sample input:
* input: Chris-Xi
*/

SetAccum<vertex> @@specific_person_set;
SetAccum<VERTEX> @@specific_person_set;

start = {input};

get_updates = SELECT t from start:s-(wasUpdated:e)-ContactOnDate:t
accum @@specific_person_set += s, @@specific_person_set += t;

print_set = @@specific_person_set;
print print_set;
get_updates = SELECT t
FROM start:s-(wasUpdated:e)-ContactOnDate:t
ACCUM @@specific_person_set += s, @@specific_person_set += t;

PRINT @@specific_person_set AS print_set;
}
70 changes: 35 additions & 35 deletions Data-Lineage/db_scripts/queries/contact_when.gsql
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
CREATE QUERY contact_when(vertex<Contact> contact, datetime time) FOR GRAPH MyGraph {
CREATE QUERY contact_when(VERTEX<Contact> contact, DATETIME time) FOR GRAPH MyGraph {
/*
Sample input:
contact: Chris-Xi
datetime: 2019-06-05
*/

typedef tuple <dtime datetime, attribute string, source string> updates;
ListAccum<vertex> @@earliest_first;
HeapAccum<updates>(1,dtime desc) @email_update;
HeapAccum<updates>(1,dtime desc) @phone_update;
HeapAccum<updates>(1,dtime desc) @title_update;
typedef tuple <dtime DATETIME, attribute STRING, source STRING> updates;
ListAccum<VERTEX> @@earliest_first;
HeapAccum<updates>(1,dtime DESC) @email_update;
HeapAccum<updates>(1,dtime DESC) @phone_update;
HeapAccum<updates>(1,dtime DESC) @title_update;

Start = {contact};

get_updates = SELECT t FROM Start:s-(wasUpdated:e)-ContactOnDate:t
where t.modifiedDate <= time and s.outdegree("wasUpdated") > 1
order by t.modifiedDate asc;
WHERE t.modifiedDate <= time AND s.outdegree("wasUpdated") > 1
ORDER BY t.modifiedDate ASC;

print get_updates;
PRINT get_updates;

updated_contacts = SELECT t FROM get_updates:s-(wasUpdated:e)-Contact:t
accum
ACCUM
@@earliest_first += get_updates,
if s.email != "" then
IF s.email != "" THEN
t.@email_update += updates(s.modifiedDate,s.email,s.source)
end,
if s.phone != "" then
END,
IF s.phone != "" THEN
t.@phone_update += updates(s.modifiedDate,s.phone,s.source)
end,
if s.title != "" then
END,
IF s.title != "" THEN
t.@title_update += updates(s.modifiedDate,s.title,s.source)
end;
END;

updated_contacts2 = SELECT t from get_updates:s-(wasUpdated:e)-Contact:t
post-accum
if get_updates.size() > 0 then
if t.@email_update.size() > 0 then
updated_contacts2 = SELECT t FROM get_updates:s-(wasUpdated:e)-Contact:t
POST-ACCUM
IF get_updates.size() > 0 THEN
IF t.@email_update.size() > 0 THEN
t.LastModifiedDate = t.@email_update.top().dtime,
t.LastModifiedByid = t.@email_update.top().source,
t.Email = t.@email_update.top().attribute,
t.Updated = true
end,
if t.@phone_update.size() > 0 then
if t.@phone_update.top().dtime > t.@email_update.top().dtime then
t.Updated = TRUE
END,
IF t.@phone_update.size() > 0 THEN
IF t.@phone_update.top().dtime > t.@email_update.top().dtime THEN
t.LastModifiedDate = t.@phone_update.top().dtime,
t.LastModifiedByid = t.@phone_update.top().source,
t.Phone = t.@phone_update.top().attribute,
t.Updated = true
t.Updated = TRUE
else
t.Phone = t.@phone_update.top().attribute,
t.Updated = true
end
end,
if t.@title_update.size() > 0 then
if t.@title_update.top().dtime > t.@email_update.top().dtime and t.@title_update.top().dtime > t.@phone_update.top().dtime then
t.Updated = TRUE
END
END,
IF t.@title_update.size() > 0 THEN
IF t.@title_update.top().dtime > t.@email_update.top().dtime AND t.@title_update.top().dtime > t.@phone_update.top().dtime THEN
t.LastModifiedDate = t.@title_update.top().dtime,
t.LastModifiedByid = t.@title_update.top().source,
t.Title = t.@title_update.top().attribute,
t.Updated = true
t.Updated = TRUE
else
t.Title = t.@title_update.top().attribute,
t.Updated = true
end
end
end;
t.Updated = TRUE
END
END
END;

}

0 comments on commit 0a457f2

Please sign in to comment.