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

Add an ability to query rules from a schema #267

Open
izmalk opened this issue Feb 21, 2023 · 9 comments
Open

Add an ability to query rules from a schema #267

izmalk opened this issue Feb 21, 2023 · 9 comments

Comments

@izmalk
Copy link
Member

izmalk commented Feb 21, 2023

Problem to Solve

We can define/undefine rules. We can read a schema with read transactions from any client. But we can't read rules right now.

Current Workaround

TypeDB Console has a built-in function to return a full schema with rules.

Proposed Solution

Have a syntax in TypeQL to query a full schema with rules and/or rules only.

Include rules into TypeDB Studio Types browser Export schema button result or create a separate rule tool.

Additional Information

@izmalk
Copy link
Member Author

izmalk commented Feb 21, 2023

As was stated in the vaticle/typedb#3281 (possible duplicate but in TypeDB repository), we can

Use Concept API, calling transaction.logic().getRule(label) or transaction.logic().getRules()

@mathieuisabel
Copy link

@izmalk Being able to query rules and see their dependencies on other rules would also be beneficial. I was talking about this with @tomassabat in the context of rules debugging where it's currently hard to assess the which rules get triggered from a particular query when there are multiple rules involved.

@izmalk
Copy link
Member Author

izmalk commented Mar 13, 2023

@izmalk Being able to query rules and see their dependencies on other rules would also be beneficial.

I'm not sure what are the dependencies on other rules. Do you mean rule interaction via inferred data?

it's currently hard to assess the which rules get triggered from a particular query when there are multiple rules involved.

But we can do that with an explanation option enabled. Did you try something like that: https://github.com/izmalk/typedb_test_queries/blob/main/all-queries.py#L176 ?
It's sometimes tricky to read the conclusion part of the explanation but I can't see any better solution for now. Do you?

@flyingsilverfin
Copy link
Member

I think @mathieuisabel is talking about showing the schema-level rule interaction graph, not the exact data-layer explanations, right?

@mathieuisabel
Copy link

That would be correct @flyingsilverfin . Here's probably a poor example that might give an idea:

image

Also in the same line of thought for debugging purposes, I remembered James showing me at some point a visual representation of the query plan (which was pretty intense). I don't know if there's a way to see that to help troubleshooting situations where rules are getting triggered unnecessarily due to common mistakes (i.e. not constraining types correctly).

Bottom line, the end game is figuring why queries are not performing in certain situations. i.e. It's tough to assess whether the query plan is ok without manually figuring out everything the query references.

@izmalk
Copy link
Member Author

izmalk commented Mar 14, 2023

That would be correct @flyingsilverfin . Here's probably a poor example that might give an idea:

Nice. But that seems to be out of the scope of this particular issue. Can you create a separate issue?

@mathieuisabel
Copy link

@izmalk Just to be sure, you're referring to the query plan piece specifically for the new issue? The dependency graph would still be in scope as you would want to be able to query rules for that kind of output.

@izmalk
Copy link
Member Author

izmalk commented Mar 14, 2023

@izmalk Just to be sure, you're referring to the query plan piece specifically for the new issue? The dependency graph would still be in scope as you would want to be able to query rules for that kind of output.

I was referring to the dependency graph. While these features can be connected, even dependent on each other, I think they are different features and might have a different priority/deadline/author. The original feature only requests to be able to retrieve rules from a schema.

@flyingsilverfin
Copy link
Member

Related to vaticle/typedb#3281

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

No branches or pull requests

4 participants