vibhatha commented on code in PR #14024: URL: https://github.com/apache/arrow/pull/14024#discussion_r961349012
########## cpp/src/arrow/engine/substrait/util.cc: ########## @@ -126,6 +131,36 @@ Result<std::shared_ptr<RecordBatchReader>> ExecuteSerializedPlan( return sink_reader; } +Result<std::shared_ptr<RecordBatchReader>> ExecuteSerializedPlan( + const Buffer& substrait_buffer, PythonTableProvider& table_provider, + const ExtensionIdRegistry* registry, compute::FunctionRegistry* func_registry) { + // TODO(ARROW-15732) + // retrieve input table from table provider + + NamedTableProvider named_table_provider = + [table_provider]( + const std::vector<std::string>& names) -> Result<compute::Declaration> { + ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Table> input_table, table_provider(names)); + std::shared_ptr<compute::ExecNodeOptions> options = + std::make_shared<compute::TableSourceNodeOptions>(input_table); + return compute::Declaration("table_source", {}, options, + "substrait_table_provider_source"); + }; + + ConversionOptions conversion_options; + conversion_options.named_table_provider = std::move(named_table_provider); + + compute::ExecContext exec_context(arrow::default_memory_pool(), + ::arrow::internal::GetCpuThreadPool(), func_registry); + ARROW_ASSIGN_OR_RAISE(auto plan, compute::ExecPlan::Make(&exec_context)); + SubstraitExecutor executor(std::move(plan), exec_context, conversion_options); + RETURN_NOT_OK(executor.Init(substrait_buffer, registry)); + ARROW_ASSIGN_OR_RAISE(auto sink_reader, executor.Execute()); + // check closing here, not in destructor, to expose error to caller + RETURN_NOT_OK(executor.Close()); + return sink_reader; Review Comment: Yes of course, this was merely a WIP proto code I just wrote for the sake of getting an insight from @richtia. I will update the code. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org