rtpsw commented on code in PR #13375:
URL: https://github.com/apache/arrow/pull/13375#discussion_r901100555
##########
cpp/src/arrow/engine/substrait/util.cc:
##########
@@ -108,25 +109,50 @@ class SubstraitExecutor {
} // namespace
Result<std::shared_ptr<RecordBatchReader>> ExecuteSerializedPlan(
- const Buffer& substrait_buffer) {
- ARROW_ASSIGN_OR_RAISE(auto plan, compute::ExecPlan::Make());
+ const Buffer& substrait_buffer, const ExtensionIdRegistry* extid_registry,
+ compute::FunctionRegistry* func_registry) {
// TODO(ARROW-15732)
compute::ExecContext exec_context(arrow::default_memory_pool(),
- ::arrow::internal::GetCpuThreadPool());
+ ::arrow::internal::GetCpuThreadPool(),
func_registry);
+ ARROW_ASSIGN_OR_RAISE(auto plan, compute::ExecPlan::Make(&exec_context));
SubstraitExecutor executor(std::move(plan), exec_context);
- RETURN_NOT_OK(executor.Init(substrait_buffer));
+ RETURN_NOT_OK(executor.Init(substrait_buffer, extid_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;
}
Result<std::shared_ptr<Buffer>> SerializeJsonPlan(const std::string&
substrait_json) {
return engine::internal::SubstraitFromJSON("Plan", substrait_json);
}
+Result<std::vector<compute::Declaration>> DeserializePlans(
+ const Buffer& buffer, const ExtensionIdRegistry* registry) {
+ return engine::DeserializePlans(
+ buffer, []() { return std::make_shared<compute::NullSinkNodeConsumer>();
},
+ registry);
+}
+
std::shared_ptr<ExtensionIdRegistry> MakeExtensionIdRegistry() {
return nested_extension_id_registry(default_extension_id_registry());
}
+Status RegisterFunction(ExtensionIdRegistry& registry, const std::string&
id_uri,
+ const std::string& id_name,
+ const std::string& arrow_function_name) {
+ const std::string& id_uri_sym = registry.AddExternalSymbol(id_uri);
+ const std::string& id_name_sym = registry.AddExternalSymbol(id_name);
+ const std::string& arrow_function_name_sym =
+ registry.AddExternalSymbol(arrow_function_name);
Review Comment:
I'll fix.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]