You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "rtpsw (via GitHub)" <gi...@apache.org> on 2023/01/28 13:10:43 UTC

[GitHub] [arrow] rtpsw opened a new pull request, #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

rtpsw opened a new pull request, #33909:
URL: https://github.com/apache/arrow/pull/33909

   See #33899. This PR adds `NamedTapRel` and a simple test case with a no-op tap (i.e., just passing-through).


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1423721107

   The [recent commit](https://github.com/apache/arrow/pull/33909/commits/0b1147bcd64dfebd266a098d9e6c72588e112afd) has `NamedTapKindMapper` returning a `Declaration`. @westonpace, let me know if anything is missing.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1101863001


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -93,6 +114,10 @@ struct ARROW_ENGINE_EXPORT ConversionOptions {
   /// The default behavior will return an invalid status if the plan has any
   /// named table relations.
   NamedTableProvider named_table_provider = kDefaultNamedTableProvider;
+  /// \brief A custom strategy to be used for mapping a tap kind to a function name
+  ///
+  /// The default mapper returns a declaration whose factory name is equal to the tap kind
+  NamedTapKindMapper named_tap_mapper = kDefaultNamedTapKindMapper;

Review Comment:
   How do you feel about renaming this to `NamedTapProvider` for consistency?



##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -76,13 +88,22 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
  public:
   static std::shared_ptr<ExtensionProvider> kDefaultExtensionProvider;
   virtual ~ExtensionProvider() = default;
-  virtual Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  virtual Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                                       const std::vector<DeclarationInfo>& inputs,
                                        const ExtensionDetails& ext_details,
                                        const ExtensionSet& ext_set) = 0;
 };
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {

Review Comment:
   We can pass the schema and name directly instead of using this class.  If we still want to wrap the two of them in some kind of object (to reduce the # of args passed into the mapper?) then we should include `kind`, do not extend `ExecNodeOptions`, and call it something like NamedTap or NamedTapOptions.
   
   In other words, we shouldn't try to form the node options from the protobuf.  That will be the mapper's job.  We just need to pass whatever was in the protobuf along to the mapper and let the mapper figure out what node options are appropriate.



##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -67,6 +69,16 @@ using NamedTableProvider =
     std::function<Result<compute::Declaration>(const std::vector<std::string>&)>;
 static NamedTableProvider kDefaultNamedTableProvider;
 
+using NamedTapKindMapper = std::function<Result<compute::Declaration>(
+    const std::string&, std::vector<compute::Declaration::Input>,
+    std::shared_ptr<compute::ExecNodeOptions>)>;

Review Comment:
   This looks great.  I think we can do one more small tweak.
   ```suggestion
   using NamedTapKindMapper = std::function<Result<compute::Declaration>(
       const std::string&, std::vector<compute::Declaration::Input>,
       std::shared_ptr<Schema>, std::string name)>;
   ```



##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -67,6 +69,16 @@ using NamedTableProvider =
     std::function<Result<compute::Declaration>(const std::vector<std::string>&)>;
 static NamedTableProvider kDefaultNamedTableProvider;
 
+using NamedTapKindMapper = std::function<Result<compute::Declaration>(
+    const std::string&, std::vector<compute::Declaration::Input>,
+    std::shared_ptr<compute::ExecNodeOptions>)>;
+static NamedTapKindMapper kDefaultNamedTapKindMapper =

Review Comment:
   Do you think we will want to make the default named tap mapper (or the default named table provider for that matter) configurable?



##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -67,6 +69,16 @@ using NamedTableProvider =
     std::function<Result<compute::Declaration>(const std::vector<std::string>&)>;
 static NamedTableProvider kDefaultNamedTableProvider;
 
+using NamedTapKindMapper = std::function<Result<compute::Declaration>(
+    const std::string&, std::vector<compute::Declaration::Input>,
+    std::shared_ptr<compute::ExecNodeOptions>)>;
+static NamedTapKindMapper kDefaultNamedTapKindMapper =
+    [](const std::string& kind, std::vector<compute::Declaration::Input> inputs,
+       std::shared_ptr<compute::ExecNodeOptions> options)
+    -> Result<compute::Declaration> {
+  return compute::Declaration(kind, inputs, options);

Review Comment:
   If we remove `NamedTapNodeOptions` like some of my other comments suggest then I suppose there is no more meaningful default mapper.  That being said, I don't know of any use case where this default would be correct.  Perhaps we just return an error here like we do with named tables?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095008878


##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -28,36 +28,58 @@
 namespace arrow {
 namespace engine {
 
+namespace {
+
+std::vector<compute::Declaration::Input> MakeDeclarationInputs(
+    const std::vector<DeclarationInfo>& inputs) {
+  std::vector<compute::Declaration::Input> input_decls(inputs.size());
+  for (size_t i = 0; i < inputs.size(); i++) {
+    input_decls[i] = inputs[i].declaration;
+  }
+  return input_decls;
+}
+
+}  // namespace
+
 class BaseExtensionProvider : public ExtensionProvider {
  public:
-  Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,

Review Comment:
   Why do we need to add the ConversionOptions here?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1413927748

   > I'm not opposed to this but I don't think it is really necessary.
   
   The purpose I had in mind for this is test isolation. I agree it's not strictly necessary.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095092205


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   There's also the option of having both - a user would use the specific structures when they fit and the more general one when they don't. If we go with this approach, this PR will be for a specific structure. I'd also like to hear @westonpace's opinion.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1412924919

   > Note that the factory registry does not support scoping, which could be useful for cleaning up after and isolating testing (here, due to AddPassFactory) and in other use cases, like with other scoped registries. @westonpace, do you agree? open an issue?
   
   I'm not opposed to this but I don't think it is really necessary.  The tests all rely on the fact that the initialization methods are setup as "call-once" so calling them repeatedly won't be a problem.
   
   When dealing with the function registry it seemed important to support nested registries because you might have query-specific functions (e.g. if a UDF is embedded this could be one way to handle it).  However, the odds of having query-specific nodes seems pretty slim to me.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1411491232

   Note that the factory registry does not support scoping, which could be useful for cleaning up after and isolating testing (here, due to `AddPassFactory`) and in other use cases, like with other scoped registries. @westonpace, do you agree? open an issue?


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095251880


##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -28,36 +28,58 @@
 namespace arrow {
 namespace engine {
 
+namespace {
+
+std::vector<compute::Declaration::Input> MakeDeclarationInputss(
+    const std::vector<DeclarationInfo>& inputs) {
+  std::vector<compute::Declaration::Input> input_decls(inputs.size());
+  for (size_t i = 0; i < inputs.size(); i++) {
+    input_decls[i] = inputs[i].declaration;
+  }
+  return input_decls;
+}
+
+}  // namespace
+
 class BaseExtensionProvider : public ExtensionProvider {
  public:
-  Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                               const std::vector<DeclarationInfo>& inputs,
                                const ExtensionDetails& ext_details,
                                const ExtensionSet& ext_set) override {
     auto details = dynamic_cast<const DefaultExtensionDetails&>(ext_details);
-    return MakeRel(inputs, details.rel, ext_set);
+    return MakeRel(conv_opts, inputs, details.rel, ext_set);
   }
 
-  virtual Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  virtual Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                                       const std::vector<DeclarationInfo>& inputs,
                                        const google::protobuf::Any& rel,
                                        const ExtensionSet& ext_set) = 0;
 };
 
 class DefaultExtensionProvider : public BaseExtensionProvider {
  public:
-  Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                               const std::vector<DeclarationInfo>& inputs,
                                const google::protobuf::Any& rel,
                                const ExtensionSet& ext_set) override {
     if (rel.Is<substrait_ext::AsOfJoinRel>()) {
       substrait_ext::AsOfJoinRel as_of_join_rel;
       rel.UnpackTo(&as_of_join_rel);
-      return MakeAsOfJoinRel(inputs, as_of_join_rel, ext_set);
+      return MakeAsOfJoinRel(conv_opts, inputs, as_of_join_rel, ext_set);
+    }
+    if (rel.Is<substrait_ext::NamedTapRel>()) {
+      substrait_ext::NamedTapRel named_tap_rel;
+      rel.UnpackTo(&named_tap_rel);
+      return MakeNamedTapRel(conv_opts, inputs, named_tap_rel, ext_set);
     }
     return Status::NotImplemented("Unrecognized extension in Susbstrait plan: ",
                                   rel.DebugString());
   }
 
  private:
-  Result<RelationInfo> MakeAsOfJoinRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeAsOfJoinRel(const ConversionOptions& conv_opts,

Review Comment:
   But `MakeAsOfJoinRel` does not call `MakeNamedTapRel`.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1413945487

   > Looking at this further I do worry that `kind` will be too restrictive. For example, if you are writing to a temporary output directory and the `name` specifies the path then how do you configure the directory to write to?
   
   Something like `kind = "write_to_temp"` and `name = "/path/to/tmp.XXXXXX"`. The `XXXXXX` part has the same meaning [as in `mktemp(1)`](https://linux.die.net/man/1/mktemp).
   
   > Perhaps that might be what you intended with the nesting of node factories? E.g. you would register a node factory that had the output directory hard-coded as a part of the node factory?
   
   One could register some node factory to implement a very specific custom behavior, and it's good that this option is available to users, but the above example is simple enough that it won't be needed for it. If we settle on this `kind`+`name` structure, we'd want to encourage its application, i.e., the recommendation would be to use `kind` to specify the functionality and `name` to specify its configuration whenever possible.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1422743894

   If we changed `NamedTapKindMapper` to return a Declaration I would be happy to proceed with something like this.
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095043128


##########
cpp/proto/substrait/extension_rels.proto:
##########
@@ -44,3 +44,17 @@ message AsOfJoinRel {
     repeated .substrait.Expression by = 2;
   }
 }
+
+// Named tap relation
+//
+// A tap is a relation having a single input relation that it passes through, while also
+// causing some side-effect, e.g., writing to external storage.
+message NamedTapRel {
+  // The kind of tap
+  string kind = 1;
+  // A name used to configure the tap, e.g., a URI defining the destination of writing
+  string name = 2;
+  // Column names for the tap's output. If specified there must be one name per field.
+  // If empty, field names will be automatically generated.

Review Comment:
   Because the tap might not care about column names. Though I'm rather indifferent to whether column names are required.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095054111


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   IMO I don't think this is over generalized - it matches the level of generalization in substrait extension protobuf - Leaf, single rel and multiple rel. As something experimental at this stage I think we do benefit from generalization since we make very minimal changes to Acero code itself and more free to experiment / iterator faster on our side.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095139749


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   IFWIW,  agree a specific structure can be useful however in this case I don't feel it is much more useful than a general one in this case. For example, the specific structure for the NamedTapNode make function returns a NamedTapNode option, and doesn't not allow the user to return a declaration with a custom node option (e.g, in our case, a WriteSmoothNodeOption), so we need to handle that in our code after calling this NamedTapNode make function here (or totally by pass NamedTapNode function here). This an be done but I feel that is unnecessary indirection.



##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   I agree a specific structure can be useful however in this case I don't feel it is much more useful than a general one in this case. For example, the specific structure for the NamedTapNode make function returns a NamedTapNode option, and doesn't not allow the user to return a declaration with a custom node option (e.g, in our case, a WriteSmoothNodeOption), so we need to handle that in our code after calling this NamedTapNode make function here (or totally by pass NamedTapNode function here). This an be done but I feel that is unnecessary indirection.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095008046


##########
cpp/proto/substrait/extension_rels.proto:
##########
@@ -44,3 +44,17 @@ message AsOfJoinRel {
     repeated .substrait.Expression by = 2;
   }
 }
+
+// Named tap relation
+//
+// A tap is a relation having a single input relation that it passes through, while also
+// causing some side-effect, e.g., writing to external storage.
+message NamedTapRel {
+  // The kind of tap
+  string kind = 1;
+  // A name used to configure the tap, e.g., a URI defining the destination of writing
+  string name = 2;
+  // Column names for the tap's output. If specified there must be one name per field.
+  // If empty, field names will be automatically generated.

Review Comment:
   Why don't we make the columns required - i.e., if it's missing or doesn't match the number of fields in the data then it's an illegal message? 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1096045166


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   I agree with @rtpsw that going too generic (protobuf.Any in and Declaration out) is not a good idea.  This is the exact API for the `ExtensionProvider` and so we already have this.  You could use this for `WriteSmoothNodeOption` and it would end up looking just like the extension that is in place for AsofJoinNode.  If that works for you then there is nothing we need to do :)
   
   So if we want to go less generic then we should look at what Acero provides at each step to simplify things:
   
   ### Generic Node
   
   The next step down in generality would be to remove protobuf from the picture using Substrait/Arrow literals:
   
   ```
   message GenericOptions {
     message Property {
       string key = 0;
       Literal value = 1;
     }
     repeated Property properties = 1;
   }
   
   message GenericNode {
     string kind = 0;
     GenericOptions options = 1;
   }
   ```
   
   The API in Arrow would be:
   
   ```
   void RegisterGenericExtensionHandler(string kind, function<Declaration(unordered_map<string, Scalar>)> handler)
   ```
   
   In other words, given properties as a map of arrow scalars, create a declaration
   
   **Pros:**
     * No need for extension author to write proto file
     * Can be used for any extension type
   **Cons:**
     * Need to create an entire ExecNode for your custom behavior
   
   ### Generic Mapper
   
   An even more focused approach could be to remove the need to create an exec node at all.  This would be focused on the 1 input in / 1 input out / no accumulation case (e.g. what MapNode handles).  From what I know of your write need this would fit this case.
   
   The Substrait would be pretty much identical to the above.
   
   ```
   message MapNode {
     string kind = 0;
     GenericOptions options = 1;
   }
   ```
   
   However, the Arrow API would be:
   
   ```
   using Mapper = function<ExecBatch(ExecBatch)>;
   void RegisterGenericMapHandler(string kind, function<Mapper(unordered_map<string, Scalar>)> handler)
   ```
   
   **Pros:**
    * No need to write proto file
    * No need to create an exec node
   **Cons:**
    * Only handles 1-in relations that don't accumulate
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1412923038

   > @westonpace, in the [recent commit](https://github.com/apache/arrow/pull/33909/commits/65542c3cbbe28228d8105ab49430a9b3844a77d5), when coding up kDefaultNamedTapKindMapper, I reused the code structure for kDefaultNamedTableProvider. However, it looks like it is not properly initialized - I observed the error message C++ exception with description "bad_function_call" thrown in the test body when calling its operator(). Is this intended? Or shall I fix the initialization of both?
   
   What would you initialize it to?  There is no default named table provider.  I'm pretty sure we are using `kDefaultNamedTapKindMapper` as sentinel value only.  Since `std::function` evaluates to false if default initialized:
   
   ```
           if (!conversion_options.named_table_provider) {
             return Status::Invalid(
                 "plan contained a named table but a NamedTableProvider has not been "
                 "configured");
           }
   ```


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1421378775

   @westonpace, are you leaning toward accepting the current version of the PR, or something close to it? @icexelloss would be OK with reducing the PR to just adding the message, in case you'd prefer this.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1096045166


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   I agree with @rtpsw that going too generic (protobuf.Any in and Declaration out) is not a good idea.  This is the exact API for the `ExtensionProvider` and so we already have this.  You could use this for `WriteSmoothNodeOption` and it would end up looking just like the extension that is in place for AsofJoinNode.  If that works for you then there is nothing we need to do :)
   
   So if we want to go less generic then we should look at what Acero provides at each step to simplify things:
   
   ### Generic Node
   
   The next step down in generality would be to remove protobuf from the picture using Substrait/Arrow literals:
   
   ```
   message GenericOptions {
     message Property {
       string key = 0;
       Literal value = 1;
     }
     repeated Property properties = 1;
   }
   
   message GenericNode {
     string kind = 0;
     GenericOptions options = 1;
   }
   ```
   
   The API in Arrow would be:
   
   ```
   using Options = unordered_map<string, Scalar>;
   void RegisterGenericExtensionHandler(string kind, function<Declaration(Options)> handler);
   ```
   
   In other words, given properties as a map of arrow scalars, create a declaration
   
   **Pros:**
     * No need for extension author to write proto file
     * Can be used for any extension type
    
   **Cons:**
     * Need to create an entire ExecNode for your custom behavior
   
   ### Generic Mapper
   
   An even more focused approach could be to remove the need to create an exec node at all.  This would be focused on the 1 input in / 1 input out / no accumulation case (e.g. what MapNode handles).  From what I know of your write need this would fit this case.
   
   The Substrait would be pretty much identical to the above.
   
   ```
   message MapNode {
     string kind = 0;
     GenericOptions options = 1;
   }
   ```
   
   However, the Arrow API would be:
   
   ```
   using Options = unordered_map<string, Scalar>;
   using Mapper = function<ExecBatch(ExecBatch)>;
   void RegisterGenericMapHandler(string kind, function<Mapper(Options)> handler);
   ```
   
   **Pros:**
    * No need to write proto file
    * No need to create an exec node
   
   **Cons:**
    * Only handles 1-in relations that don't accumulate
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1100707431


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   Somehow missed this message - I am leaning towards "Generic Node" since it allows more flexibility to define node that is not just "map-like" and also we don't need to write protobuf file. 
   
   I have a question - if we go the "Generic Node" route it looks like we can achieve register custom handlers via either `RegisterGenericExtensionHandler` or `set_default_extension_provider` [https://github.com/apache/arrow/commit/7423f0332cb11eb780f421c07bac71f87bf44a03#diff-8c5c127e8db8e52b40519262ee2b7e0179d4a39e5bcfe8b2165173b2b352d6a9R139](url) so technically we don't need `set_default_extension_provider` if we have `RegisterGenericExtensionHandler`?
   



##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   Somehow missed this message - I am leaning towards "Generic Node" since it allows more flexibility to define node that is not just "map-like" and also we don't need to write protobuf file. 
   
   I have a question - if we go the "Generic Node" route it looks like we can achieve register custom handlers via either `RegisterGenericExtensionHandler` or `set_default_extension_provider` [https://github.com/apache/arrow/commit/7423f0332cb11eb780f421c07bac71f87bf44a03#diff-8c5c127e8db8e52b40519262ee2b7e0179d4a39e5bcfe8b2165173b2b352d6a9R139](link) so technically we don't need `set_default_extension_provider` if we have `RegisterGenericExtensionHandler`?
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095045102


##########
cpp/src/arrow/type.h:
##########
@@ -1968,6 +1968,8 @@ class ARROW_EXPORT Schema : public detail::Fingerprintable,
   Result<std::shared_ptr<Schema>> SetField(int i,
                                            const std::shared_ptr<Field>& field) const;
 
+  Result<std::shared_ptr<Schema>> WithNames(const std::vector<std::string>& names) const;

Review Comment:
   It gives a schema with the names changed, similar to other `With*` methods. I could add a docstring.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1102001141


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -67,6 +69,16 @@ using NamedTableProvider =
     std::function<Result<compute::Declaration>(const std::vector<std::string>&)>;
 static NamedTableProvider kDefaultNamedTableProvider;
 
+using NamedTapKindMapper = std::function<Result<compute::Declaration>(
+    const std::string&, std::vector<compute::Declaration::Input>,
+    std::shared_ptr<compute::ExecNodeOptions>)>;

Review Comment:
   Done.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1096045166


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   I agree with @rtpsw that going too generic (protobuf.Any in and Declaration out) is not a good idea.  This is the exact API for the `ExtensionProvider` and so we already have this.  You could use this for `WriteSmoothNodeOption` and it would end up looking just like the extension that is in place for AsofJoinNode.  If that works for you then there is nothing we need to do :)
   
   So if we want to go less generic then we should look at what Acero provides at each step to simplify things:
   
   ### Generic Node
   
   The next step down in generality would be to remove protobuf from the picture using Substrait/Arrow literals:
   
   ```
   message GenericOptions {
     message Property {
       string key = 0;
       Literal value = 1;
     }
     repeated Property properties = 1;
   }
   
   message GenericNode {
     string kind = 0;
     GenericOptions options = 1;
   }
   ```
   
   The API in Arrow would be:
   
   ```
   void RegisterGenericExtensionHandler(string kind, function<Declaration(unordered_map<string, Scalar>)> handler)
   ```
   
   In other words, given properties as a map of arrow scalars, create a declaration
   
   **Pros:**
     * No need for extension author to write proto file
     * Can be used for any extension type
    
   **Cons:**
     * Need to create an entire ExecNode for your custom behavior
   
   ### Generic Mapper
   
   An even more focused approach could be to remove the need to create an exec node at all.  This would be focused on the 1 input in / 1 input out / no accumulation case (e.g. what MapNode handles).  From what I know of your write need this would fit this case.
   
   The Substrait would be pretty much identical to the above.
   
   ```
   message MapNode {
     string kind = 0;
     GenericOptions options = 1;
   }
   ```
   
   However, the Arrow API would be:
   
   ```
   using Mapper = function<ExecBatch(ExecBatch)>;
   void RegisterGenericMapHandler(string kind, function<Mapper(unordered_map<string, Scalar>)> handler)
   ```
   
   **Pros:**
    * No need to write proto file
    * No need to create an exec node
   
   **Cons:**
    * Only handles 1-in relations that don't accumulate
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1094708520


##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -28,36 +28,58 @@
 namespace arrow {
 namespace engine {
 
+namespace {
+
+std::vector<compute::Declaration::Input> MakeDeclarationInputss(
+    const std::vector<DeclarationInfo>& inputs) {
+  std::vector<compute::Declaration::Input> input_decls(inputs.size());
+  for (size_t i = 0; i < inputs.size(); i++) {
+    input_decls[i] = inputs[i].declaration;
+  }
+  return input_decls;
+}
+
+}  // namespace
+
 class BaseExtensionProvider : public ExtensionProvider {
  public:
-  Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                               const std::vector<DeclarationInfo>& inputs,
                                const ExtensionDetails& ext_details,
                                const ExtensionSet& ext_set) override {
     auto details = dynamic_cast<const DefaultExtensionDetails&>(ext_details);
-    return MakeRel(inputs, details.rel, ext_set);
+    return MakeRel(conv_opts, inputs, details.rel, ext_set);
   }
 
-  virtual Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  virtual Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                                       const std::vector<DeclarationInfo>& inputs,
                                        const google::protobuf::Any& rel,
                                        const ExtensionSet& ext_set) = 0;
 };
 
 class DefaultExtensionProvider : public BaseExtensionProvider {
  public:
-  Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                               const std::vector<DeclarationInfo>& inputs,
                                const google::protobuf::Any& rel,
                                const ExtensionSet& ext_set) override {
     if (rel.Is<substrait_ext::AsOfJoinRel>()) {
       substrait_ext::AsOfJoinRel as_of_join_rel;
       rel.UnpackTo(&as_of_join_rel);
-      return MakeAsOfJoinRel(inputs, as_of_join_rel, ext_set);
+      return MakeAsOfJoinRel(conv_opts, inputs, as_of_join_rel, ext_set);
+    }
+    if (rel.Is<substrait_ext::NamedTapRel>()) {
+      substrait_ext::NamedTapRel named_tap_rel;
+      rel.UnpackTo(&named_tap_rel);
+      return MakeNamedTapRel(conv_opts, inputs, named_tap_rel, ext_set);
     }
     return Status::NotImplemented("Unrecognized extension in Susbstrait plan: ",
                                   rel.DebugString());
   }
 
  private:
-  Result<RelationInfo> MakeAsOfJoinRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeAsOfJoinRel(const ConversionOptions& conv_opts,

Review Comment:
   It gets passed all the way to `MakeNamedTapRel`, which uses `conv_opts.named_tap_mapper`.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095022896


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   In my mind we should do the following:
   
   (1) Add "NamedTapRel" as a purely abstract relation in Acero. The Acero code itself doesn't care or know how to turn a NamedTapRel message into a Declaration.
   
   (2) Add a C++ extension API that allows downstream users / implementer of the NamedTapRel to tell Acero "hey, if you see a NamedTapRel message, call into the custom substrait extension function that I provide here and I will return a declaration to u" (basically this: https://github.com/apache/arrow/issues/33850)
   
   This way I believe we don't need most the stuff here (including changes to pass conv_opts, named_tap_mapper, etc)
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095031320


##########
cpp/proto/substrait/extension_rels.proto:
##########
@@ -44,3 +44,17 @@ message AsOfJoinRel {
     repeated .substrait.Expression by = 2;
   }
 }
+
+// Named tap relation
+//
+// A tap is a relation having a single input relation that it passes through, while also
+// causing some side-effect, e.g., writing to external storage.
+message NamedTapRel {
+  // The kind of tap
+  string kind = 1;
+  // A name used to configure the tap, e.g., a URI defining the destination of writing
+  string name = 2;
+  // Column names for the tap's output. If specified there must be one name per field.
+  // If empty, field names will be automatically generated.

Review Comment:
   I think we should use 
   https://github.com/substrait-io/substrait/blob/main/proto/substrait/algebra.proto#L268
   
   that contains named tal rel similar to how we implement Asof join extension with ExtensionMultiRel



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095061363


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -67,6 +68,10 @@ using NamedTableProvider =
     std::function<Result<compute::Declaration>(const std::vector<std::string>&)>;
 static NamedTableProvider kDefaultNamedTableProvider;
 
+using NamedTapKindMapper = std::function<Result<std::string>(const std::string&)>;
+static NamedTapKindMapper kDefaultNamedTapKindMapper =

Review Comment:
   If you wanted to add this, I think we should probably match the signature of kDefaultNamedTableProvider and returns a Declaration instead? 
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1424395973

   2 is acceptable to me. @westonpace are u asking for "Generic Node" or "Generic Mapper"?


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1410064480

   @westonpace, in the [recent commit](https://github.com/apache/arrow/pull/33909/commits/65542c3cbbe28228d8105ab49430a9b3844a77d5), when coding up `kDefaultNamedTapKindMapper`, I reused the code structure for `kDefaultNamedTableProvider`. However, it looks like it is not properly initialized - I observed the error message `C++ exception with description "bad_function_call" thrown in the test body` when calling its `operator()`. Is this intended? Or shall I fix the initialization of both?


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095031320


##########
cpp/proto/substrait/extension_rels.proto:
##########
@@ -44,3 +44,17 @@ message AsOfJoinRel {
     repeated .substrait.Expression by = 2;
   }
 }
+
+// Named tap relation
+//
+// A tap is a relation having a single input relation that it passes through, while also
+// causing some side-effect, e.g., writing to external storage.
+message NamedTapRel {
+  // The kind of tap
+  string kind = 1;
+  // A name used to configure the tap, e.g., a URI defining the destination of writing
+  string name = 2;
+  // Column names for the tap's output. If specified there must be one name per field.
+  // If empty, field names will be automatically generated.

Review Comment:
   I think we should use 
   https://github.com/substrait-io/substrait/blob/main/proto/substrait/algebra.proto#L268
   
   To define the named tal rel similar to how we implement Asof join extension with ExtensionMultiRel



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1420801585

   My understanding is that even with the [most generic solution Weston described](https://github.com/westonpace), we would need some message defined since the current design has the extension provider check for the message using `google::protobuf::Any::Is<...>()`. Is there a different place, external to Arrow rather than in its `extension_rels.proto`, where we could define the message?


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1093868774


##########
cpp/proto/substrait/extension_rels.proto:
##########
@@ -44,3 +44,16 @@ message AsOfJoinRel {
     repeated .substrait.Expression by = 2;
   }
 }
+
+// Named tap relation
+//
+// A tap is a relation having a single input relation that it passes through, while also
+// causing some side-effect, e.g., writing to external storage.
+message NamedTapRel {
+  // The kind of tap
+  string kind = 1;
+  // A name used to configure the tap, e.g., a URI defining the destination of writing
+  string name = 2;
+  // Column names for the tap's output. Their number must be 0 or equal to the input's.

Review Comment:
   ```suggestion
     // Column names for the tap's output. If specified there must be one name per field.
     // This can be empty and field names will be generated
   ```



##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -28,36 +28,58 @@
 namespace arrow {
 namespace engine {
 
+namespace {
+
+std::vector<compute::Declaration::Input> MakeDeclarationInputss(
+    const std::vector<DeclarationInfo>& inputs) {
+  std::vector<compute::Declaration::Input> input_decls(inputs.size());
+  for (size_t i = 0; i < inputs.size(); i++) {
+    input_decls[i] = inputs[i].declaration;
+  }
+  return input_decls;
+}
+
+}  // namespace
+
 class BaseExtensionProvider : public ExtensionProvider {
  public:
-  Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                               const std::vector<DeclarationInfo>& inputs,
                                const ExtensionDetails& ext_details,
                                const ExtensionSet& ext_set) override {
     auto details = dynamic_cast<const DefaultExtensionDetails&>(ext_details);
-    return MakeRel(inputs, details.rel, ext_set);
+    return MakeRel(conv_opts, inputs, details.rel, ext_set);
   }
 
-  virtual Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  virtual Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                                       const std::vector<DeclarationInfo>& inputs,
                                        const google::protobuf::Any& rel,
                                        const ExtensionSet& ext_set) = 0;
 };
 
 class DefaultExtensionProvider : public BaseExtensionProvider {
  public:
-  Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                               const std::vector<DeclarationInfo>& inputs,
                                const google::protobuf::Any& rel,
                                const ExtensionSet& ext_set) override {
     if (rel.Is<substrait_ext::AsOfJoinRel>()) {
       substrait_ext::AsOfJoinRel as_of_join_rel;
       rel.UnpackTo(&as_of_join_rel);
-      return MakeAsOfJoinRel(inputs, as_of_join_rel, ext_set);
+      return MakeAsOfJoinRel(conv_opts, inputs, as_of_join_rel, ext_set);
+    }
+    if (rel.Is<substrait_ext::NamedTapRel>()) {
+      substrait_ext::NamedTapRel named_tap_rel;
+      rel.UnpackTo(&named_tap_rel);
+      return MakeNamedTapRel(conv_opts, inputs, named_tap_rel, ext_set);
     }
     return Status::NotImplemented("Unrecognized extension in Susbstrait plan: ",
                                   rel.DebugString());
   }
 
  private:
-  Result<RelationInfo> MakeAsOfJoinRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeAsOfJoinRel(const ConversionOptions& conv_opts,

Review Comment:
   Any particular reason to add `conv_opts` here?



##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -28,36 +28,58 @@
 namespace arrow {
 namespace engine {
 
+namespace {
+
+std::vector<compute::Declaration::Input> MakeDeclarationInputss(

Review Comment:
   ```suggestion
   std::vector<compute::Declaration::Input> MakeDeclarationInputs(
   ```



##########
cpp/src/arrow/engine/substrait/serde_test.cc:
##########
@@ -5355,5 +5380,97 @@ TEST(Substrait, AsOfJoinDefaultEmit) {
   CheckRoundTripResult(std::move(expected_table), buf, {}, conversion_options);
 }
 
+TEST(Substrait, PlanWithNamedTapExtension) {
+  // This demos an extension relation
+  std::string substrait_json = R"({
+    "extensionUris": [],
+    "extensions": [],
+    "relations": [{
+      "root": {
+        "input": {
+          "extension_multi": {
+            "inputs": [
+              {
+                "read": {
+                  "common": {
+                    "direct": {
+                    }
+                  },
+                  "baseSchema": {
+                    "names": ["time", "key", "value"],
+                    "struct": {
+                      "types": [
+                        {
+                          "i32": {
+                            "typeVariationReference": 0,
+                            "nullability": "NULLABILITY_NULLABLE"
+                          }
+                        },
+                        {
+                          "i32": {
+                            "typeVariationReference": 0,
+                            "nullability": "NULLABILITY_NULLABLE"
+                          }
+                        },
+                        {
+                          "fp64": {
+                            "typeVariationReference": 0,
+                            "nullability": "NULLABILITY_NULLABLE"
+                          }
+                        }
+                      ],
+                      "typeVariationReference": 0,
+                      "nullability": "NULLABILITY_REQUIRED"
+                    }
+                  },
+                  "namedTable": {
+                    "names": ["T"]
+                  }
+                }
+              }
+            ],
+            "detail": {
+              "@type": "/arrow.substrait_ext.NamedTapRel",
+              "kind" : "pass_for_named_tap",
+              "name" : "does_not_matter",
+              "columns" : ["pass_time", "pass_key", "pass_value"]
+            }
+          }
+        },
+        "names": ["t", "k", "v"]
+      }
+    }],
+    "expectedTypeUrls": []
+  })";
+
+  ASSERT_OK(AddPassFactory("pass_for_named_tap"));
+
+  std::shared_ptr<Schema> input_schema =
+      schema({field("time", int32()), field("key", int32()), field("value", float64())});
+  NamedTableProvider table_provider = ProvideMadeTable(
+      [&input_schema](
+          const std::vector<std::string>& names) -> Result<std::shared_ptr<Table>> {
+        if (names.size() != 1) {
+          return Status::Invalid("Multiple test table names");
+        }
+        if (names[0] == "T") {
+          return TableFromJSON(input_schema, {"[[2, 1, 1.1], [4, 1, 2.1], [6, 2, 3.1]]"});
+        }
+        return Status::Invalid("Unknown test table name ", names[0]);
+      });

Review Comment:
   Use `AlwaysProvideSameTable` for brevity.



##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -93,6 +106,11 @@ struct ARROW_ENGINE_EXPORT ConversionOptions {
   /// The default behavior will return an invalid status if the plan has any
   /// named table relations.
   NamedTableProvider named_table_provider = kDefaultNamedTableProvider;
+  /// \brief A custom strategy to be used for mapping a tap kind to a function name
+  ///
+  /// The default behavior will return an invalid status if the plan has any
+  /// named tap relations.

Review Comment:
   Couldn't a default implementation pass the `kind` through directly?  E.g. `pass_for_named_tap -> pass_for_named_tap`?



##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -111,15 +133,43 @@ class DefaultExtensionProvider : public BaseExtensionProvider {
     compute::AsofJoinNodeOptions asofjoin_node_opts{std::move(input_keys), tolerance};
 
     // declaration
-    std::vector<compute::Declaration::Input> input_decls(inputs.size());
-    for (size_t i = 0; i < inputs.size(); i++) {
-      input_decls[i] = inputs[i].declaration;
-    }
+    auto input_decls = MakeDeclarationInputss(inputs);
     return RelationInfo{
         {compute::Declaration("asofjoin", input_decls, std::move(asofjoin_node_opts)),
          std::move(schema)},
         std::move(field_output_indices)};
   }
+
+  Result<RelationInfo> MakeNamedTapRel(const ConversionOptions& conv_opts,
+                                       const std::vector<DeclarationInfo>& inputs,
+                                       const substrait_ext::NamedTapRel& named_tap_rel,
+                                       const ExtensionSet& ext_set) {
+    if (inputs.size() != 1) {
+      return Status::Invalid(
+          "substrait_ext::NamedTapNode requires a single table but got: ", inputs.size());

Review Comment:
   ```suggestion
             "substrait_ext::NamedTapRel requires a single input but got: ", inputs.size());
   ```



##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -111,15 +133,43 @@ class DefaultExtensionProvider : public BaseExtensionProvider {
     compute::AsofJoinNodeOptions asofjoin_node_opts{std::move(input_keys), tolerance};
 
     // declaration
-    std::vector<compute::Declaration::Input> input_decls(inputs.size());
-    for (size_t i = 0; i < inputs.size(); i++) {
-      input_decls[i] = inputs[i].declaration;
-    }
+    auto input_decls = MakeDeclarationInputss(inputs);

Review Comment:
   ```suggestion
       auto input_decls = MakeDeclarationInputs(inputs);
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095139749


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   I agree a specific structure can be useful however in this case I don't feel it is much more useful than a general one in this case. For example, the specific structure for the NamedTapNode make function creates a NamedTapNode option, and doesn't not allow the user to return a declaration with a custom node option (e.g, in our case, a WriteSmoothNodeOption), so we need to handle that in our code after calling this NamedTapNode make function here (or totally by pass NamedTapNode function here). This an be done but I feel that is unnecessary indirection.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1102001316


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -76,13 +88,22 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
  public:
   static std::shared_ptr<ExtensionProvider> kDefaultExtensionProvider;
   virtual ~ExtensionProvider() = default;
-  virtual Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  virtual Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                                       const std::vector<DeclarationInfo>& inputs,
                                        const ExtensionDetails& ext_details,
                                        const ExtensionSet& ext_set) = 0;
 };
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {

Review Comment:
   Done.



##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -93,6 +114,10 @@ struct ARROW_ENGINE_EXPORT ConversionOptions {
   /// The default behavior will return an invalid status if the plan has any
   /// named table relations.
   NamedTableProvider named_table_provider = kDefaultNamedTableProvider;
+  /// \brief A custom strategy to be used for mapping a tap kind to a function name
+  ///
+  /// The default mapper returns a declaration whose factory name is equal to the tap kind
+  NamedTapKindMapper named_tap_mapper = kDefaultNamedTapKindMapper;

Review Comment:
   Done.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1102001909


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -67,6 +69,16 @@ using NamedTableProvider =
     std::function<Result<compute::Declaration>(const std::vector<std::string>&)>;
 static NamedTableProvider kDefaultNamedTableProvider;
 
+using NamedTapKindMapper = std::function<Result<compute::Declaration>(
+    const std::string&, std::vector<compute::Declaration::Input>,
+    std::shared_ptr<compute::ExecNodeOptions>)>;
+static NamedTapKindMapper kDefaultNamedTapKindMapper =
+    [](const std::string& kind, std::vector<compute::Declaration::Input> inputs,
+       std::shared_ptr<compute::ExecNodeOptions> options)
+    -> Result<compute::Declaration> {
+  return compute::Declaration(kind, inputs, options);

Review Comment:
   Done.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095036684


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   I think with this approach, we can basically support any ExtensionSingleRel, ExtensionMultiRel and ExtensionLeafRel in the future with a single extension point (the custom substrait provider)



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095088266


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -67,6 +68,10 @@ using NamedTableProvider =
     std::function<Result<compute::Declaration>(const std::vector<std::string>&)>;
 static NamedTableProvider kDefaultNamedTableProvider;
 
+using NamedTapKindMapper = std::function<Result<std::string>(const std::string&)>;
+static NamedTapKindMapper kDefaultNamedTapKindMapper =

Review Comment:
   A string-typed argument is not sufficient for creating a declaration for an internal (non-source) node - the input declarations are required, and probably options too. Another reason for the differing signatures is that here the string-typed parameter is for the tap kind, which is semantically different than a table name.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095664348


##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -28,36 +28,58 @@
 namespace arrow {
 namespace engine {
 
+namespace {
+
+std::vector<compute::Declaration::Input> MakeDeclarationInputss(
+    const std::vector<DeclarationInfo>& inputs) {
+  std::vector<compute::Declaration::Input> input_decls(inputs.size());
+  for (size_t i = 0; i < inputs.size(); i++) {
+    input_decls[i] = inputs[i].declaration;
+  }
+  return input_decls;
+}
+
+}  // namespace
+
 class BaseExtensionProvider : public ExtensionProvider {
  public:
-  Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                               const std::vector<DeclarationInfo>& inputs,
                                const ExtensionDetails& ext_details,
                                const ExtensionSet& ext_set) override {
     auto details = dynamic_cast<const DefaultExtensionDetails&>(ext_details);
-    return MakeRel(inputs, details.rel, ext_set);
+    return MakeRel(conv_opts, inputs, details.rel, ext_set);
   }
 
-  virtual Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  virtual Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                                       const std::vector<DeclarationInfo>& inputs,
                                        const google::protobuf::Any& rel,
                                        const ExtensionSet& ext_set) = 0;
 };
 
 class DefaultExtensionProvider : public BaseExtensionProvider {
  public:
-  Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,
+                               const std::vector<DeclarationInfo>& inputs,
                                const google::protobuf::Any& rel,
                                const ExtensionSet& ext_set) override {
     if (rel.Is<substrait_ext::AsOfJoinRel>()) {
       substrait_ext::AsOfJoinRel as_of_join_rel;
       rel.UnpackTo(&as_of_join_rel);
-      return MakeAsOfJoinRel(inputs, as_of_join_rel, ext_set);
+      return MakeAsOfJoinRel(conv_opts, inputs, as_of_join_rel, ext_set);
+    }
+    if (rel.Is<substrait_ext::NamedTapRel>()) {
+      substrait_ext::NamedTapRel named_tap_rel;
+      rel.UnpackTo(&named_tap_rel);
+      return MakeNamedTapRel(conv_opts, inputs, named_tap_rel, ext_set);
     }
     return Status::NotImplemented("Unrecognized extension in Susbstrait plan: ",
                                   rel.DebugString());
   }
 
  private:
-  Result<RelationInfo> MakeAsOfJoinRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeAsOfJoinRel(const ConversionOptions& conv_opts,

Review Comment:
   Ah, sorry. Right, it's not needed here in `MakeAsOfJoinRel`; it's only needed in `MakeNamedTapRel`.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1096052487


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   Also, sorry, I was starting a bit with a blank slate above.  I think, in this PR, the current idea is that instead of using `GenericOptions` we use `string name` and encode the options into the name.  This is probably less flexible but in many cases users might be more familiar with encoding options into strings (ala URL encoding) instead of dealing with Arrow scalars.  I'm fine with either approach.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1102001703


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -67,6 +69,16 @@ using NamedTableProvider =
     std::function<Result<compute::Declaration>(const std::vector<std::string>&)>;
 static NamedTableProvider kDefaultNamedTableProvider;
 
+using NamedTapKindMapper = std::function<Result<compute::Declaration>(
+    const std::string&, std::vector<compute::Declaration::Input>,
+    std::shared_ptr<compute::ExecNodeOptions>)>;
+static NamedTapKindMapper kDefaultNamedTapKindMapper =

Review Comment:
   I made it configurable.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1102867955


##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -129,5 +175,28 @@ std::shared_ptr<ExtensionProvider> default_extension_provider() {
   return ExtensionProvider::kDefaultExtensionProvider;
 }
 
+namespace {
+
+NamedTapProvider g_default_named_tap_provider =
+    [](const std::string& tap_kind, std::vector<compute::Declaration::Input> inputs,
+       const std::string& tap_name,
+       std::shared_ptr<Schema> tap_schema) -> Result<compute::Declaration> {
+  return Status::NotImplemented("Named tap provider must be given");

Review Comment:
   ```suggestion
     return Status::NotImplemented("Plan contained a NamedTapRel but no provider configured");
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] ursabot commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1426657454

   Benchmark runs are scheduled for baseline = 8fed97fa951032a7e686407d29107cf48f6ab5f5 and contender = 24e5a580f907a2a995fb9183cb4cce6218c711e6. 24e5a580f907a2a995fb9183cb4cce6218c711e6 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/dcbeee00eec043829fdaa0fff47a0ad4...148eab5a337e451891b84280cc91570c/)
   [Failed :arrow_down:0.95% :arrow_up:0.12%] [test-mac-arm](https://conbench.ursa.dev/compare/runs/c42dd6da0fa14e368df088137a0aaec4...2ffdf66c54fa4d07b9eae418f6d96ebe/)
   [Finished :arrow_down:0.51% :arrow_up:0.0%] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/9cf7f9a54d6d4f2889413ba47992eb4b...97dec8db19df4e278ae93f91fd0cce4f/)
   [Finished :arrow_down:0.22% :arrow_up:0.0%] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/98b700999a0f46fb95d5cc62cbdc9643...477ff56a010f44da9f8fd7d051e753b9/)
   Buildkite builds:
   [Finished] [`24e5a580` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/2361)
   [Failed] [`24e5a580` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/2390)
   [Finished] [`24e5a580` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/2359)
   [Finished] [`24e5a580` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/2381)
   [Finished] [`8fed97fa` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/2360)
   [Finished] [`8fed97fa` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/2389)
   [Finished] [`8fed97fa` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/2358)
   [Finished] [`8fed97fa` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/2380)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] ursabot commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1426657879

   ['Python', 'R'] benchmarks have high level of regressions.
   [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/9cf7f9a54d6d4f2889413ba47992eb4b...97dec8db19df4e278ae93f91fd0cce4f/)
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1421492913

   IMO we should reduce this PR to be just the extension protobuf. The main reason is that most of the other change in this PR will not be used by us anyway because we will use another custom extension provider to handle the NamedTapMessage so it will not be hitting any of the code changes in this PR. Therefore introducing a bunch of code that will not be used doesn't seem necessarily.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1419955919

   @rtpsw With https://github.com/apache/arrow/pull/34042 merged I think we can simply this PR? I.e. we don't really need to use the `MakeNamedTapRel` in this PR since it will be implemented in the custom substrait consumer anyway?


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1100707431


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   Somehow missed this message - I am leaning towards "Generic Node" since it allows more flexibility to define node that is not just "map-like" and also we don't need to write protobuf file. 
   
   I have a question - if we go the "Generic Node" route it looks like we can achieve register custom handlers via either `RegisterGenericExtensionHandler` or `set_default_extension_provider` (https://github.com/apache/arrow/commit/7423f0332cb11eb780f421c07bac71f87bf44a03#diff-8c5c127e8db8e52b40519262ee2b7e0179d4a39e5bcfe8b2165173b2b352d6a9R139) so technically we don't need `set_default_extension_provider` if we have `RegisterGenericExtensionHandler`?
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095023186


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   @westonpace @rtpsw WDYT?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095024484


##########
cpp/src/arrow/type.h:
##########
@@ -1968,6 +1968,8 @@ class ARROW_EXPORT Schema : public detail::Fingerprintable,
   Result<std::shared_ptr<Schema>> SetField(int i,
                                            const std::shared_ptr<Field>& field) const;
 
+  Result<std::shared_ptr<Schema>> WithNames(const std::vector<std::string>& names) const;

Review Comment:
   What does this function do? (Missing docstring)



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095040557


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   Taking it a step further, we could just add `NamedTapRel` without any callback code, because one would be able (with #33850 and without this PR) register a custom extension provider that would handle it in `MakeRel` (and forward what it doesn't handle to the original/default extension provider). One step more, we could add nothing and just let the extension interpret an `Any` message. This feels like stepping in the wrong direction, which aggressively prioritizes generality. I feel we should have some structure in Acero for this, at least so that structures would get reused instead of reinvented.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1091118571


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   This is a design part to discuss. The current PR implementation takes the `kind field (i.e., `named_tap_rel.kind()`) as the factory name in the declaration. There is no need for a new `NamedTapProvider` concept when the factory registry is the provider of taps. OTOH, I agree with your mapping idea - adding a mapping from the `kind` field to the factory name would improve.
   
   So, the plan here is:
   - `NamedTapRel`: the `kind` field selects the tap's kind, the `name` field configures the tap's action, and the `columns` field configures the tap's output schema. 
   - `NamedTapNodeOptions`: the `name` field configured the tap's action as in `NamedTapRel`, and the `schema` field is the output schema configured for the tap. The selection of the tap kind is not done via options, so it's not included in them. 
   I could add a description along these lines in docstrings.
   
   The test code shows a vanilla example of this. The `AddPassFactory` tap is registered in the factory registry. It's configuration is not the focus of the test. In a (future) test case of a specific tap, we would cast the options argument of the tap's `Make` function to `NamedTapNodeOptions` and use the fields there to configure it.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1091118571


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   This is a design part to discuss. The current PR implementation takes the `kind` field (i.e., `named_tap_rel.kind()`) as the factory name in the declaration. There is no need for a new `NamedTapProvider` concept when the factory registry is the provider of taps. OTOH, I agree with your mapping idea - adding a mapping from the `kind` field to the factory name would improve.
   
   So, the plan here is:
   - `NamedTapRel`: the `kind` field selects the tap's kind, the `name` field configures the tap's action, and the `columns` field configures the tap's output schema. 
   - `NamedTapNodeOptions`: the `name` field configured the tap's action as in `NamedTapRel`, and the `schema` field is the output schema configured for the tap. The selection of the tap kind is not done via options, so it's not included in them. 
   I could add a description along these lines in docstrings.
   
   The test code shows a vanilla example of this. The `AddPassFactory` tap is registered in the factory registry. It's configuration is not the focus of the test. In a (future) test case of a specific tap, we would cast the options argument of the tap's `Make` function to `NamedTapNodeOptions` and use the fields there to configure it.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1093867742


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   If you return exec node options (similar to named tap provider) then you could bypass the need to encode properties into the name (you wouldn't even really need `kind`):
   
   ```
   # in python
   def tap_provider(name):
     if name == 'one':
       return TeeNodeOptions('/tmp/dataset_one')
     elif name == 'two':
       return TeeNodeOptions('/tmp/dataset_two')
     else:
       raise Error(...)
   ```
   
   or you could move the name encoding / decoding into python
   
   ```
   # in python
   def tap_provider(name)
     path = get_path_from_name(name)
     return TeeNodeOptions(path)
   ```
   
   or you could still use the kind mapping
   
   ```
   # in python
   def tap_provider(name)
     kind = get_kind_from_name(name)
     if kind == 'tee':
      return TeeNodeOptions(path)...
   ```
   
   However, this feature is still pretty experimental so I don't mind sticking with kind<->factory name mapping for now if that is what you would prefer.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095043677


##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -28,36 +28,58 @@
 namespace arrow {
 namespace engine {
 
+namespace {
+
+std::vector<compute::Declaration::Input> MakeDeclarationInputs(
+    const std::vector<DeclarationInfo>& inputs) {
+  std::vector<compute::Declaration::Input> input_decls(inputs.size());
+  for (size_t i = 0; i < inputs.size(); i++) {
+    input_decls[i] = inputs[i].declaration;
+  }
+  return input_decls;
+}
+
+}  // namespace
+
 class BaseExtensionProvider : public ExtensionProvider {
  public:
-  Result<RelationInfo> MakeRel(const std::vector<DeclarationInfo>& inputs,
+  Result<RelationInfo> MakeRel(const ConversionOptions& conv_opts,

Review Comment:
   See [this discussion](https://github.com/apache/arrow/pull/33909#discussion_r1093869541).



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1413896662

   > What would you initialize it to?
   
   I would have the default implementation return the invalid status, like the one you pointed to.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095054111


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   IMO I don't think this is over generalized - it matches the level of generalization in substrait extension protobuf - Leaf, single rel and multiple rel. As something experimental at this stage I think we do benefit from generalization since we make very minimal changes to Acero code itself and have more freedom to experiment / iterator faster on our side.
   
   And if we have https://github.com/apache/arrow/issues/33850, then I think we don't need `kDefaultNamedTapKindMapper` and feels to me it's a simpler single extension point.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095054111


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   IMO I don't think this is over generalized - it matches the level of generalization in substrait extension protobuf - Leaf, single rel and multiple rel. As something experimental at this stage I think we do benefit from generalization since we make very minimal changes to Acero code itself and have more freedom to experiment / iterate faster on our side.
   
   And if we have https://github.com/apache/arrow/issues/33850, then I think we don't need `kDefaultNamedTapKindMapper` and feels to me it's a simpler single extension point.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1096054051


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   So sticking with `name` I think the two approaches are:
   
   ### Generic Node
   ```
   void RegisterGenericExtensionHandler(string kind, function<Declaration(string)> handler);
   ```
   ### Generic Mapper
   ```
   using Mapper = function<ExecBatch(ExecBatch)>;
   void RegisterGenericMapHandler(string kind, function<Mapper(string)> handler);
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1422807774

   @westonpace would u be ok with having just the proto change in 
   https://github.com/apache/arrow/pull/33909/files#diff-878a08387dc84ac471ccb8f129a6e032154fc82d457f8cc59bfcbe012920339b 
   
   I think since the we can register custom substrait extension consumer, we won't really need to call into the implementation for "NamedTapRel" in the default substrait consumer. 
   
   If there is a use case can justifies support NamedTapRel in the default consumer I think we can add that later (but currently, our use case doesn't need it). WDTY?


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1100707431


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   Somehow missed this message - I am leaning towards "Generic Node" since it allows more flexibility to define node that is not just "map-like" and also we don't need to write protobuf file. 
   
   I have a question - if we go the "Generic Node" route it looks like we can achieve register custom handlers via either `RegisterGenericExtensionHandler` or `set_default_extension_provider` [https://github.com/apache/arrow/commit/7423f0332cb11eb780f421c07bac71f87bf44a03#diff-8c5c127e8db8e52b40519262ee2b7e0179d4a39e5bcfe8b2165173b2b352d6a9R139](url) so technically we don't need `set_default_extension_provider` if we have `RegisterGenericExtensionHandler`?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1423558826

   If 2 is acceptable then I would ask that we please move to that.  I think the only change is to have the mapper return a declaration instead of a string.  If we feel there is still some ambiguity I'd be happy to make a PR / diff real quick to show what I am thinking.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1422819106

   One thing I am thinking is for testing maybe we can do the following:
   
   * construct a plan that contains a NamedTapRel
   * register a custom substrait consumer that can handle NamedTapRel (returns some declaration, but not necessarily need to execute it) 
   * Verify the Declaration 
   
   This way the test serves and both an example for using NamedTapRel and also mimicing how we will be using this internally.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace merged pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace merged PR #33909:
URL: https://github.com/apache/arrow/pull/33909


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1096055349


##########
cpp/proto/substrait/extension_rels.proto:
##########
@@ -44,3 +44,17 @@ message AsOfJoinRel {
     repeated .substrait.Expression by = 2;
   }
 }
+
+// Named tap relation
+//
+// A tap is a relation having a single input relation that it passes through, while also
+// causing some side-effect, e.g., writing to external storage.
+message NamedTapRel {
+  // The kind of tap
+  string kind = 1;
+  // A name used to configure the tap, e.g., a URI defining the destination of writing
+  string name = 2;
+  // Column names for the tap's output. If specified there must be one name per field.
+  // If empty, field names will be automatically generated.

Review Comment:
   I have no strong opinion on this either.  I do agree there will be cases where the tap doesn't care about the names but forcing the producer to invent field names in this case isn't much burden.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1422883874

   I'd rather not just add proto without any support for processing that proto.  A mapper that returns a declaration seems simple enough (and this PR is 80% of the way there) and this makes it clear what the intent of the proto message is even if you don't end up using it.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1422899614

   > A mapper that returns a declaration seems simple enough (and this PR is 80% of the way there) and this makes it clear what the intent of the proto message is even if you don't end up using it.
   
   Fair enough. Let do that @rtpsw 


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on PR #33909:
URL: https://github.com/apache/arrow/pull/33909#issuecomment-1423299225

   @rtpsw @westonpace 
   
   I realize there might be some confusion so I want to clarify here.
   
   There seems to be two (or three) proposed solutions:
   (1) The one that is implemented in the PR now
   (2) What Weston wrote 5 days ago here (https://github.com/apache/arrow/pull/33909#discussion_r1096045166) (The Generic Node / Generic Map) (sorry I somehow missed this message and just read that Today)
   
   It's not clear to me if we have agreement to go with one vs the other? Both seem workable to me. (2) does seem a bit more generic / future proof and (1) seems pretty much done. 
   
   Li


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1090884638


##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -28,6 +28,19 @@
 namespace arrow {
 namespace engine {
 
+namespace {
+
+std::vector<compute::Declaration::Input> MakeInputDeclarations(

Review Comment:
   Maybe call this `MakeDeclarationInputs`?  An "input declaration" sounds like a source node.



##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -28,6 +28,19 @@
 namespace arrow {
 namespace engine {
 
+namespace {
+
+std::vector<compute::Declaration::Input> MakeInputDeclarations(
+    const std::vector<DeclarationInfo> inputs) {

Review Comment:
   ```suggestion
       const std::vector<DeclarationInfo>& inputs) {
   ```



##########
cpp/proto/substrait/extension_rels.proto:
##########
@@ -44,3 +44,9 @@ message AsOfJoinRel {
     repeated .substrait.Expression by = 2;
   }
 }
+
+message NamedTapRel {
+  string kind = 1;
+  string name = 2;
+  repeated string columns = 3;
+}

Review Comment:
   Let's add some comments explaining what these are perhaps.



##########
cpp/src/arrow/engine/substrait/options.cc:
##########
@@ -111,15 +129,43 @@ class DefaultExtensionProvider : public BaseExtensionProvider {
     compute::AsofJoinNodeOptions asofjoin_node_opts{std::move(input_keys), tolerance};
 
     // declaration
-    std::vector<compute::Declaration::Input> input_decls(inputs.size());
-    for (size_t i = 0; i < inputs.size(); i++) {
-      input_decls[i] = inputs[i].declaration;
-    }
+    auto input_decls = MakeInputDeclarations(inputs);
     return RelationInfo{
         {compute::Declaration("asofjoin", input_decls, std::move(asofjoin_node_opts)),
          std::move(schema)},
         std::move(field_output_indices)};
   }
+
+  Result<RelationInfo> MakeNamedTapRel(const std::vector<DeclarationInfo>& inputs,
+                                       const substrait_ext::NamedTapRel& named_tap_rel,
+                                       const ExtensionSet& ext_set) {
+    if (inputs.size() != 1) {
+      return Status::Invalid(
+          "substrait_ext::NamedTapNode requires a single table but got: ", inputs.size());
+    }
+
+    auto schema = inputs[0].output_schema;
+    int num_fields = schema->num_fields();
+    if (named_tap_rel.columns_size() != num_fields) {
+      return Status::Invalid("Got ", named_tap_rel.columns_size(),
+                             " NamedTapRel columns but expected ", num_fields);
+    }
+    int i = 0;
+    FieldVector fields(static_cast<size_t>(num_fields));
+    for (const auto& column : named_tap_rel.columns()) {
+      fields[i] = field(column, schema->field(i)->type());
+      i++;
+    }
+    auto renamed_schema = arrow::schema(std::move(fields));

Review Comment:
   There is a `Field::WithName` method.  You could maybe move this into a `Schema::WithNames` method.  I wrote one once but it was on a PR that didn't end up merging:
   
   ```
   Result<std::shared_ptr<Schema>> Schema::WithNames(
       const std::vector<std::string>& names) const {
     if (names.size() != impl_->fields_.size()) {
       return Status::Invalid("attempted to rename schema with ", impl_->fields_.size(),
                              " fields but only ", names.size(), " new names were given");
     }
     FieldVector new_fields;
     auto names_itr = names.begin();
     for (const auto& field : impl_->fields_) {
       new_fields.push_back(field->WithName(*names_itr));
       names_itr++;
     }
     return schema(std::move(new_fields));
   }
   ```



##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   I'm not sure what the plan is here.  I thought originally the goal was to mimic the named table.  In that case I'd expect to see something like `NamedTableProvider` (e.g. `NamedTapProvider`) that translates names into actual nodes (e.g. a `TeeNode`).
   
   In that case I wouldn't expect there to be any "named tap" equivalent in Acero.  I'm not sure what `NamedTapNode` and `AddPassFactory` are providing in this PR?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] rtpsw commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "rtpsw (via GitHub)" <gi...@apache.org>.
rtpsw commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1094715454


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -93,6 +106,11 @@ struct ARROW_ENGINE_EXPORT ConversionOptions {
   /// The default behavior will return an invalid status if the plan has any
   /// named table relations.
   NamedTableProvider named_table_provider = kDefaultNamedTableProvider;
+  /// \brief A custom strategy to be used for mapping a tap kind to a function name
+  ///
+  /// The default behavior will return an invalid status if the plan has any
+  /// named tap relations.

Review Comment:
   I guess so.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095022896


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   In my mind we should do the following:
   
   (1) Add "NamedTapRel" as a purely abstract relation in Acero. The Acero substrait consumer code itself doesn't care or know how to turn a NamedTapRel message into a Declaration.
   
   (2) Add a C++ extension API that allows downstream users / implementer of the NamedTapRel to tell Acero "hey, if you see a NamedTapRel message, call into the custom substrait extension function that I provide here and I will return a declaration to u" (basically this: https://github.com/apache/arrow/issues/33850)
   
   This way I believe we don't need most the stuff here (including changes to pass conv_opts, named_tap_mapper, etc)
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095031320


##########
cpp/proto/substrait/extension_rels.proto:
##########
@@ -44,3 +44,17 @@ message AsOfJoinRel {
     repeated .substrait.Expression by = 2;
   }
 }
+
+// Named tap relation
+//
+// A tap is a relation having a single input relation that it passes through, while also
+// causing some side-effect, e.g., writing to external storage.
+message NamedTapRel {
+  // The kind of tap
+  string kind = 1;
+  // A name used to configure the tap, e.g., a URI defining the destination of writing
+  string name = 2;
+  // Column names for the tap's output. If specified there must be one name per field.
+  // If empty, field names will be automatically generated.

Review Comment:
   I think we should use 
   https://github.com/substrait-io/substrait/blob/main/proto/substrait/algebra.proto#L268
   
   To define the named tal rel similar to how we implement Asof join extension with MultiRelExtension



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095031320


##########
cpp/proto/substrait/extension_rels.proto:
##########
@@ -44,3 +44,17 @@ message AsOfJoinRel {
     repeated .substrait.Expression by = 2;
   }
 }
+
+// Named tap relation
+//
+// A tap is a relation having a single input relation that it passes through, while also
+// causing some side-effect, e.g., writing to external storage.
+message NamedTapRel {
+  // The kind of tap
+  string kind = 1;
+  // A name used to configure the tap, e.g., a URI defining the destination of writing
+  string name = 2;
+  // Column names for the tap's output. If specified there must be one name per field.
+  // If empty, field names will be automatically generated.

Review Comment:
   I think we should use 
   https://github.com/substrait-io/substrait/blob/main/proto/substrait/algebra.proto#L268
   
   instead of extension multi rel



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] icexelloss commented on a diff in pull request #33909: GH-33899: [C++] Add NamedTapRel relation as a Substrait extension

Posted by "icexelloss (via GitHub)" <gi...@apache.org>.
icexelloss commented on code in PR #33909:
URL: https://github.com/apache/arrow/pull/33909#discussion_r1095028635


##########
cpp/src/arrow/engine/substrait/options.h:
##########
@@ -83,6 +84,14 @@ class ARROW_ENGINE_EXPORT ExtensionProvider {
 
 ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
 
+struct ARROW_ENGINE_EXPORT NamedTapNodeOptions : public compute::ExecNodeOptions {
+  NamedTapNodeOptions(const std::string& name, std::shared_ptr<Schema> schema)
+      : name(name), schema(std::move(schema)) {}
+
+  std::string name;
+  std::shared_ptr<Schema> schema;
+};

Review Comment:
   Maybe the API for (2) can also be "Hey, if you see an certain type of message (is there a way to detect a message is an extension message)?) pass it to the custom extension function that I provide and I will return a declaration to u" 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org