Window functions in gremlin
Is there any way to apply window functions in gremlin queries I need to convert the following SQL query into gremlin.
SELECT ass.id, fin.id, ass.display_label, fin.finding_status CASE WHEN SUM( CASE WHEN fin.finding_status = 'Closed' THEN 0 ELSE 1 END ) OVER (PARTITION BY ass.id) > 0 THEN 'Failed' ELSE 'Passed' END as assmnt_status FROM "sds_datalake"."ei_publish_cloud_3"."findings" as fin LEFT JOIN "sds_datalake"."ei_publish_cloud_3"."findigs_associated_with_assessments" as ass_fin on fin.p_id = ass_fin.source_p_id LEFT JOIN "sds_datalake"."ei_publish_cloud_3"."assessments" as ass on ass_fin.target_p_id = ass.p_id`
1 Reply
Interesting, as I really don't think of window functions that much in the graph world. It's typically more related to tabular or time-series data. Can you explain a bit more about what you're attempting to do with the data in a graph as opposed to it being in a relational database?
There are iterative aggregation patterns in graph. In Gremlin, there is the
There are iterative aggregation patterns in graph. In Gremlin, there is the
sack()
step that allows you to gather up a set of values as a traversal is executed and then act on that "sack" of values at the end of the query. https://kelvinlawrence.net/book/Gremlin-Graph-Guide.html#sackintro