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

Function ExecPlan_run_substrait

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

[[substrait::export]]

Source from the content-addressed store, hash-verified

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