-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from tigergraph/GML-1866-entity-type-upserts
feat(graphrag): add type information upsert
- Loading branch information
Showing
6 changed files
with
132 additions
and
31 deletions.
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
20 changes: 20 additions & 0 deletions
20
common/gsql/supportai/create_entity_type_relationships.gsql
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
CREATE DISTRIBUTED QUERY create_entity_type_relationships(/* Parameters here */) SYNTAX v2{ | ||
MapAccum<STRING, MapAccum<STRING, SumAccum<INT>>> @rel_type_count; // entity type, relationship type for entity type, frequency | ||
SumAccum<INT> @@rels_inserted; | ||
ents = {Entity.*}; | ||
accum_types = SELECT et FROM ents:e -(RELATIONSHIP>:r)- Entity:e2 -(ENTITY_HAS_TYPE>:eht)- EntityType:et | ||
WHERE r.relation_type != "DOC_CHUNK_COOCCURRENCE" | ||
ACCUM | ||
e.@rel_type_count += (et.id -> (r.relation_type -> 1)); | ||
|
||
ets = SELECT et FROM ents:e -(ENTITY_HAS_TYPE>:eht)- EntityType:et | ||
ACCUM | ||
FOREACH (entity_type, rel_type_freq) IN e.@rel_type_count DO | ||
FOREACH (rel_type, freq) IN e.@rel_type_count.get(entity_type) DO | ||
INSERT INTO RELATIONSHIP_TYPE VALUES (et.id, entity_type, rel_type, freq), | ||
@@rels_inserted += 1 | ||
END | ||
END; | ||
|
||
PRINT @@rels_inserted as relationships_inserted; | ||
} |
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