substrait-io / duckdb-substrait-extension

MIT License
28 stars 22 forks source link

Reuse connection to Extract,Consume and execute substrait query plans #113

Closed pdet closed 2 weeks ago

pdet commented 2 months ago

Up until now, we have been creating new connections to interact with substrait. This was necessary to circumvent the client context lock.

However, this was a brittle solution and especially problematic when dealing with temporary objects since these are not passed around new connections.

This PR allows us to reuse the same connection by utilizing a new flexible relation binder that allows us to consume and execute substrait plans from within the same connection; it also changes the from_substrait functions to use bind replace.

Aditionally, extracting plans will also go through a specialized code path, to allow us to use the same connection.

Since substrait also uses special options (e.g., some optimizations are disabled), these are set and reset on the original connection.