You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ap...@apache.org on 2023/01/23 20:16:04 UTC

[arrow] branch master updated: MINOR: [C++][R] Declare FieldRef(std::vector) constructor explicit (#33838)

This is an automated email from the ASF dual-hosted git repository.

apitrou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 767252309a MINOR: [C++][R] Declare FieldRef(std::vector<FieldRef>) constructor explicit (#33838)
767252309a is described below

commit 767252309ad2fa9b491039571544e59a9435b7f8
Author: Felipe Oliveira Carvalho <fe...@gmail.com>
AuthorDate: Mon Jan 23 17:15:58 2023 -0300

    MINOR: [C++][R] Declare FieldRef(std::vector<FieldRef>) constructor explicit (#33838)
    
    This implicit constructor can make passing `std::vector<FieldRef>`s around very confusing. You might think you are passing a vector, but it's implicitly being converted into a single `FieldRef`.
    
    Authored-by: Felipe Oliveira Carvalho <fe...@gmail.com>
    Signed-off-by: Antoine Pitrou <an...@python.org>
---
 cpp/src/arrow/type.h | 4 +---
 r/src/expression.cpp | 3 ++-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/cpp/src/arrow/type.h b/cpp/src/arrow/type.h
index 05fcb3d615..1e16806947 100644
--- a/cpp/src/arrow/type.h
+++ b/cpp/src/arrow/type.h
@@ -1692,9 +1692,7 @@ class ARROW_EXPORT FieldRef : public util::EqualityComparable<FieldRef> {
   FieldRef(int index) : impl_(FieldPath({index})) {}  // NOLINT runtime/explicit
 
   /// Construct a nested FieldRef.
-  FieldRef(std::vector<FieldRef> refs) {  // NOLINT runtime/explicit
-    Flatten(std::move(refs));
-  }
+  explicit FieldRef(std::vector<FieldRef> refs) { Flatten(std::move(refs)); }
 
   /// Convenience constructor for nested FieldRefs: each argument will be used to
   /// construct a FieldRef
diff --git a/r/src/expression.cpp b/r/src/expression.cpp
index d7a511e760..fbed6b5ee3 100644
--- a/r/src/expression.cpp
+++ b/r/src/expression.cpp
@@ -101,7 +101,8 @@ std::shared_ptr<compute::Expression> compute___expr__nested_field_ref(
     }
     // Add the new ref
     ref_vec.push_back(arrow::FieldRef(std::move(name)));
-    return std::make_shared<compute::Expression>(compute::field_ref(std::move(ref_vec)));
+    return std::make_shared<compute::Expression>(
+        compute::field_ref(arrow::FieldRef{std::move(ref_vec)}));
   } else {
     cpp11::stop("'x' must be a FieldRef Expression");
   }