Skip to content
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

Improve query input support #156

Merged

Conversation

tsandall
Copy link
Member

These changes improve support for query inputs. Most of the commits are refactoring done along the way. The core changes are in "Update topdown.Query to support non-ground globals" (6fa4848). These changes make topdown queries evaluate the globals before performing evaluation on the query itself. For each set of bindings of the globals, the query is executed. The result is a set of sets where the inner-most set contains both the query result/document value AND the bindings for variables found in the globals.

With these changes, the REST API will now return the set of sets/array of arrays if global inputs contain variables. The REST API docs have been updated to show this.

The construction of the global variables map passed to topdown can be re-used
in a few places, so move it into topdown. The query string parsing is kept in
the server package as that part is relatively simple.
These functions do not require the entire context. They only depend on the
ability to resolve references to base documents to native Go values. As such,
it makes sense to limit the coupling.
This change required refactoring the topdown.Query interface to return
multiple document values instead of a single one.
Copy link
Member

@timothyhinrichs timothyhinrichs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elegant change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants