westonpace commented on code in PR #13117:
URL: https://github.com/apache/arrow/pull/13117#discussion_r872147159


##########
cpp/src/arrow/compute/exec/exec_plan.cc:
##########
@@ -506,22 +506,49 @@ Result<ExecNode*> Declaration::AddToPlan(ExecPlan* plan,
   return node;
 }
 
+Declaration* Declaration::Root() {
+  Declaration* current = this;
+  while (!current->inputs.empty()) {
+    DCHECK_LE(current->inputs.size(), 1)
+        << "No clear root when a declaration has multiple inputs";
+    auto& input = current->inputs[0];
+    Declaration* maybe_next = input.get<Declaration>();
+    DCHECK(maybe_next) << "Attempt to get root when part of declaration is 
already built";
+    current = maybe_next;
+  }
+  return current;
+}
+
 Declaration Declaration::Sequence(std::vector<Declaration> decls) {
   DCHECK(!decls.empty());
 
   Declaration out = std::move(decls.back());
   decls.pop_back();
-  auto receiver = &out;
+  auto receiver = out.Root();

Review Comment:
   Ah, fair enough.  I can switch to this model.  Thanks for the clarification.
   



-- 
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]

Reply via email to