MCPcopy Create free account
hub / github.com/apache/arrow / ExecPlan_run_substrait

Function ExecPlan_run_substrait

r/src/compute-exec.cpp:545–578  ·  view source on GitHub ↗

[[substrait::export]]

Source from the content-addressed store, hash-verified

543
544// [[substrait::export]]
545std::shared_ptr<arrow::Table> ExecPlan_run_substrait(
546 const std::shared_ptr<acero::ExecPlan>& plan,
547 const std::shared_ptr<arrow::Buffer>& serialized_plan) {
548 std::vector<std::shared_ptr<AccumulatingConsumer>> consumers;
549
550 std::function<std::shared_ptr<acero::SinkNodeConsumer>()> consumer_factory = [&] {
551 consumers.emplace_back(new AccumulatingConsumer());
552 return consumers.back();
553 };
554
555 arrow::Result<std::vector<acero::Declaration>> maybe_decls =
556 ValueOrStop(arrow::engine::DeserializePlans(*serialized_plan, consumer_factory));
557 std::vector<acero::Declaration> decls = std::move(ValueOrStop(maybe_decls));
558
559 // For now, the Substrait plan must include a 'read' that points to
560 // a Parquet file (instead of using a source node create in Arrow)
561 for (const acero::Declaration& decl : decls) {
562 auto node = decl.AddToPlan(plan.get());
563 StopIfNotOk(node.status());
564 }
565
566 StopIfNotOk(plan->Validate());
567 plan->StartProducing();
568 StopIfNotOk(plan->finished().status());
569
570 std::vector<std::shared_ptr<arrow::RecordBatch>> all_batches;
571 for (const auto& consumer : consumers) {
572 for (const auto& batch : consumer->batches()) {
573 all_batches.push_back(batch);
574 }
575 }
576
577 return ValueOrStop(arrow::Table::FromRecordBatches(std::move(all_batches)));
578}
579
580#endif

Callers 1

Calls 12

ValueOrStopFunction · 0.85
DeserializePlansFunction · 0.85
StopIfNotOkFunction · 0.85
emplace_backMethod · 0.80
backMethod · 0.80
AddToPlanMethod · 0.80
finishedMethod · 0.80
push_backMethod · 0.80
getMethod · 0.45
statusMethod · 0.45
ValidateMethod · 0.45
StartProducingMethod · 0.45

Tested by

no test coverage detected