macro_rules! duck_projection {
() => { ... };
}Expand description
Returns the 0-based column indices the current query actually needs, as a
Vec<usize>, from inside a #[duckdb_table_function(projection_pushdown)]
function body.
Empty if the query didn’t request pushdown (every column is wanted).
§Panics
Panics if called outside a table function’s init callback — contained by
this crate’s callback machinery, so it always surfaces as a normal query
error, never undefined behavior.
§Examples
use better_duck_core::{connection::Connection, duck_projection, duckdb_table_function};
#[duckdb_table_function(columns("a", "b"), projection_pushdown)]
fn two_cols() -> impl Iterator<Item = (i32, i32)> + Send {
let wanted = duck_projection!();
// `wanted` lists which of columns 0 (`a`) / 1 (`b`) the query needs.
let _ = wanted;
std::iter::once((1, 2))
}
let mut conn = Connection::open_in_memory()?;
two_cols::register(&mut conn)?;