-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support PREPARE statements without explicit parameters #4683
Comments
EXECUTE
statement for prepared statement
Thanks @alamb for writing up a ticket, and thank you @NGA-TRAN for building out an implementation! My personal backstory is that I'm trying to run https://github.com/AgilData/tpcc which defines a number of prepared statements: https://gist.github.com/avantgardnerio/5bdf77297956add71cbf664d3366224b When the JDBC client calls the server, it doesn't use the
and returns a response:
This leads me to believe that in order to be compatible with the FlightSQL JDBC client and apps that use it, the type inference has to happen in the DataFusion planner. That being said, implementation might not be too difficult: based upon the statements in the git gist above, types always seem to be:
I think it would be possible to take:
and make This way the placeholders could serve for a 1st pass, then a second inference pass could walk the tree, infer the types and set them if possible or error if it can't figure them out. Just a suggestion - let me know if I can help out more. |
I think this is a good high level plan (and one that has been sketched out in #4701 )
I think starting with simple rules (aka use the type of the other side of the operator) would be good and then we can extend the rules to be more sophisticated over time as needs evolve (like |
Currently, DataFusion has support for Prepared statements (thanks @NGA-TRAN !) https://github.com/apache/arrow-datafusion/blob/fddb3d3651041f41d66a801f10e27387e84374f7/datafusion/expr/src/logical_plan/plan.rs#L119-L121
However, currently the types of the parameters must be supplied
@avantgardnerio noted that the types of the parameters in the postgres
PREPARE
statement https://www.postgresql.org/docs/current/sql-prepare.html#:~:text=A%20prepared%20statement%20is%20a,statement%20is%20planned%20and%20executed. is optionalSo for example
And the planner should be able to and infer the types (in this case, I assume create table person (int id, int age)) so the parameter $1 must be of type int and return that to the FlightSQL Client
The text was updated successfully, but these errors were encountered: