diff --git a/vortex-duckdb/cpp/include/duckdb_vx/table_function.h b/vortex-duckdb/cpp/include/duckdb_vx/table_function.h index 3e2b0580684..4b60207a036 100644 --- a/vortex-duckdb/cpp/include/duckdb_vx/table_function.h +++ b/vortex-duckdb/cpp/include/duckdb_vx/table_function.h @@ -114,21 +114,14 @@ typedef struct { duckdb_vx_data (*init_global)(const duckdb_vx_tfunc_init_input *input, duckdb_vx_error *error_out); - duckdb_vx_data (*init_local)(const duckdb_vx_tfunc_init_input *input, - void *init_global_data, - duckdb_vx_error *error_out); + duckdb_vx_data (*init_local)(void *init_global_data); - void (*function)(duckdb_client_context ctx, - const void *bind_data, - void *init_global_data, + void (*function)(void *init_global_data, void *init_local_data, duckdb_data_chunk data_chunk_out, duckdb_vx_error *error_out); - bool (*statistics)(duckdb_client_context context, - const void *bind_data, - size_t column_index, - duckdb_column_statistics *stats_out); + bool (*statistics)(const void *bind_data, size_t column_index, duckdb_column_statistics *stats_out); void (*cardinality)(void *bind_data, duckdb_vx_node_statistics *node_stats_out); @@ -136,10 +129,9 @@ typedef struct { void (*to_string)(void *bind_data, duckdb_vx_string_map map); - double (*table_scan_progress)(duckdb_client_context ctx, void *bind_data, void *global_state); + double (*table_scan_progress)(void *global_state); - void (*get_partition_data)(const void *bind_data, - void *init_global_data, + void (*get_partition_data)(void *init_global_data, void *init_local_data, duckdb_vx_partition_data *partition_data_out); } duckdb_vx_tfunc_vtab_t; diff --git a/vortex-duckdb/cpp/table_function.cpp b/vortex-duckdb/cpp/table_function.cpp index fcfcd826bad..c7bb885e937 100644 --- a/vortex-duckdb/cpp/table_function.cpp +++ b/vortex-duckdb/cpp/table_function.cpp @@ -82,14 +82,12 @@ struct CTableLocalData final : LocalTableFunctionState { unique_ptr ffi_data; }; -double c_table_scan_progress(ClientContext &context, - const FunctionData *bind_data, - const GlobalTableFunctionState *global_state) { +double table_scan_progress(ClientContext &, + const FunctionData *bind_data, + const GlobalTableFunctionState *global_state) { auto &bind = bind_data->Cast(); - duckdb_client_context c_ctx = reinterpret_cast(&context); - void *const c_bind_data = bind.ffi_data->DataPtr(); void *const c_global_state = global_state->Cast().ffi_data->DataPtr(); - return bind.info.vtab.table_scan_progress(c_ctx, c_bind_data, c_global_state); + return bind.info.vtab.table_scan_progress(c_global_state); } static Value &UnwrapValue(duckdb_value value) { @@ -140,8 +138,7 @@ unique_ptr base_stats(duckdb_column_statistics &stats, LogicalTy return out.ToUnique(); } -unique_ptr -c_statistics(ClientContext &context, const FunctionData *bind_data, column_t column_index) { +unique_ptr statistics(ClientContext &, const FunctionData *bind_data, column_t column_index) { if (IsVirtualColumn(column_index)) { return {}; } @@ -149,9 +146,8 @@ c_statistics(ClientContext &context, const FunctionData *bind_data, column_t col const auto &bind = bind_data->Cast(); void *const ffi_bind = bind.ffi_data->DataPtr(); - duckdb_client_context c_ctx = reinterpret_cast(&context); duckdb_column_statistics statistics = {}; - if (!bind.info.vtab.statistics(c_ctx, ffi_bind, column_index, &statistics)) { + if (!bind.info.vtab.statistics(ffi_bind, column_index, &statistics)) { return {}; } @@ -243,43 +239,25 @@ unique_ptr c_init_global(ClientContext &context, Table return make_uniq(std::move(cdata)); } -unique_ptr c_init_local(ExecutionContext &context, - TableFunctionInitInput &input, - GlobalTableFunctionState *global_state) { +unique_ptr +init_local(ExecutionContext &, TableFunctionInitInput &input, GlobalTableFunctionState *global_state) { const auto &bind = input.bind_data->Cast(); void *const ffi_global = global_state->Cast().ffi_data->DataPtr(); - duckdb_vx_tfunc_init_input ffi_input = { - .bind_data = bind.ffi_data->DataPtr(), - .column_ids = input.column_ids.data(), - .column_ids_count = input.column_ids.size(), - .projection_ids = input.projection_ids.data(), - .projection_ids_count = input.projection_ids.size(), - .filters = reinterpret_cast(input.filters.get()), - .client_context = reinterpret_cast(&context), - }; - - duckdb_vx_error error_out = nullptr; - duckdb_vx_data ffi_local_data = bind.info.vtab.init_local(&ffi_input, ffi_global, &error_out); - if (error_out) { - throw BinderException(IntoErrString(error_out)); - } - + duckdb_vx_data ffi_local_data = bind.info.vtab.init_local(ffi_global); auto cdata = unique_ptr(reinterpret_cast(ffi_local_data)); return make_uniq(std::move(cdata)); } -void c_function(ClientContext &context, TableFunctionInput &input, DataChunk &output) { +void function(ClientContext &, TableFunctionInput &input, DataChunk &output) { const auto &bind = input.bind_data->Cast(); - duckdb_client_context ffi_ctx = reinterpret_cast(&context); - void *const ffi_bind = bind.ffi_data->DataPtr(); void *const ffi_global = input.global_state->Cast().ffi_data->DataPtr(); void *const ffi_local = input.local_state->Cast().ffi_data->DataPtr(); duckdb_data_chunk chunk = reinterpret_cast(&output); duckdb_vx_error error_out = nullptr; - bind.info.vtab.function(ffi_ctx, ffi_bind, ffi_global, ffi_local, chunk, &error_out); + bind.info.vtab.function(ffi_global, ffi_local, chunk, &error_out); if (error_out) { throw InvalidInputException(IntoErrString(error_out)); } @@ -366,11 +344,10 @@ TablePartitionInfo get_partition_info(ClientContext &, TableFunctionPartitionInp */ OperatorPartitionData get_partition_data(ClientContext &, TableFunctionGetPartitionInput &input) { auto &bind = input.bind_data->Cast(); - void *const ffi_bind = bind.ffi_data->DataPtr(); void *const ffi_global = input.global_state->Cast().ffi_data->DataPtr(); void *const ffi_local = input.local_state->Cast().ffi_data->DataPtr(); duckdb_vx_partition_data partition_data; - bind.info.vtab.get_partition_data(ffi_bind, ffi_global, ffi_local, &partition_data); + bind.info.vtab.get_partition_data(ffi_global, ffi_local, &partition_data); OperatorPartitionData out(partition_data.partition_index); @@ -410,7 +387,7 @@ extern "C" duckdb_state duckdb_vx_tfunc_register(duckdb_database ffi_db, const d const DatabaseWrapper &wrapper = *reinterpret_cast(ffi_db); DatabaseInstance &db = *wrapper.database->instance; - TableFunction tf(vtab->name, {}, c_function, c_bind, c_init_global, c_init_local); + TableFunction tf(vtab->name, {}, function, c_bind, c_init_global, init_local); tf.projection_pushdown = true; tf.filter_pushdown = true; @@ -422,8 +399,8 @@ extern "C" duckdb_state duckdb_vx_tfunc_register(duckdb_database ffi_db, const d tf.get_partition_info = get_partition_info; tf.get_partition_data = get_partition_data; tf.to_string = c_to_string; - tf.table_scan_progress = c_table_scan_progress; - tf.statistics = c_statistics; + tf.table_scan_progress = table_scan_progress; + tf.statistics = statistics; tf.late_materialization = true; // Columns that uniquely identify a row for deferred re-fetch in a multi diff --git a/vortex-duckdb/src/datasource.rs b/vortex-duckdb/src/datasource.rs index b3b6c7ad09f..1f07155e1f6 100644 --- a/vortex-duckdb/src/datasource.rs +++ b/vortex-duckdb/src/datasource.rs @@ -254,10 +254,6 @@ impl ColumnStatisticsAggregate { } } -// --------------------------------------------------------------------------- -// Blanket TableFunction implementation for any DataSourceTableFunction -// --------------------------------------------------------------------------- - impl TableFunction for T { type BindData = DataSourceBindData; type GlobalState = DataSourceGlobal; @@ -398,10 +394,7 @@ impl TableFunction for T { }) } - fn init_local( - _init: &TableInitInput, - global: &Self::GlobalState, - ) -> VortexResult { + fn init_local(global: &Self::GlobalState) -> Self::LocalState { unsafe { use custom_labels::sys; @@ -417,17 +410,15 @@ impl TableFunction for T { CURRENT_LABELSET.set(key, value); } - Ok(DataSourceLocal { + DataSourceLocal { iterator: global.iterator.clone(), exporter: None, partition_index: 0, file_index: 0, - }) + } } fn scan( - _client_context: &ClientContextRef, - _bind_data: &Self::BindData, local_state: &mut Self::LocalState, global_state: &Self::GlobalState, chunk: &mut DataChunkRef, @@ -501,11 +492,7 @@ impl TableFunction for T { Ok(()) } - fn table_scan_progress( - _client_context: &ClientContextRef, - _bind_data: &Self::BindData, - global_state: &Self::GlobalState, - ) -> f64 { + fn table_scan_progress(global_state: &Self::GlobalState) -> f64 { progress(&global_state.bytes_read, &global_state.bytes_total) } @@ -532,11 +519,7 @@ impl TableFunction for T { /// Get column-wise statistics. Available only if we're reading a single /// file. - fn statistics( - _client_context: &ClientContextRef, - bind_data: &Self::BindData, - column_index: usize, - ) -> Option { + fn statistics(bind_data: &Self::BindData, column_index: usize) -> Option { let children = bind_data.data_source.children(); // Otherwise we'd have to open all files eagerly which is a performance // regression. Duckdb's Parquet reader only gets metadata for multiple @@ -566,7 +549,6 @@ impl TableFunction for T { } fn partition_data( - _bind_data: &Self::BindData, global_init_data: &Self::GlobalState, local_init_data: &mut Self::LocalState, ) -> PartitionData { @@ -586,10 +568,6 @@ impl TableFunction for T { } } -// --------------------------------------------------------------------------- -// Helper functions -// --------------------------------------------------------------------------- - /// Extracts DuckDB column names and logical types from a Vortex struct DType. fn extract_schema_from_dtype(dtype: &DType) -> VortexResult> { let struct_dtype = dtype diff --git a/vortex-duckdb/src/duckdb/table_function/init.rs b/vortex-duckdb/src/duckdb/table_function/init.rs index f58e558d0b2..6baa6d6a300 100644 --- a/vortex-duckdb/src/duckdb/table_function/init.rs +++ b/vortex-duckdb/src/duckdb/table_function/init.rs @@ -40,26 +40,13 @@ pub(crate) unsafe extern "C-unwind" fn init_global_callback( /// Native callback for the local initialization of a table function. pub(crate) unsafe extern "C-unwind" fn init_local_callback( - init_input: *const cpp::duckdb_vx_tfunc_init_input, global_init_data: *mut c_void, - error_out: *mut cpp::duckdb_vx_error, ) -> cpp::duckdb_vx_data { - let init_input = TableInitInput::new( - unsafe { init_input.as_ref() }.vortex_expect("init_input null pointer"), - ); - let global_init_data = unsafe { global_init_data.cast::().as_ref() } .vortex_expect("global_init_data null pointer"); - match T::init_local(&init_input, global_init_data) { - Ok(init_data) => Data::from(Box::new(init_data)).as_ptr(), - Err(e) => { - // Set the error in the error output. - let msg = e.to_string(); - unsafe { error_out.write(cpp::duckdb_vx_error_create(msg.as_ptr().cast(), msg.len())) }; - ptr::null_mut::().cast() - } - } + let init_data = T::init_local(global_init_data); + Data::from(Box::new(init_data)).as_ptr() } /// A typed wrapper for the input to a table function's initialization. diff --git a/vortex-duckdb/src/duckdb/table_function/mod.rs b/vortex-duckdb/src/duckdb/table_function/mod.rs index 1b3b8199e0e..986ac64d100 100644 --- a/vortex-duckdb/src/duckdb/table_function/mod.rs +++ b/vortex-duckdb/src/duckdb/table_function/mod.rs @@ -5,35 +5,28 @@ use std::ffi::CStr; use std::ffi::CString; use std::ffi::c_void; use std::fmt::Debug; +use std::ptr; use vortex::error::VortexExpect; use vortex::error::VortexResult; mod bind; mod cardinality; mod init; -mod partition; -mod pushdown_complex_filter; -mod statistics; -mod table_scan_progress; pub use bind::*; pub use init::*; use crate::cpp; -use crate::cpp::duckdb_client_context; -use crate::duckdb::ClientContext; use crate::duckdb::DataChunk; use crate::duckdb::DatabaseRef; +use crate::duckdb::Expression; use crate::duckdb::LogicalType; use crate::duckdb::Value; use crate::duckdb::client_context::ClientContextRef; use crate::duckdb::data_chunk::DataChunkRef; use crate::duckdb::expr::ExpressionRef; use crate::duckdb::table_function::cardinality::cardinality_callback; -use crate::duckdb::table_function::partition::get_partition_data_callback; -use crate::duckdb::table_function::pushdown_complex_filter::pushdown_complex_filter_callback; -use crate::duckdb::table_function::statistics::statistics; -use crate::duckdb::table_function::table_scan_progress::table_scan_progress_callback; +use crate::duckdb::try_or; use crate::duckdb_try; pub struct PartitionData { @@ -86,16 +79,10 @@ pub trait TableFunction: Sized + Debug { /// Report column statistics for a file or collections of files e.g. /// registered as a VIEW. - fn statistics( - client_context: &ClientContextRef, - bind_data: &Self::BindData, - column_index: usize, - ) -> Option; + fn statistics(bind_data: &Self::BindData, column_index: usize) -> Option; /// The function is called during query execution and is responsible for producing the output fn scan( - client_context: &ClientContextRef, - bind_data: &Self::BindData, init_local: &mut Self::LocalState, init_global: &Self::GlobalState, chunk: &mut DataChunkRef, @@ -111,17 +98,10 @@ pub trait TableFunction: Sized + Debug { /// /// The local operator state is used to keep track of the progress in the table function and /// is thread-local. - fn init_local( - init: &TableInitInput, - global: &Self::GlobalState, - ) -> VortexResult; + fn init_local(global: &Self::GlobalState) -> Self::LocalState; /// Return table scanning progress from 0. to 100. - fn table_scan_progress( - client_context: &ClientContextRef, - bind_data: &Self::BindData, - global_state: &Self::GlobalState, - ) -> f64; + fn table_scan_progress(global_state: &Self::GlobalState) -> f64; /// Pushes down a filter expression to the table function. /// @@ -129,21 +109,16 @@ pub trait TableFunction: Sized + Debug { /// or `false` if the filter could not be pushed down. In which case, the filter will be /// applied later in the query plan. fn pushdown_complex_filter( - _bind_data: &mut Self::BindData, - _expr: &ExpressionRef, - ) -> VortexResult { - Ok(false) - } + bind_data: &mut Self::BindData, + expr: &ExpressionRef, + ) -> VortexResult; /// Returns the cardinality estimate of the table function. - fn cardinality(_bind_data: &Self::BindData) -> Cardinality { - Cardinality::Unknown - } + fn cardinality(bind_data: &Self::BindData) -> Cardinality; /// Returns the idx of the current partition being processed by a local threa. /// This *must* be globally unique. fn partition_data( - bind_data: &Self::BindData, global_init_data: &Self::GlobalState, local_init_data: &mut Self::LocalState, ) -> PartitionData; @@ -207,30 +182,73 @@ unsafe extern "C-unwind" fn to_string_callback( T::to_string(bind_data, map); } -/// The native function callback for a table function. -unsafe extern "C-unwind" fn function( - duckdb_client_context: duckdb_client_context, +unsafe extern "C-unwind" fn statistics( bind_data: *const c_void, + column_index: usize, + stats_out: *mut cpp::duckdb_column_statistics, +) -> bool { + let stats_out = unsafe { &mut *stats_out }; + let bind_data = + unsafe { bind_data.cast::().as_ref() }.vortex_expect("bind_data null pointer"); + let Some(stats) = T::statistics(bind_data, column_index) else { + return false; + }; + stats_out.min = stats.min.map_or(ptr::null_mut(), |v| v.into_ptr()); + stats_out.max = stats.max.map_or(ptr::null_mut(), |v| v.into_ptr()); + stats_out.max_string_length = stats.max_string_length; + stats_out.has_null = stats.has_null; + true +} + +unsafe extern "C-unwind" fn table_scan_progress_callback( + global_state: *mut c_void, +) -> f64 { + let global_state = unsafe { global_state.cast::().as_ref() } + .vortex_expect("global_init_data null pointer"); + T::table_scan_progress(global_state) +} + +unsafe extern "C-unwind" fn get_partition_data_callback( + global_init_data: *mut c_void, + local_init_data: *mut c_void, + partition_data_out: *mut cpp::duckdb_vx_partition_data, +) { + let global_init_data = unsafe { global_init_data.cast::().as_ref() } + .vortex_expect("global_init_data null pointer"); + let local_init_data = unsafe { local_init_data.cast::().as_mut() } + .vortex_expect("local_init_data null pointer"); + let data = T::partition_data(global_init_data, local_init_data); + let out = unsafe { &mut *partition_data_out }; + + out.partition_index = data.partition_index; + out.file_index_column_pos = data.file_index_column_pos.unwrap_or(usize::MAX); + out.file_index = data.file_index; +} + +unsafe extern "C-unwind" fn pushdown_complex_filter_callback( + bind_data: *mut c_void, + expr: cpp::duckdb_vx_expr, + error_out: *mut cpp::duckdb_vx_error, +) -> bool { + let bind_data = + unsafe { bind_data.cast::().as_mut() }.vortex_expect("bind_data null pointer"); + let expr = unsafe { Expression::borrow(expr) }; + try_or(error_out, || T::pushdown_complex_filter(bind_data, expr)) +} + +unsafe extern "C-unwind" fn function( global_init_data: *mut c_void, local_init_data: *mut c_void, output: cpp::duckdb_data_chunk, error_out: *mut cpp::duckdb_vx_error, ) { - let client_context = unsafe { ClientContext::borrow(duckdb_client_context) }; - let bind_data = unsafe { &*(bind_data as *const T::BindData) }; let global_init_data = unsafe { global_init_data.cast::().as_ref() } .vortex_expect("global_init_data null pointer"); let local_init_data = unsafe { local_init_data.cast::().as_mut() } .vortex_expect("local_init_data null pointer"); let data_chunk = unsafe { DataChunk::borrow_mut(output) }; - match T::scan( - client_context, - bind_data, - local_init_data, - global_init_data, - data_chunk, - ) { + match T::scan(local_init_data, global_init_data, data_chunk) { Ok(()) => { // The data chunk is already filled by the function. // No need to do anything here. diff --git a/vortex-duckdb/src/duckdb/table_function/partition.rs b/vortex-duckdb/src/duckdb/table_function/partition.rs deleted file mode 100644 index d373d6f5623..00000000000 --- a/vortex-duckdb/src/duckdb/table_function/partition.rs +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: Copyright the Vortex contributors - -use std::ffi::c_void; - -use vortex::error::VortexExpect; - -use crate::cpp; -use crate::duckdb::TableFunction; - -/// Native callback for the cardinality estimate of a table function. -pub(crate) unsafe extern "C-unwind" fn get_partition_data_callback( - bind_data: *const c_void, - global_init_data: *mut c_void, - local_init_data: *mut c_void, - partition_data_out: *mut cpp::duckdb_vx_partition_data, -) { - let bind_data = - unsafe { bind_data.cast::().as_ref() }.vortex_expect("bind_data null pointer"); - let global_init_data = unsafe { global_init_data.cast::().as_ref() } - .vortex_expect("global_init_data null pointer"); - let local_init_data = unsafe { local_init_data.cast::().as_mut() } - .vortex_expect("local_init_data null pointer"); - let data = T::partition_data(bind_data, global_init_data, local_init_data); - let out = unsafe { &mut *partition_data_out }; - out.partition_index = data.partition_index; - - out.file_index_column_pos = data.file_index_column_pos.unwrap_or(usize::MAX); - out.file_index = data.file_index; -} diff --git a/vortex-duckdb/src/duckdb/table_function/pushdown_complex_filter.rs b/vortex-duckdb/src/duckdb/table_function/pushdown_complex_filter.rs deleted file mode 100644 index bf85d4163a9..00000000000 --- a/vortex-duckdb/src/duckdb/table_function/pushdown_complex_filter.rs +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: Copyright the Vortex contributors - -use std::ffi::c_void; - -use vortex::error::VortexExpect; - -use crate::cpp; -use crate::duckdb::Expression; -use crate::duckdb::TableFunction; -use crate::duckdb::try_or; - -/// Native callback for the global initialization of a table function. -pub(crate) unsafe extern "C-unwind" fn pushdown_complex_filter_callback( - bind_data: *mut c_void, - expr: cpp::duckdb_vx_expr, - error_out: *mut cpp::duckdb_vx_error, -) -> bool { - let bind_data = - unsafe { bind_data.cast::().as_mut() }.vortex_expect("bind_data null pointer"); - let expr = unsafe { Expression::borrow(expr) }; - try_or(error_out, || T::pushdown_complex_filter(bind_data, expr)) -} diff --git a/vortex-duckdb/src/duckdb/table_function/statistics.rs b/vortex-duckdb/src/duckdb/table_function/statistics.rs deleted file mode 100644 index 7f923dddefd..00000000000 --- a/vortex-duckdb/src/duckdb/table_function/statistics.rs +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: Copyright the Vortex contributors - -use std::ffi::c_void; -use std::ptr; - -use vortex::error::VortexExpect; - -use crate::cpp; -use crate::duckdb::ClientContext; -use crate::duckdb::TableFunction; - -pub(crate) unsafe extern "C-unwind" fn statistics( - ctx: cpp::duckdb_client_context, - bind_data: *const c_void, - column_index: usize, - stats_out: *mut cpp::duckdb_column_statistics, -) -> bool { - let stats_out = unsafe { &mut *stats_out }; - let client_context = unsafe { ClientContext::borrow(ctx) }; - let bind_data = - unsafe { bind_data.cast::().as_ref() }.vortex_expect("bind_data null pointer"); - let Some(stats) = T::statistics(client_context, bind_data, column_index) else { - return false; - }; - stats_out.min = stats.min.map_or(ptr::null_mut(), |v| v.into_ptr()); - stats_out.max = stats.max.map_or(ptr::null_mut(), |v| v.into_ptr()); - stats_out.max_string_length = stats.max_string_length; - stats_out.has_null = stats.has_null; - true -} diff --git a/vortex-duckdb/src/duckdb/table_function/table_scan_progress.rs b/vortex-duckdb/src/duckdb/table_function/table_scan_progress.rs deleted file mode 100644 index cfe3dd43b45..00000000000 --- a/vortex-duckdb/src/duckdb/table_function/table_scan_progress.rs +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: Copyright the Vortex contributors - -use vortex::error::VortexExpect; - -use crate::duckdb::TableFunction; - -pub(crate) unsafe extern "C-unwind" fn table_scan_progress_callback( - ctx: crate::cpp::duckdb_client_context, - bind_data: *mut ::std::os::raw::c_void, - global_state: *mut ::std::os::raw::c_void, -) -> f64 { - let ctx = unsafe { crate::duckdb::ClientContext::borrow(ctx) }; - let bind_data = - unsafe { bind_data.cast::().as_ref() }.vortex_expect("bind_data null pointer"); - let global_state = unsafe { global_state.cast::().as_ref() } - .vortex_expect("global_init_data null pointer"); - T::table_scan_progress(ctx, bind_data, global_state) -} diff --git a/vortex-duckdb/src/e2e_test/object_cache_test.rs b/vortex-duckdb/src/e2e_test/object_cache_test.rs index b21c10b1d11..b5dacc18adc 100644 --- a/vortex-duckdb/src/e2e_test/object_cache_test.rs +++ b/vortex-duckdb/src/e2e_test/object_cache_test.rs @@ -11,6 +11,7 @@ use vortex::error::vortex_err; use crate::cpp::DUCKDB_TYPE; use crate::duckdb::BindInputRef; use crate::duckdb::BindResultRef; +use crate::duckdb::Cardinality; use crate::duckdb::ClientContextRef; use crate::duckdb::ColumnStatistics; use crate::duckdb::DataChunkRef; @@ -66,17 +67,11 @@ impl TableFunction for TestTableFunction { }) } - fn table_scan_progress( - _client_context: &ClientContextRef, - _bind_data: &Self::BindData, - _global_state: &Self::GlobalState, - ) -> f64 { + fn table_scan_progress(_global_state: &Self::GlobalState) -> f64 { 100.0 } fn scan( - _client_context: &ClientContextRef, - _bind_data: &Self::BindData, _local_state: &mut Self::LocalState, _global_state: &Self::GlobalState, chunk: &mut DataChunkRef, @@ -100,15 +95,11 @@ impl TableFunction for TestTableFunction { Ok(TestGlobalState) } - fn init_local( - _init: &TableInitInput, - _global: &Self::GlobalState, - ) -> VortexResult { - Ok(TestLocalState) + fn init_local(_global: &Self::GlobalState) -> Self::LocalState { + TestLocalState } fn partition_data( - _bind_data: &Self::BindData, _global_init_data: &Self::GlobalState, _local_init_data: &mut Self::LocalState, ) -> PartitionData { @@ -119,15 +110,22 @@ impl TableFunction for TestTableFunction { } } - fn statistics( - _client_context: &ClientContextRef, - _bind_data: &Self::BindData, - _column_index: usize, - ) -> Option { + fn statistics(_bind_data: &Self::BindData, _column_index: usize) -> Option { None } fn to_string(_bind_data: &Self::BindData, _map: &mut crate::duckdb::DuckdbStringMapRef) {} + + fn pushdown_complex_filter( + _bind_data: &mut Self::BindData, + _expr: &crate::duckdb::ExpressionRef, + ) -> VortexResult { + Ok(false) + } + + fn cardinality(_bind_data: &Self::BindData) -> Cardinality { + Cardinality::Unknown + } } use crate::duckdb::Database;