feat: Initial prepare statement support for Postgres protocol#925
feat: Initial prepare statement support for Postgres protocol#925sunng87 merged 17 commits intoGreptimeTeam:developfrom
Conversation
88cd051 to
0f060a5
Compare
Codecov Report
@@ Coverage Diff @@
## develop #925 +/- ##
===========================================
- Coverage 85.88% 85.70% -0.19%
===========================================
Files 443 443
Lines 59202 59427 +225
===========================================
+ Hits 50848 50932 +84
- Misses 8354 8495 +141
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
I have some doubts whether defining |
|
Mysql implementation won't use this API because its protocol combines column definition with its first batch of results. If we remove do_describe from Actually when implementing this, I feel there is increased need for |
|
@sunng87 I have a feeling that the problem roots in the lack of some abstraction regards to "prepare" stmt of pg and mysql in |
Co-authored-by: LFC <bayinamine@gmail.com>
7ef5b4c to
88dca59
Compare
…meTeam#925) * feat: add describe statement to query_engine * feat: add ability to describe statement for sql handler * refactor: return schema instead of wrapped ref * test: resolve tests * feat: add initial support for prepared statements * feat: add parameter types to query statement * test: fix parser test * chore: add todo task * fix: turn on integer_datetime for binary timestamp * fix: format string using single quote * test: add tests for prepared statement * Apply suggestions from code review Co-authored-by: LFC <bayinamine@gmail.com> * refactor: use stream api from recordbatches --------- Co-authored-by: LFC <bayinamine@gmail.com>
I hereby agree to the terms of the GreptimeDB CLA
What's changed and what's your intention?
This is a proof-of-concept implementation of prepare statement for our postgres protocol adapter. In prepared statement, or extended query as in postgres, it follows a parse-bind-describe-execute process to run a query:
When statement is cached in server-side, parse and describe can be omitted.
In order to support this process, we need a new ability to get schema out of a query statement without executing it. This implementation relies on datafusion's LogicalPlan to get schema. Parameter types are added into
PlannerContextto make it work.Limitations
LogicalPlanand use its with_param_values for parameters replacement. And we also need a solution for parameter replacement on INSERT/DELETE/UPDATEMore postgres types need to be supported, especially those date/time types. The current encoding of timestamp is not compatible with psycopg3 and jdbc. This needs to be corrected in next patch.queryimplementation doesn't include parameter type while datafusion requires types when there is placeholders in sql.Checklist
Refer to a related PR or issue link (optional)