You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "lidavidm (via GitHub)" <gi...@apache.org> on 2023/03/06 18:00:39 UTC

[GitHub] [arrow] lidavidm commented on a diff in pull request #34406: GH-34405: [C++] Add support for custom names in QueryOptions. Wire this up to Substrait

lidavidm commented on code in PR #34406:
URL: https://github.com/apache/arrow/pull/34406#discussion_r1126828055


##########
cpp/src/arrow/compute/exec/options.h:
##########
@@ -614,6 +616,13 @@ class ARROW_EXPORT TableSinkNodeOptions : public ExecNodeOptions {
   ///
   /// \see QueryOptions for more details
   std::optional<bool> sequence_output;
+  /// \brief Custom names to use for the columns.
+  ///
+  /// If specified then names must be provided for all fields. Currently, only a flat
+  /// schema is supported (see ARROW-15901).

Review Comment:
   nit: maybe we should refer to the GitHub issue instead? (I assume this was copied from above)



##########
cpp/src/arrow/compute/exec/exec_plan.cc:
##########
@@ -925,14 +943,32 @@ struct BatchConverter {
         });
   }
 
+  Result<std::shared_ptr<Schema>> InitializeSchema(
+      const std::vector<std::string>& names) {
+    // By this point this->schema will have been set by the SinkNode.  We potentially
+    // rename it with the names provided by the user and then return this in case the user
+    // wants to know the output schema.
+    if (!names.empty()) {
+      if (static_cast<int>(names.size()) != schema->num_fields()) {
+        return Status::Invalid(
+            "A plan was created with custom field names but the number of names did not "
+            "match the number of output columns");

Review Comment:
   nit: include expected/actual count in the message for convenience?



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