diff --git a/extension/delta/src/function/delta_scan.cpp b/extension/delta/src/function/delta_scan.cpp index c310f1f87eb..182ff73f6c2 100644 --- a/extension/delta/src/function/delta_scan.cpp +++ b/extension/delta/src/function/delta_scan.cpp @@ -73,9 +73,12 @@ std::unique_ptr initEmptyLocalState(TableFunctionInitInput& function_set DeltaScanFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back( - std::make_unique(name, tableFunc, bindFunc, initDeltaScanSharedState, - initEmptyLocalState, std::vector{LogicalTypeID::STRING})); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initDeltaScanSharedState; + function->initLocalStateFunc = initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/extension/duckdb/src/function/clear_cache.cpp b/extension/duckdb/src/function/clear_cache.cpp index d7d7b7b4389..6427f6a51b7 100644 --- a/extension/duckdb/src/function/clear_cache.cpp +++ b/extension/duckdb/src/function/clear_cache.cpp @@ -37,9 +37,12 @@ static std::unique_ptr clearCacheBindFunc(ClientContext* cont } ClearCacheFunction::ClearCacheFunction() - : TableFunction{name, clearCacheTableFunc, clearCacheBindFunc, - function::SimpleTableFunction::initSharedState, - function::SimpleTableFunction::initEmptyLocalState, std::vector{}} {} + : TableFunction{name, std::vector{}} { + tableFunc = clearCacheTableFunc; + bindFunc = clearCacheBindFunc; + initSharedStateFunc = SimpleTableFunction::initSharedState; + initLocalStateFunc = SimpleTableFunction::initEmptyLocalState; +} } // namespace duckdb_extension } // namespace kuzu diff --git a/extension/duckdb/src/function/duckdb_scan.cpp b/extension/duckdb/src/function/duckdb_scan.cpp index 56a699bd16a..1a58cec2b27 100644 --- a/extension/duckdb/src/function/duckdb_scan.cpp +++ b/extension/duckdb/src/function/duckdb_scan.cpp @@ -112,11 +112,13 @@ std::unique_ptr DuckDBScanFunction::bindFunc( } TableFunction getScanFunction(DuckDBScanBindData bindData) { - return TableFunction(DuckDBScanFunction::DUCKDB_SCAN_FUNC_NAME, DuckDBScanFunction::tableFunc, - std::bind(DuckDBScanFunction::bindFunc, std::move(bindData), std::placeholders::_1, - std::placeholders::_2), - DuckDBScanFunction::initSharedState, DuckDBScanFunction::initLocalState, - std::vector{}); + auto function = TableFunction(DuckDBScanFunction::DUCKDB_SCAN_FUNC_NAME, std::vector{}); + function.tableFunc = DuckDBScanFunction::tableFunc; + function.bindFunc = std::bind(DuckDBScanFunction::bindFunc, std::move(bindData), std::placeholders::_1, + std::placeholders::_2); + function.initSharedStateFunc = DuckDBScanFunction::initSharedState; + function.initLocalStateFunc = DuckDBScanFunction::initLocalState; + return function; } } // namespace duckdb_extension diff --git a/extension/fts/src/function/create_fts_index.cpp b/extension/fts/src/function/create_fts_index.cpp index e6dc75a9934..d4a7a2bbcb4 100644 --- a/extension/fts/src/function/create_fts_index.cpp +++ b/extension/fts/src/function/create_fts_index.cpp @@ -228,10 +228,13 @@ static common::offset_t tableFunc(TableFuncInput& input, TableFuncOutput& /*outp function_set CreateFTSFunction::getFunctionSet() { function_set functionSet; - auto func = std::make_unique(name, tableFunc, bindFunc, initSharedState, - initEmptyLocalState, + auto func = std::make_unique(name, std::vector{LogicalTypeID::STRING, LogicalTypeID::STRING, LogicalTypeID::LIST}); + func->tableFunc = tableFunc; + func->bindFunc = bindFunc; + func->initSharedStateFunc = initSharedState; + func->initLocalStateFunc = initEmptyLocalState; func->rewriteFunc = createFTSIndexQuery; func->canParallelFunc = []() { return false; }; functionSet.push_back(std::move(func)); diff --git a/extension/fts/src/function/drop_fts_index.cpp b/extension/fts/src/function/drop_fts_index.cpp index d0a0bfe1ced..a032cde3cac 100644 --- a/extension/fts/src/function/drop_fts_index.cpp +++ b/extension/fts/src/function/drop_fts_index.cpp @@ -49,9 +49,12 @@ static common::offset_t tableFunc(TableFuncInput& input, TableFuncOutput& /*outp function_set DropFTSFunction::getFunctionSet() { function_set functionSet; - auto func = std::make_unique(name, tableFunc, bindFunc, initSharedState, - initEmptyLocalState, + auto func = std::make_unique(name, std::vector{LogicalTypeID::STRING, LogicalTypeID::STRING}); + func->tableFunc = tableFunc; + func->bindFunc = bindFunc; + func->initSharedStateFunc = initSharedState; + func->initLocalStateFunc = initEmptyLocalState; func->rewriteFunc = dropFTSIndexQuery; func->canParallelFunc = []() { return false; }; functionSet.push_back(std::move(func)); diff --git a/extension/iceberg/src/function/iceberg_metadata.cpp b/extension/iceberg/src/function/iceberg_metadata.cpp index 4aedb50b456..c818a18c6a9 100644 --- a/extension/iceberg/src/function/iceberg_metadata.cpp +++ b/extension/iceberg/src/function/iceberg_metadata.cpp @@ -13,9 +13,12 @@ std::unique_ptr metadataBindFunc(main::ClientContext* context function_set IcebergMetadataFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, delta_extension::tableFunc, - metadataBindFunc, delta_extension::initDeltaScanSharedState, - delta_extension::initEmptyLocalState, std::vector{LogicalTypeID::STRING})); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = delta_extension::tableFunc; + function->bindFunc = metadataBindFunc; + function->initSharedStateFunc = delta_extension::initDeltaScanSharedState; + function->initLocalStateFunc = delta_extension::initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/extension/iceberg/src/function/iceberg_scan.cpp b/extension/iceberg/src/function/iceberg_scan.cpp index d0e020c7e04..72a916a9879 100644 --- a/extension/iceberg/src/function/iceberg_scan.cpp +++ b/extension/iceberg/src/function/iceberg_scan.cpp @@ -13,9 +13,12 @@ std::unique_ptr scanBindFunc(main::ClientContext* context, function_set IcebergScanFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, delta_extension::tableFunc, - scanBindFunc, delta_extension::initDeltaScanSharedState, - delta_extension::initEmptyLocalState, std::vector{LogicalTypeID::STRING})); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = delta_extension::tableFunc; + function->bindFunc = scanBindFunc; + function->initSharedStateFunc = delta_extension::initDeltaScanSharedState; + function->initLocalStateFunc = delta_extension::initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/extension/iceberg/src/function/iceberg_snapshots.cpp b/extension/iceberg/src/function/iceberg_snapshots.cpp index 7c4e3192f18..fb92810f0a9 100644 --- a/extension/iceberg/src/function/iceberg_snapshots.cpp +++ b/extension/iceberg/src/function/iceberg_snapshots.cpp @@ -13,9 +13,12 @@ static std::unique_ptr snapshotBindFunc(main::ClientContext* function_set IcebergSnapshotsFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, delta_extension::tableFunc, - snapshotBindFunc, delta_extension::initDeltaScanSharedState, - delta_extension::initEmptyLocalState, std::vector{LogicalTypeID::STRING})); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = delta_extension::tableFunc; + function->bindFunc = snapshotBindFunc; + function->initSharedStateFunc = delta_extension::initDeltaScanSharedState; + function->initLocalStateFunc = delta_extension::initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/extension/json/src/functions/table_functions/json_scan.cpp b/extension/json/src/functions/table_functions/json_scan.cpp index a9cac717868..4f90cc3ce8f 100644 --- a/extension/json/src/functions/table_functions/json_scan.cpp +++ b/extension/json/src/functions/table_functions/json_scan.cpp @@ -899,8 +899,13 @@ static void finalizeFunc(processor::ExecutionContext* ctx, TableFuncSharedState* std::unique_ptr JsonScan::getFunction() { auto func = - std::make_unique(name, tableFunc, bindFunc, initSharedState, initLocalState, - progressFunc, std::vector{LogicalTypeID::STRING}, finalizeFunc); + std::make_unique(name, std::vector{LogicalTypeID::STRING}); + func->tableFunc = tableFunc; + func->bindFunc = bindFunc; + func->initSharedStateFunc = initSharedState; + func->initLocalStateFunc = initLocalState; + func->progressFunc = progressFunc; + func->finalizeFunc = finalizeFunc; return func; } diff --git a/src/function/table/call/bm_info.cpp b/src/function/table/call/bm_info.cpp index bc5219b08c9..ccb743ec2ac 100644 --- a/src/function/table/call/bm_info.cpp +++ b/src/function/table/call/bm_info.cpp @@ -46,8 +46,12 @@ static std::unique_ptr bindFunc(main::ClientContext* context, function_set BMInfoFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initEmptyLocalState, std::vector{})); + auto function = std::make_unique(name, std::vector{}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/function/table/call/clear_warnings.cpp b/src/function/table/call/clear_warnings.cpp index 791a9b0740f..57b1689b5bd 100644 --- a/src/function/table/call/clear_warnings.cpp +++ b/src/function/table/call/clear_warnings.cpp @@ -19,8 +19,11 @@ static std::unique_ptr bindFunc(main::ClientContext* /*contex function_set ClearWarningsFunction::getFunctionSet() { function_set functionSet; - auto func = std::make_unique(name, tableFunc, bindFunc, initSharedState, - initEmptyLocalState, std::vector{}); + auto func = std::make_unique(name, std::vector{}); + func->tableFunc = tableFunc; + func->bindFunc = bindFunc; + func->initSharedStateFunc = initSharedState; + func->initLocalStateFunc = initEmptyLocalState; func->canParallelFunc = []() { return false; }; functionSet.push_back(std::move(func)); return functionSet; diff --git a/src/function/table/call/current_setting.cpp b/src/function/table/call/current_setting.cpp index 32293826343..738b95642c2 100644 --- a/src/function/table/call/current_setting.cpp +++ b/src/function/table/call/current_setting.cpp @@ -47,8 +47,12 @@ static std::unique_ptr bindFunc(ClientContext* context, function_set CurrentSettingFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initEmptyLocalState, std::vector{LogicalTypeID::STRING})); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/function/table/call/db_version.cpp b/src/function/table/call/db_version.cpp index df1b38cd668..4b1da2757a3 100644 --- a/src/function/table/call/db_version.cpp +++ b/src/function/table/call/db_version.cpp @@ -30,8 +30,12 @@ static std::unique_ptr bindFunc(ClientContext*, TableFuncBind function_set DBVersionFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initEmptyLocalState, std::vector{})); + auto function = std::make_unique(name, std::vector{}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/function/table/call/show_attached_databases.cpp b/src/function/table/call/show_attached_databases.cpp index 2c85c306b12..73a95e3eca6 100644 --- a/src/function/table/call/show_attached_databases.cpp +++ b/src/function/table/call/show_attached_databases.cpp @@ -56,8 +56,12 @@ static std::unique_ptr bindFunc(main::ClientContext* context, function_set ShowAttachedDatabasesFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initEmptyLocalState, std::vector{})); + auto function = std::make_unique(name, std::vector{}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/function/table/call/show_connection.cpp b/src/function/table/call/show_connection.cpp index 422c71aa1ec..c23b928272d 100644 --- a/src/function/table/call/show_connection.cpp +++ b/src/function/table/call/show_connection.cpp @@ -113,8 +113,12 @@ static std::unique_ptr bindFunc(ClientContext* context, function_set ShowConnectionFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initEmptyLocalState, std::vector{LogicalTypeID::STRING})); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/function/table/call/show_functions.cpp b/src/function/table/call/show_functions.cpp index d3a79fb6f11..5216819d805 100644 --- a/src/function/table/call/show_functions.cpp +++ b/src/function/table/call/show_functions.cpp @@ -73,8 +73,12 @@ static std::unique_ptr bindFunc(main::ClientContext* context, function_set ShowFunctionsFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initEmptyLocalState, std::vector{})); + auto function = std::make_unique(name, std::vector{}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/function/table/call/show_sequences.cpp b/src/function/table/call/show_sequences.cpp index 4a5b562d85f..9a9f645fbbe 100644 --- a/src/function/table/call/show_sequences.cpp +++ b/src/function/table/call/show_sequences.cpp @@ -108,8 +108,12 @@ static std::unique_ptr bindFunc(main::ClientContext* context, function_set ShowSequencesFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initEmptyLocalState, std::vector{})); + auto function = std::make_unique(name, std::vector{}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/function/table/call/show_tables.cpp b/src/function/table/call/show_tables.cpp index ec359e4acfa..2951b513f41 100644 --- a/src/function/table/call/show_tables.cpp +++ b/src/function/table/call/show_tables.cpp @@ -97,8 +97,12 @@ static std::unique_ptr bindFunc(main::ClientContext* context, function_set ShowTablesFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initEmptyLocalState, std::vector{})); + auto function = std::make_unique(name, std::vector{}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/function/table/call/show_warnings.cpp b/src/function/table/call/show_warnings.cpp index 29bb4ced52e..f58e15a5892 100644 --- a/src/function/table/call/show_warnings.cpp +++ b/src/function/table/call/show_warnings.cpp @@ -56,8 +56,12 @@ static std::unique_ptr bindFunc(main::ClientContext* context, function_set ShowWarningsFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initEmptyLocalState, std::vector{})); + auto function = std::make_unique(name, std::vector{}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/function/table/call/stats_info.cpp b/src/function/table/call/stats_info.cpp index d7b493067cb..6c6d7b94b77 100644 --- a/src/function/table/call/stats_info.cpp +++ b/src/function/table/call/stats_info.cpp @@ -87,8 +87,12 @@ static std::unique_ptr bindFunc(ClientContext* context, function_set StatsInfoFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initLocalState, std::vector{LogicalTypeID::STRING})); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/function/table/call/storage_info.cpp b/src/function/table/call/storage_info.cpp index d9c14396157..fd2dcd7d9a4 100644 --- a/src/function/table/call/storage_info.cpp +++ b/src/function/table/call/storage_info.cpp @@ -359,8 +359,12 @@ static std::unique_ptr bindFunc(ClientContext* context, function_set StorageInfoFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initLocalState, std::vector{LogicalTypeID::STRING})); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/function/table/call/table_info.cpp b/src/function/table/call/table_info.cpp index 913226d8b60..895165405ff 100644 --- a/src/function/table/call/table_info.cpp +++ b/src/function/table/call/table_info.cpp @@ -107,8 +107,12 @@ static std::unique_ptr bindFunc(main::ClientContext* context, function_set TableInfoFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, bindFunc, - initSharedState, initEmptyLocalState, std::vector{LogicalTypeID::STRING})); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initEmptyLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/include/function/table_functions.h b/src/include/function/table_functions.h index 925f3c60726..1a6edc02168 100644 --- a/src/include/function/table_functions.h +++ b/src/include/function/table_functions.h @@ -1,7 +1,5 @@ #pragma once -#include - #include "common/data_chunk/data_chunk.h" #include "function.h" @@ -96,36 +94,12 @@ struct KUZU_API TableFunction : public Function { table_func_can_parallel_t canParallelFunc = [] { return true; }; table_func_progress_t progressFunc = [](TableFuncSharedState*) { return 0.0; }; table_func_finalize_t finalizeFunc = [](auto, auto) {}; - table_func_rewrite_t rewriteFunc; + table_func_rewrite_t rewriteFunc = nullptr; - TableFunction() - : Function{}, tableFunc{nullptr}, bindFunc{nullptr}, initSharedStateFunc{nullptr}, - initLocalStateFunc{nullptr} {}; + TableFunction() : Function{} {}; TableFunction(std::string name, std::vector inputTypes) : Function{name, inputTypes} {} - TableFunction(std::string name, table_func_t tableFunc, table_func_bind_t bindFunc, - table_func_init_shared_t initSharedFunc, table_func_init_local_t initLocalFunc, - std::vector inputTypes, - std::optional finalizeFunc = {}) - : Function{std::move(name), std::move(inputTypes)}, tableFunc{tableFunc}, - bindFunc{bindFunc}, initSharedStateFunc{initSharedFunc}, - initLocalStateFunc{initLocalFunc} { - if (finalizeFunc.has_value()) { - this->finalizeFunc = finalizeFunc.value(); - } - } - TableFunction(std::string name, table_func_t tableFunc, table_func_bind_t bindFunc, - table_func_init_shared_t initSharedFunc, table_func_init_local_t initLocalFunc, - table_func_progress_t progressFunc, std::vector inputTypes, - std::optional finalizeFunc = {}) - : Function{std::move(name), std::move(inputTypes)}, tableFunc{tableFunc}, - bindFunc{bindFunc}, initSharedStateFunc{initSharedFunc}, - initLocalStateFunc{initLocalFunc}, progressFunc(progressFunc) { - if (finalizeFunc.has_value()) { - this->finalizeFunc = finalizeFunc.value(); - } - } - + std::string signatureToString() const override { return common::LogicalTypeUtils::toString(parameterTypeIDs); } diff --git a/src/include/main/client_context.h b/src/include/main/client_context.h index 6f6d6c4a3cc..bef201eb70f 100644 --- a/src/include/main/client_context.h +++ b/src/include/main/client_context.h @@ -3,6 +3,7 @@ #include #include #include +#include #include "common/timer.h" #include "common/types/value/value.h" diff --git a/src/processor/operator/persistent/reader/csv/parallel_csv_reader.cpp b/src/processor/operator/persistent/reader/csv/parallel_csv_reader.cpp index c79a022ef94..d5fa97474d7 100644 --- a/src/processor/operator/persistent/reader/csv/parallel_csv_reader.cpp +++ b/src/processor/operator/persistent/reader/csv/parallel_csv_reader.cpp @@ -317,9 +317,14 @@ static void finalizeFunc(ExecutionContext* ctx, TableFuncSharedState* sharedStat function_set ParallelCSVScan::getFunctionSet() { function_set functionSet; - functionSet.push_back( - std::make_unique(name, tableFunc, bindFunc, initSharedState, initLocalState, - progressFunc, std::vector{LogicalTypeID::STRING}, finalizeFunc)); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initLocalState; + function->progressFunc = progressFunc; + function->finalizeFunc = finalizeFunc; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/processor/operator/persistent/reader/csv/serial_csv_reader.cpp b/src/processor/operator/persistent/reader/csv/serial_csv_reader.cpp index 3bef44e1a85..3e16a2433c8 100644 --- a/src/processor/operator/persistent/reader/csv/serial_csv_reader.cpp +++ b/src/processor/operator/persistent/reader/csv/serial_csv_reader.cpp @@ -271,9 +271,14 @@ static double progressFunc(TableFuncSharedState* sharedState) { function_set SerialCSVScan::getFunctionSet() { function_set functionSet; - functionSet.push_back( - std::make_unique(name, tableFunc, bindFunc, initSharedState, initLocalState, - progressFunc, std::vector{LogicalTypeID::STRING}, finalizeFunc)); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initLocalState; + function->progressFunc = progressFunc; + function->finalizeFunc = finalizeFunc; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/processor/operator/persistent/reader/npy/npy_reader.cpp b/src/processor/operator/persistent/reader/npy/npy_reader.cpp index e88a391ec1d..a320b6dc9d1 100644 --- a/src/processor/operator/persistent/reader/npy/npy_reader.cpp +++ b/src/processor/operator/persistent/reader/npy/npy_reader.cpp @@ -345,9 +345,14 @@ static std::unique_ptr initLocalState( function_set NpyScanFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back( - std::make_unique(name, tableFunc, bindFunc, initSharedState, initLocalState, - std::vector{LogicalTypeID::STRING}, finalizeFunc)); + auto function = std::make_unique(name, + std::vector{LogicalTypeID::STRING}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initLocalState; + function->finalizeFunc = finalizeFunc; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/processor/operator/persistent/reader/parquet/parquet_reader.cpp b/src/processor/operator/persistent/reader/parquet/parquet_reader.cpp index 121489d8e3e..e5054b35a8b 100644 --- a/src/processor/operator/persistent/reader/parquet/parquet_reader.cpp +++ b/src/processor/operator/persistent/reader/parquet/parquet_reader.cpp @@ -731,9 +731,14 @@ static void finalizeFunc(ExecutionContext* ctx, TableFuncSharedState*) { function_set ParquetScanFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back( - std::make_unique(name, tableFunc, bindFunc, initSharedState, initLocalState, - progressFunc, std::vector{LogicalTypeID::STRING}, finalizeFunc)); + auto function = std::make_unique(name, std::vector{LogicalTypeID::STRING}); + function->tableFunc = tableFunc; + function->bindFunc = bindFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initLocalState; + function->progressFunc = progressFunc; + function->finalizeFunc = finalizeFunc; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/src/processor/operator/table_scan/ftable_scan_function.cpp b/src/processor/operator/table_scan/ftable_scan_function.cpp index c16e792ef96..49da088dcce 100644 --- a/src/processor/operator/table_scan/ftable_scan_function.cpp +++ b/src/processor/operator/table_scan/ftable_scan_function.cpp @@ -64,8 +64,11 @@ static std::unique_ptr initLocalState(TableFunctionInitInpu function_set FTableScan::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(name, tableFunc, nullptr /*bindFunc*/, - initSharedState, initLocalState, std::vector{})); + auto function = std::make_unique(name, std::vector{}); + function->tableFunc = tableFunc; + function->initSharedStateFunc = initSharedState; + function->initLocalStateFunc = initLocalState; + functionSet.push_back(std::move(function)); return functionSet; } diff --git a/tools/python_api/src_cpp/include/pandas/pandas_scan.h b/tools/python_api/src_cpp/include/pandas/pandas_scan.h index baadc687d42..1116597a322 100644 --- a/tools/python_api/src_cpp/include/pandas/pandas_scan.h +++ b/tools/python_api/src_cpp/include/pandas/pandas_scan.h @@ -27,6 +27,7 @@ struct PandasScanFunction { static constexpr const char* name = "READ_PANDAS"; static function::function_set getFunctionSet(); + static function::TableFunction getFunction(); }; struct PandasScanFunctionData : public function::TableFuncBindData { @@ -45,6 +46,10 @@ struct PandasScanFunctionData : public function::TableFuncBindData { std::vector> copyColumnBindData() const; + std::unique_ptr copy() const override { + return std::unique_ptr(new PandasScanFunctionData(*this)); + } + private: PandasScanFunctionData(const PandasScanFunctionData& other) : TableFuncBindData{other}, df{other.df} { @@ -52,11 +57,6 @@ struct PandasScanFunctionData : public function::TableFuncBindData { columnBindData.push_back(i->copy()); } } - -public: - std::unique_ptr copy() const override { - return std::unique_ptr(new PandasScanFunctionData(*this)); - } }; std::unique_ptr tryReplacePD(py::dict& dict, py::str& objectName); diff --git a/tools/python_api/src_cpp/pandas/pandas_scan.cpp b/tools/python_api/src_cpp/pandas/pandas_scan.cpp index 1345f8e03b2..9767be81485 100644 --- a/tools/python_api/src_cpp/pandas/pandas_scan.cpp +++ b/tools/python_api/src_cpp/pandas/pandas_scan.cpp @@ -123,12 +123,21 @@ static double progressFunc(TableFuncSharedState* sharedState) { function_set PandasScanFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back(std::make_unique(PandasScanFunction::name, tableFunc, - bindFunc, initSharedState, initLocalState, progressFunc, - std::vector{LogicalTypeID::POINTER})); + functionSet.push_back(getFunction().copy()); return functionSet; } +function::TableFunction PandasScanFunction::getFunction() { + auto function = TableFunction(name, + std::vector{LogicalTypeID::POINTER}); + function.tableFunc = tableFunc; + function.bindFunc = bindFunc; + function.initSharedStateFunc = initSharedState; + function.initLocalStateFunc = initLocalState; + function.progressFunc = progressFunc; + return function; +} + static bool isPyArrowBacked(const py::handle& df) { py::list dtypes = df.attr("dtypes"); if (dtypes.empty()) { @@ -154,9 +163,7 @@ std::unique_ptr tryReplacePD(py::dict& dict, py::str& objec if (isPyArrowBacked(entry)) { scanReplacementData->func = PyArrowTableScanFunction::getFunction(); } else { - scanReplacementData->func = TableFunction(PandasScanFunction::name, tableFunc, bindFunc, - initSharedState, initLocalState, progressFunc, - std::vector{LogicalTypeID::POINTER}); + scanReplacementData->func = PandasScanFunction::getFunction(); } auto bindInput = TableFuncBindInput(); bindInput.addLiteralParam(Value::createValue(reinterpret_cast(entry.ptr()))); diff --git a/tools/python_api/src_cpp/pyarrow/pyarrow_scan.cpp b/tools/python_api/src_cpp/pyarrow/pyarrow_scan.cpp index 69f46690366..6cd20959b22 100644 --- a/tools/python_api/src_cpp/pyarrow/pyarrow_scan.cpp +++ b/tools/python_api/src_cpp/pyarrow/pyarrow_scan.cpp @@ -144,15 +144,18 @@ static double progressFunc(function::TableFuncSharedState* sharedState) { function::function_set PyArrowTableScanFunction::getFunctionSet() { function_set functionSet; - functionSet.push_back( - std::make_unique(name, tableFunc, bindFunc, initSharedState, initLocalState, - progressFunc, std::vector{LogicalTypeID::POINTER})); + functionSet.push_back(getFunction().copy()); return functionSet; } TableFunction PyArrowTableScanFunction::getFunction() { - return TableFunction(name, tableFunc, bindFunc, initSharedState, initLocalState, progressFunc, - std::vector{LogicalTypeID::POINTER}); + auto function = TableFunction(name, std::vector{LogicalTypeID::POINTER}); + function.tableFunc = tableFunc; + function.bindFunc = bindFunc; + function.initSharedStateFunc = initSharedState; + function.initLocalStateFunc = initLocalState; + function.progressFunc = progressFunc; + return function; } } // namespace kuzu