gchq / Gaffer

A large-scale entity and relation database supporting aggregation of properties
Apache License 2.0
1.77k stars 350 forks source link

Gh-2996: Ability to pass config in gremlin queries #3195

Closed tb06904 closed 5 months ago

tb06904 commented 5 months ago

Adds the ability to override a limited set of graph variables when doing a gremlin query. This utilises the with() feature of gremlin that will attach a OptionsStrategy to the query that can then be parsed for the relevant options passed in.

To implement this it required creating a custom traversal mechanism for gremlin GraphSteps so that we can override and parse the options on the query. Adding this step also allowed for a small optimisation to ensure any hasLabel type queries on the original GraphStep are parsed to create a representative Gaffer View. The intention is that additional custom traversal steps are added in future to optimise the mapping of gremlin to standard Gaffer operations.

As an example this allows the following:

g.with("userId", "user").V()   // userId extracted to be used in the operations spawned from the query
g.with("dataAuths", "write-access,read-access").V()   // user access controls to apply on the user
g.with("operationOptions", ["graphId:graph1", "opt1:val1"]).V()   // operation options (can add a federated graph Id here)

Related issue

codecov[bot] commented 5 months ago

Codecov Report

Attention: Patch coverage is 77.27273% with 25 lines in your changes are missing coverage. Please review.

Project coverage is 66.76%. Comparing base (40ef69b) to head (bd35f37).

Files Patch % Lines
...gchq/gaffer/tinkerpop/GafferPopGraphVariables.java 72.97% 6 Missing and 4 partials :warning:
...pop/process/traversal/step/GafferPopGraphStep.java 77.14% 3 Missing and 5 partials :warning:
...a/uk/gov/gchq/gaffer/tinkerpop/GafferPopGraph.java 80.95% 2 Missing and 2 partials :warning:
...ategy/optimisation/GafferPopGraphStepStrategy.java 82.35% 0 Missing and 3 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #3195 +/- ## ============================================= + Coverage 66.70% 66.76% +0.05% Complexity 2558 2558 ============================================= Files 908 910 +2 Lines 29113 29203 +90 Branches 3243 3254 +11 ============================================= + Hits 19421 19498 +77 - Misses 8259 8261 +2 - Partials 1433 1444 +11 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tb06904 commented 5 months ago

Given the ability to set the user provided in this PR, to what extent does this resolve #2991?

See comment added to #2991