trinodb / trino-python-client

Python client for Trino
Apache License 2.0
309 stars 151 forks source link

Add callproc to call stored procedures #320

Open mdesmet opened 1 year ago

mdesmet commented 1 year ago

Describe the feature

DBAPI provides following method to call stored procedures.

.callproc( procname [, parameters ] ) (This method is optional since not all databases provide stored procedures. [3]) Call a stored database procedure with the given name. The sequence of parameters must contain one entry for each argument that the procedure expects. The result of the call is returned as modified copy of the input sequence. Input parameters are left untouched, output and input/output parameters replaced with possibly new values.

The procedure may also provide a result set as output. This must then be made available through the standard .fetch*() methods.

Describe alternatives you've considered

No response

Are you willing to submit PR?

hashhar commented 1 year ago

There are no stored procedures yet on the server side. Can you share more detail about how it might be used?

mdesmet commented 1 year ago

See https://trino.io/docs/current/sql/call.html

For example there exists a stored procedure to register a table on Iceberg.

hashhar commented 1 year ago

I don't think those are "stored procedures" regardless of what the docs say.

@martint / @dain Once/when SQL defined functions land do we expect to reuse the CALL statement to execute those? I'd like to avoid a situation where we need to change what callproc does once SQL defined functions/SPs are available since it'd break user code.