Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The Arrow API of the Python client regularly causes confusion. The most important issues seem to be that:
Also see #97
Core Functions
The Connection API (and with it, the
duckdbmodule) and the Relational API have two core functions to create Arrow objects:fetch_record_batch() -> pyarrow.lib.RecordBatchReaderfetch_arrow_table() -> pyarrow.lib.TableThe Connection API has another function to create a Relation from an Arrow object:
arrow(arrow_object, connection = None) -> DuckDBPyRelationAliases
The Connection and Relational APIs both have an alias for
fetch_record_batch():arrow() -> pyarrow.lib.RecordBatchReaderThis function was the first we exposed in the API and is probably most often used. It changed return type over the course of 1.4.X, fromTabletoRecordBatchReader, which caused a number of issues.The Relational API has three more aliases:
to_arrow_table() -> pyarrow.lib.Tablefetch_arrow_reader() -> pyarrow.lib.RecordBatchReaderrecord_batch() -> pyarrow.lib.RecordBatchReader(this has been deprecated for a while)Changes
v1.5.0 API
The Connection and Relational APIs will have the following functions:
to_arrow_reader() -> pyarrow.lib.RecordBatchReaderto_arrow_table() -> pyarrow.lib.Tablearrow() -> pyarrow.lib.RecordBatchReaderNote: we will not deprecate this function in v1.5.0, but we will discourage its use in both the documentation and the docstring. We encourage users to useto_arrow_reader()instead.The Connection API will keep this function:
arrow(arrow_object, connection = None) -> DuckDBPyRelationv1.5.0 Deprecated API
The
fetch_*functions will be deprecated in v1.5.0 (which will be emitted as a DeprecationWarning) and removed in v1.6.0:fetch_record_batch() -> pyarrow.lib.RecordBatchReaderfetch_arrow_table() -> pyarrow.lib.Tablefetch_arrow_reader() -> pyarrow.lib.RecordBatchReaderv1.5.0 Removed API
Relation::record_batch() -> pyarrow.lib.RecordBatchReaderwill be removed.What's in a Name
Arrow's ADBC Driver Manager API uses the
fetch_*naming convention (docs):fetch_arrow_table()fetch_record_reader()fetch_df()There are lots of examples of the
to_*naming convention as well: