-
Notifications
You must be signed in to change notification settings - Fork 17
Support with_parameter and with_parameters in query engine #125
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
ChunxuTang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leiyuou Thanks for the contribution! This is a very nice work.
I carefully re-evaluated the three design options for the parameter support, and I think it's better to go with option 1 (replacing the parameters during the semantic analysis pass). Could you update the PR?
| alt(( | ||
| // $param | ||
| map(preceded(char('$'), identifier), |s| s.to_string()), | ||
| // @param | ||
| map(preceded(char('@'), identifier), |s| s.to_string()), | ||
| // :param | ||
| map(preceded(char(':'), identifier), |s| s.to_string()), | ||
| // {param} | ||
| map(delimited(char('{'), identifier, char('}')), |s| { | ||
| s.to_string() | ||
| }), | ||
| ))(input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formal Cypher syntax only supports using $ for parameters. Could you remove other special symbols?
| assert "company" in engine_config.node_labels() | ||
|
|
||
|
|
||
| def test_cypher_parameter_syntax(graph_env): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new test is unrelated to the CypherEngine API: maybe put it into the test_graph.py?
| // 1. Resolve parameters during semantic analysis (substitute before planning) | ||
| // 2. Pass parameter map to to_df_value_expr and resolve here | ||
| // 3. Use DataFusion's parameter binding mechanism | ||
| col(format!("${}", name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leiyuou I've carefully considered the design options here, and I think it's better to go with option 1 for now. Here are the rationales:
-
If using option 2/3, we can only support parameters in the DataFusion planner, but we also have the simple executor and later Lance native planner. We'll have to re-implement similar mechanisms in all these planners.
-
Very recently, we added a case-insensitivity enforcement feat: implement case-insensitive support #119), which lowers all table/column/alias names. But the parameters here are case-sensitive, which will cause execution failures. It's better to replace them during the semantic analysis step.
Support $param, @param, :param, and {param} placeholder in query engine.
Key Changes:
Closes #103.