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

Bug: [Recursive relationship] Error: Runtime exception: Internal ID of relationship is not scanned. This should not happen. #3793

Closed
sapalli2989 opened this issue Jul 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@sapalli2989
Copy link
Contributor

sapalli2989 commented Jul 10, 2024

Kùzu version

nightly

What operating system are you using?

Fedora 39

What happened?

With demo dataset execute following query:

MATCH p = (u:User {name: "Adam"})-[e:Follows* (r, n | WHERE EXISTS { MATCH (n)-[:LivesIn]->(:City) })]->(u2:User {name: "Noura"})
RETURN properties(nodes(p),'name'), properties(rels(p),"_label");

Error message:

Error: Runtime exception: Internal ID of relationship is not scanned. This should not happen.

(r, n | WHERE EXISTS { MATCH (n)-[:LivesIn]->(:City) }) is basically a placeholder for more complex filtering logic based on node and relation for current traversion step within a recursive MATCH pattern. It was used here as simple example and shouldn't change results, as every :User in the graph has a :City assigned. Without this clause, result is

kuzu> MATCH p = (u:User {name: "Adam"})-[e:Follows*]->(u2:User {name: "Noura"}) RETURN properties(nodes(p),'name'), properties(rels(p),"_label");
-----------------------------------------------------------
| PROPERTIES(NODES(p),name)  | PROPERTIES(RELS(p),_label) |
-----------------------------------------------------------
| [Adam,Zhang,Noura]         | [Follows,Follows]          |
-----------------------------------------------------------
| [Adam,Karissa,Zhang,Noura] | [Follows,Follows,Follows]  |
-----------------------------------------------------------

, which also would be expected for former query.

(after discussion with @andyfengHKU )

Are there known steps to reproduce?

No response

@sapalli2989 sapalli2989 added the bug Something isn't working label Jul 10, 2024
@ray6080 ray6080 mentioned this issue Jul 12, 2024
81 tasks
@andyfengHKU
Copy link
Contributor

Hi @sapalli2989,

Sorry took a while to get on this. Once #4052 is fixed, I suggest the following rewrite

MATCH (n)-[:LivesIn]->(:City)
 WITH collect(n.name) AS names // collect names that satisfies the pattern
 MATCH p = (u:User {name: "Adam"})-[e:Follows*]->(u2:User {name: "Noura"})
 WITH properties(nodes(e),'name') AS pathNames, names, p AS path // find names without running predicate
 WITH size(pathNames) AS originalSize, size(list_filter(pathNames, x->x IN names)) AS filteredSize, path 
 WHERE originalSize = filteredSize // make sure all elements in list satisfy lambda `x IN names`
 RETURN properties(nodes(path),'name')

@ray6080 ray6080 mentioned this issue Oct 22, 2024
5 tasks
@ray6080
Copy link
Contributor

ray6080 commented Jan 20, 2025

The exception is no longer reproducible on latest master.
We can run the query as it is now.

MATCH p = (u:User {name: "Adam"})-[e:Follows* (r, n | WHERE EXISTS { MATCH (n)-[:LivesIn]->(:City) })]->(u2:User {name: "Noura"})
RETURN properties(nodes(p),'name'), properties(rels(p),"_label");

@ray6080 ray6080 closed this as completed Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants