-
Notifications
You must be signed in to change notification settings - Fork 101
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
Recursive Queries Produce Non-plannable Query Outputs #430
Comments
The problem arises because Logica is greedy about putting everything into one query. We need to tell it to break it up. When we add Here is a CoLab where your program runs just fine: Logica is not using recursive CTE, instead it compiles to a SQL iterations. As far as I know no mainstream SQL engine supports aggregation in recursion, but in Logica its very useful, so CTEs are not enough and iteration is required. In my experience anything that's at all practical can be acheive with SQL iteration the way Logica does it. So if you encounter any further challenges, please let me know, it's very interesting for me to see if Logica can fully support your usecase as-is. If we uncover the true need for CTE we can work on that. |
@EvgSkv thanks for the quick reply! That worked great for me. I finished modeling some of the primitives of ReBAC models using Logica. I wanted to learn more about Logica and so I figured I'd model a real world use case. Google Zanzibar inspired models are becoming more popular, and there has been a lot of projects and literature built around the Zanzibar model. If you would be interested, it may be cool to write a blog post or something together on it. Would you be interested in doing something like that? Here are some of the projects that have written about Relationship-based Access Control (ReBAC) or sometimes also referred to in literature as Fine-grained Authorization (FGA). https://openfga.dev/ Here is a link to the CoLab notebook that I have been working on.
I may expose some interesting findings, because these ReBAC models can require mutually recursive CTE semantics and fixed point iteration mechanics, of which only some projects like Feldera and Materialize can offer today AFAIK. But yeah, to your point, I don't think any mainstream SQL engine provides mutually recursive CTEs with fixed point iteration. Only those two AFAIK. |
@jon-whit , I am happy to support your post if you need any advice on using Logica. I'll get in touch over email. I didn't know there are any SQL engines supporting aggregation in recursion. This is very interesting. Thank you for links! |
👋 I'm working on a project to map Relationship-based Access Control (ReBAC) queries inspired by Google Zanzibar to Logica queries, but I'm running into an issue with what Logica produces. These queries are very recursive based queries as relationships in one subquery can reference relationships in others etc..
Here's an example of the Logica specification for the kinds of queries I am trying to express:
When I try to run this program against BigQuery in Colab, for example, I get an error:
Looking at the query, it appears that the query output does not do a very good job at mapping the recursive semantics to CTE definitions and that these definitions get fully denormalized into intermediate temporary tables. See the attached output-sql.txt
I'm curious if ya'll have any thoughts on how this could be avoided and/or if you feel like this kind of definition is going to be a challenge for something like Logica to really support? I'd love some help with modeling the semantics and being able to produce some plans that can actually get executed.
The text was updated successfully, but these errors were encountered: