C++ documentation for Parquet files is misleading for includes
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the bug, including details regarding any error messages, version, and platform.
I looked at the documentation there to figure out how to open a Parquet file with C++: https://arrow.apache.org/docs/cpp/parquet.html#filereader
In the example, we have this:
```cpp
// #include "arrow/io/api.h"
// #include "parquet/arrow/reader.h"
arrow::MemoryPool* pool = arrow::default_memory_pool();
std::shared_ptr input;
ARROW_ASSIGN_OR_RAISE(input, arrow::io::ReadableFile::Open(path_to_file));
// Open Parquet file reader
std::unique_ptr arrow_reader;
ARROW_ASSIGN_OR_RAISE(arrow_reader, parquet::arrow::OpenFile(input, pool));
// Read entire file as a single Arrow table
std::shared_ptr table;
ARROW_RETURN_NOT_OK(arrow_reader->ReadTable(&table));
```
So I tried this code (by uncommenting the imports) and it compiles but the table that we get does not seem correct, because any of the methods of tables does not work and gives errors like this:
```
/path/to/test.cpp: In function 'arrow::Status open_parquet(std::string&)':
/path/to/test.cpp:28:26: error: invalid use of incomplete type 'using std::__shared_ptr_access::element_type = class arrow::Table' {aka 'class arrow::Table'}
28 | auto num_rows = table->num_rows();
| ^~
In file included from /usr/include/arrow/io/type_fwd.h:20,
from /usr/include/arrow/io/interfaces.h:26,
from /usr/include/arrow/io/concurrency.h:22,
from /usr/include/arrow/io/buffered.h:26,
from /usr/include/arrow/io/api.h:20,
from /path/to/test.cpp:7:
/usr/include/arrow/type_fwd.h:86:7: note: forward declaration of 'using std::__shared_ptr_access::element_type = class arrow::Table' {aka 'class arrow::Table'}
86 | class Table;
| ^~~~~
```
But then by replacing `#include "arrow/io/api.h"` with:
```cpp
#include "arrow/api.h"
#include "arrow/io/file.h"
```
it works correctly.
### Component(s)
C++
Contributor guide
Assessment
This issue has not been assessed yet.