Skip to main content

Module replacement

Module replacement 

Source
Expand description

DuckDB replacement scans: rewrite an unresolved table reference into a table function call. Experimental — see the module docs. DuckDB replacement scans: automatically rewrite an unresolved table reference into a table function call — e.g. routing SELECT * FROM 'data.parquet' to read_parquet('data.parquet') by file extension, without the caller writing the function call explicitly.

§Experimental

No comparable safe-Rust design exists in the reference duckdb crate to model this on — this is a from-scratch design. It deliberately restricts what a replacement scan can do: it may only rewrite the unresolved name into a table function call with literal parameters (ReplacementScanInfo::set_function_name/add_parameter). There is no way to run SQL from inside the callback — DuckDB invokes it while resolving the very query being planned, on the same connection; issuing another query from there would re-enter (and likely deadlock or corrupt) that in-progress resolution. If a rewrite needs data that can only come from a query, compute it before the query that triggers the scan, not inside the callback.

Structs§

ReplacementScanInfo
An interface to redirect an unresolved table reference during a replacement scan callback.

Traits§

ReplacementScan
A hook that rewrites an unresolved table reference into a table function call. See the module docs for the v1 scope restriction (no SQL execution).