vibhatha commented on code in PR #14292:
URL: https://github.com/apache/arrow/pull/14292#discussion_r1024944812


##########
cpp/src/arrow/engine/substrait/serde.cc:
##########
@@ -124,6 +107,24 @@ compute::Declaration 
ProjectByNamesDeclaration(compute::Declaration input,
         compute::ProjectNodeOptions{std::move(expressions), 
std::move(names)}}});
 }
 
+DeclarationFactory MakeConsumingSinkDeclarationFactory(
+    const ConsumerFactory& consumer_factory) {
+  return [&consumer_factory](
+             compute::Declaration input,
+             std::vector<std::string> names) -> Result<compute::Declaration> {
+    std::shared_ptr<compute::SinkNodeConsumer> consumer = consumer_factory();
+    if (consumer == nullptr) {
+      return Status::Invalid("consumer factory is exhausted");
+    }
+    std::shared_ptr<compute::ExecNodeOptions> options =
+        std::make_shared<compute::ConsumingSinkNodeOptions>(
+            compute::ConsumingSinkNodeOptions{std::move(consumer), 
std::move(names)});
+    compute::Declaration projected = ProjectByNamesDeclaration(input, names);
+    return compute::Declaration::Sequence(
+        {std::move(projected), {"consuming_sink", options}});
+  };

Review Comment:
   It was much neater after removing that `ProjectByNamesDeclaration`, but I am 
not sure why it was there in the first place, it is a bit confusing. The 
existing options in the `ConsumingSinkNode` already does the required job. I am 
also trying to remember the logic. Could you pick any wrong doing in my change? 
   
   I also cleaned up the `CheckRoundTripResult` function to use 
`DeclareToTable` and avoid the use of expected schema. I guess we may need to 
clean many other places which pass a schema. 



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