-
Notifications
You must be signed in to change notification settings - Fork 98
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
Error: Binder exception: Read after update is not supported. Try query with multiple statements. #2303
Comments
Hi @sapalli2989,
My understanding of WITH is to pipe the result from previous query part to the next query part. In your case,
In this example, the last two query parts are actually dependent because if
The answer is yes. We didn't support read after update for simplicity because we SQL standard also doesn't allow read after update in one statement. So we thought this is not an important use case. Since now there is user demand, we certainly can implement this. Though different from bug-fix, this is a relatively big feature and we should take a few weeks to implement and test. Let me know if you have further questions. |
Hi @andyfengHKU,
Yes, exactly. Your example and the one from Neo4j docs are better than mine, as they express those dependencies I have between query parts. The dependent pars are why I cannot easily split it up in multiple statements. Let me give you an example, which tries to reflect my case a bit more: Minimal example: Extract We need to drop This is a quite error-prone operation without graph features. But Cypher seems to be able to solve this operation very elegantly. I used following query in Neo4j successfully - it doesn't work with Kuzu yet: WITH "t2" as selected_id, "t6" as move_after_id
MATCH (s:T {id: selected_id})
OPTIONAL MATCH (a:T {id: move_after_id})
OPTIONAL MATCH (t1:T)-[e1:AFTER]->(s)
OPTIONAL MATCH (s)-[e2:AFTER]->(t3:T)
OPTIONAL MATCH (t5:T)-[e4:AFTER]->(a)
DELETE e1,e2,e4
CREATE (s)-[:AFTER]->(a)
WITH t1,t3,t5,s MATCH(t1) MATCH(t3) CREATE (t1)-[:AFTER]->(t3)
WITH t5,s MATCH(t5) CREATE (t5)-[:AFTER]->(s); (still in my early learning phase with Cypher, there might be a better solution)
If I feed query with above sample data:
, the result is as expected - not tested thoroughly though:
Not 42? 😂 Joking aside, happy to hear this is on the roadmap! From my own learning experience, I mostly tested queries with Neo4j web explorer first and then tried to execute it with Kuzu CLI. Assuming many folks do this, it probably makes sense for Neo4j -> Kuzu to be "copy and paste" query-wise.
Hope to have given a suitable example case that actually makes sense. Thanks much for your time! |
@sapalli2989 The example you gave make a lot of sense to me. I'll assign this issue to one of my colleagues to make sure Kùzu can run the example properly. I don't have an ETA for the fix now but certainly we will make it available in our November release.
FYI. We are releasing a Web explorer this week as well. Will announce in the slack when releasing.
Yes copy-paste is our ultimate goal. Currently there are still a few features that are missing but we should cover the majority by the end of this year. Though Kùzu will always ask for DDL because we believe this is the best practice for query performance and data integrity. |
Wonderful. Thank you, sir! |
Hi @andyfengHKU. Is there already any development branch or patch, where I could help with testing? |
Hi @sapalli2989, we actually need a bit more time to handle read after update due to some edge cases. Though for your use case, I have added a test case that does not require read after update.
Seems that you just need multiple update rather than read after update. Let me know if the above solution works. I'll also give a bit more details regarding read after update. We are solving an edge case where update creates dependency between query parts. |
No problem, take your time.
OK, let's modify the example slightly. Example 2, I'd now like to select Your query wouldn't do anything here, because the whole query is aborted with Assuming, the actual location of selected node is unknown, I'd like to keep query as generic as possible - so that we don't need to care about its location! For now let's revert to MATCH (s:T {id: "t1"}), (a:T {id: "t6"})
OPTIONAL MATCH (t0:T)-[e0:AFTER]->(s)
OPTIONAL MATCH (s)-[e1:AFTER]->(t2:T)
OPTIONAL MATCH (t5:T)-[e4:AFTER]->(a)
DELETE e0,e1,e4
CREATE (s)-[:AFTER]->(a)
WITH t0,t2,t5,s MATCH(t0) MATCH(t2) CREATE (t0)-[:AFTER]->(t2)
WITH t5,s MATCH(t5) CREATE (t5)-[:AFTER]->(s); But relation WITH t0,t2,t5,s MATCH(t0) MATCH(t2) CREATE (t0)-[:AFTER]->(t2) // (1)
WITH t5,s MATCH(t5) CREATE (t5)-[:AFTER]->(s); // (2) , What would be idealI guess the ideal query can use MATCH (s:T {id: "t1"}), (a:T {id: "t6"})
OPTIONAL MATCH (t0:T)-[e0:AFTER]->(s)
OPTIONAL MATCH (s)-[e1:AFTER]->(t2:T)
OPTIONAL MATCH (t5:T)-[e4:AFTER]->(a)
DELETE e0,e1,e4
CREATE (s)-[:AFTER]->(a), (t0)-[:AFTER]->(t2), (t5)-[:AFTER]->(s);
(Below is my previous idea, but I find it less than ideal) Previous ideaMATCH (s:T {id: "t1"}), (a:T {id: "t6"})
OPTIONAL MATCH (t0:T)-[e0:AFTER]->(s)
OPTIONAL MATCH (s)-[e1:AFTER]->(t2:T)
OPTIONAL MATCH (t5:T)-[e4:AFTER]->(a)
DELETE e0,e1,e4
CREATE (s)-[:AFTER]->(a)
WITH t0,t2,t5,s OPTIONAL MATCH(t0) OPTIONAL MATCH(t2) CREATE (t0)-[:AFTER]->(t2)
WITH t5,s OPTIONAL MATCH(t5) CREATE (t5)-[:AFTER]->(s); Neo4j currently doesn't support
For me, being able to query exactly these complex graph cases (imagine model of linked list again) would be one of the main advantages compared to SQL. Is there a chance to get this supported in Kuzu? Sorry, if this feature request should go in yet another direction. Sometimes ideas need time to grow.
Thanks! I stay tuned :-) |
I see your point. Though I think you can achieve what you want with just
Optional match will guarantee query not abort during match state. If certain pattern is not matched, e.g. I'll attach the full statements I ran in KuzuExplorer.
|
Ah great. My bad, I had the assumption, above query wouldn't run in Kuzu yet. But you're right, I used latest Kuzu DB + explorer and indeed this works - better than Neo4j! |
Read after update should now be supported in #3126 |
(Follow-up of #2300)
Contrived example:
This query works as is with Neo4j.
Not sure about the error message - isn't the purpose of
WITH
to separate query parts, so there isn't any read operation directly following after update/delete? Would be curious to hear, if this is this going to be supported.To add some context:
In my case there are multiple optional, somehow dependent nodes or relations, which are to be deleted, if they exist. I used multiple
MATCH ... DELETE
constructs for this purpose (also to omit error in #2300). These deletes are connected byWITH
to keep logic in one query, as there are dependent parts - I don't want to use multiple statements here. A corresponding query structure with multipleWITH
andMERGE
(instead ofDELETE
) can be found here (page bottom) for reference.The text was updated successfully, but these errors were encountered: