Skip to content

fix: #1447 decide writes via bound_plan::write::is_write_statement (clause-list only) - #1564

Open
hari2353 wants to merge 1 commit into
genezhang:mainfrom
hari2353:fix/1447-is-write-statement
Open

hari2353 wants to merge 1 commit into
genezhang:mainfrom
hari2353:fix/1447-is-write-statement

Conversation

@hari2353

Copy link
Copy Markdown

Adds bound_plan::write::is_write_statement using only the clause-list parser (no legacy AST fallback), and switches the embedded dispatcher to it.

@genezhang

Copy link
Copy Markdown
Owner

Thanks for looking at #1447. I compared this against main and could not find a statement where the two behave differently, so I'd suggest not merging it as is.

What I did. I compared StatementTargets::of(text).is_write(), which is what the dispatcher reads today, with the new is_write_statement(text) on 25 statement shapes: plain reads and writes, a write in a later UNION arm, COUNT { } in SET / RETURN / WHERE of a write, MERGE, FOREACH, CALL, DETACH DELETE, SET n:Label, UNWIND … CREATE, and more. The results are identical for all 25.

Why. StatementTargets::of already tries the clause-list parser first and returns its result when the text parses (#1504). The legacy parser is only the fallback for text the clause-list parser rejects, and none of my shapes reached it. The UNION half of #1447 was fixed by #1504. For the COUNT { } half, the clause-list parser now reads those statements, so they already classify as writes on main. I checked the classification only, not a full COUNT { } write executed on chdb.

So the change is a refactor, and it duplicates the Create | Set | Remove | Delete match that prepared.rs already has. If the goal is a single place for that decision, one option is to have StatementTargets::of call is_write_statement. Either way it would need a test (for example the COUNT { } write shapes through the dispatcher).

I'd say #1447 can be closed once that COUNT { } write is confirmed end to end on chdb. If you'd like to take that on instead of this refactor, we'd welcome it.

This branch has not been deployed

No deployments
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