Hello, I have found the mistake the correct version of the test, would be:
#include <vector>#include <memory>#include <iostream>
#include <arrow/api.h>#include <arrow/result.h>#include
<arrow/table_builder.h>#include <arrow/type_traits.h>#include
<arrow/util/iterator.h>#include <arrow/util/logging.h>#include
<arrow/visit_array_inline.h>
std::shared_ptr<arrow::Schema> ExampleSchema1() { auto f0 = arrow::field("f0",
arrow::int32()); auto f1 = arrow::field("f1", arrow::utf8()); auto f2 =
arrow::field("f1", arrow::list(arrow::int8())); return arrow::schema({f0, f1,
f2});}
arrow::Result<std::shared_ptr<arrow::RecordBatchBuilder>> test(){
std::shared_ptr<arrow::Schema> schema = ExampleSchema1();
std::unique_ptr<arrow::RecordBatchBuilder> batch_builder; std::int64_t nrows =
10; ARROW_ASSIGN_OR_RAISE(batch_builder,
arrow::RecordBatchBuilder::Make(schema, arrow::default_memory_pool(), nrows));
return batch_builder;}
int main(){ test(); return 0;}
Actually the problem I had it was the same on the example I was returning
std::unique_ptr<arrow::RecordBatchBuilder> instead of
arrow::Result<std::unique_ptr<arrow::RecordBatchBuilder>>. thanks =)
On 2022/10/23 12:53:24 Alan Souza via user wrote: Hello. I am trying to use
this macro with the the arrow function arrow::RecordBatchBuilder::Make with
this macroHowever I am getting this error: /usr/bin/c++ -isystem
/usr/local/arrow/include -O3 -DNDEBUG -fPIE -std=c++17 -MD -MT
benchmark/CMakeFiles/reproducer.exe.dir/reproducer.cpp.o -MF
benchmark/CMakeFiles/reproducer.exe.dir/reproducer.cpp.o.d -o
benchmark/CMakeFiles/reproducer.exe.dir/reproducer.cpp.o -c
/workspaces/cpptest/benchmark/reproducer.cpp In file included from
/usr/local/arrow/include/arrow/buffer.h:29, from
/usr/local/arrow/include/arrow/array/data.h:26, from
/usr/local/arrow/include/arrow/array/array_base.h:26, from
/usr/local/arrow/include/arrow/array.h:37, from
/usr/local/arrow/include/arrow/api.h:22, from
/workspaces/cpptest/benchmark/reproducer.cpp:5:
/workspaces/cpptest/benchmark/reproducer.cpp: In function ‘int main()’:
/workspaces/cpptest/benchmark/reproducer.cpp:28:5: error: cannot convert ‘const
arrow::Status’ to ‘int’ in return 28 |
ARROW_ASSIGN_OR_RAISE(batch_builder, arrow::RecordBatchBuilder::Make(schema,
arrow::default_memory_pool(), nrows)); | ^ | | |
const arrow::Status ninja: build stopped: subcommand failed. I am using g++
12.2.1 (I also have tried with clang++ 14.0.5) with a built arrow library 10 (I
also have tried with arrow 9). The strangest thing is that I am able to build
and run the rapidjson conversion example. that uses a similar construct Without
using the macro (the commented out code) works without any issues. #include
#include #include #include #include #include #include #include #include
#include std::shared_ptr ExampleSchema1() { auto f0 = arrow::field("f0",
arrow::int32()); auto f1 = arrow::field("f1", arrow::utf8()); auto f2 =
arrow::field("f1", arrow::list(arrow::int8())); return arrow::schema({f0, f1,
f2});} int main(){ std::shared_ptr schema = ExampleSchema1(); std::unique_ptr
batch_builder; std::int64_t nrows = 10; ARROW_ASSIGN_OR_RAISE(batch_builder,
arrow::RecordBatchBuilder::Make(schema, arrow::default_memory_pool(), nrows));
// arrow::Result batch_builder_result = arrow::RecordBatchBuilder::Make(schema,
// arrow::default_memory_pool(), // nrows); // if(!batch_builder_result.ok()){
// std::cerr return 0;} thanks -