Unable to pass `pyarrow` table to `arrow::Table`

  apache-arrow, c++, pyarrow, pybind11

I’m trying to pass a pyarrow table to c++ via pybind11. In this example I’m simply trying to print the number of rows of a pyarrow table passed from python.

#include <pybind11/pybind11.h>
#include <Python.h>
#include <iostream>
#include <arrow/python/pyarrow.h>

// Convert pyarrow table to native C++ object and print its contents
void print_table(PyObject* py_table)
    // convert pyobject to table
    auto status = arrow::py::unwrap_table(py_table);
    if (!status.ok())
        std::cout << "Error converting pyarrow table to arrow table" << std::endl;
    std::shared_ptr<arrow::Table> table = status.ValueOrDie();
    std::cout << "Table has " << table->num_rows() << " rows" << std::endl;

PYBIND11_MODULE(df_test, m)
    m.doc() = "Pyarrow Extensions";
    m.def("print_table", &print_table);

However I get the following error:

 error: member access into incomplete type 'std::shared_ptr<arrow::Table>::element_type' (aka 'arrow::Table')
    std::cout << "Table has " << table->num_rows() << " rows" << std::endl;

How do I fix this error?

Source: Windows Questions C++