dinimar commented on issue #14939:
URL: https://github.com/apache/arrow/issues/14939#issuecomment-1464481799

   @rok @pitrou @benibus Hi, I'm a newbie and stuck at implementing 
`FieldPath::Get(const Table & table)`
   Test case code:
   ```
   ...
     for (int index = 0; index < tablePtr->num_columns(); ++index) {
       ASSERT_OK_AND_ASSIGN(auto fieldPathColumn, 
FieldPath({index}).Get(*tablePtr));
       EXPECT_TRUE(fieldPathColumn->Equals(tablePtr->column(index)));
     }
   ...
   ```
   Currently, I have the following implementation for this function:
   ```
   Result<std::shared_ptr<ChunkedArray>> FieldPath::Get(const Table& table) 
const {
     ARROW_ASSIGN_OR_RAISE(auto data, FieldPathGetImpl::Get(this, 
table.columns()));
     return data;
   }
   ```
   And the following `FieldPathGetImpl::Get` implementation:
   ```
     static Result<std::shared_ptr<ChunkedArray>> Get(const FieldPath* path,
                                                      const ChunkedArrayVector& 
table) {
       return FieldPathGetImpl::Get(
         path, &table,
         [](const std::shared_ptr<ChunkedArray>& data)  {
           return data;
         });
     }
   ```
   
   For the function above I got the following compilation error:
   ```
   \arrow\cpp\src\arrow\type.cc(1136,1): error C2440: '=': cannot convert from 
'std::shared_ptr<arrow::ChunkedArray>' to 'const 
std::vector<std::shared_ptr<arrow::ChunkedArray>,std::allocator<std::shared_ptr<arrow::ChunkedArray>>>
 *'
   ```
   related code:
   ```
   template <typename T, typename GetChildren>
     static Result<T> Get(const FieldPath* path, const std::vector<T>* children,
                          GetChildren&& get_children, int* out_of_range_depth) {
   ...
   
         out = &children->at(index);
         children = get_children(*out); // line 1136
         ++depth;
       }
   
       return *out;
     }
   ```
   
   Implementations with no using `Result<T> FieldPathGetImpl::Get(const 
FieldPath* path, const std::vector<T>* children,
                          GetChildren&& get_children, int* out_of_range_depth)` 
will violate DRY principle by creating non-template functions specifically for 
Table or putting implementation of template function right in `Get(const 
FieldPath* path,
                                                      const ChunkedArrayVector& 
table) `
   
   Any help would be appreciated. Other functions are implemented and tested by 
unit tests
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to