API Review: Apache Arrow Support in Bulk Copy #669
gargsaumya
started this conversation in
General
Replies: 2 comments
-
|
Adding @amachanic @jschuba for any feedback. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Adding @oscarrobertson who had opened this issue #551 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Apache Arrow Support in Bulk Copy
We are working on native Apache Arrow support for bulk copy and would like to align on the public API design before implementation.
The primary question is whether Arrow ingestion should be exposed as:
bulkcopy_arrow()method, orbulkcopy()API that accepts Arrow sources in addition to row iterators.Motivation
Today,
Cursor.bulkcopy()accepts an iterable of Python tuples orRowobjects. Users who already hold data in an Arrow-based format (PyArrow, Polars, DuckDB, etc.) must first materialize that data into Python objects before bulk loading.Allowing Arrow batches to be passed directly through the Arrow C Data Interface would eliminate that per-row materialization overhead. This is purely additive functionality.
Option A: Dedicated
bulkcopy_arrow()Pros
Cons
Option B: Extend
bulkcopy()to Accept Arrow SourcesAllow
bulkcopy()to accept either a traditional row iterator or an Arrow source.Pros
column_mappings,batch_size,keep_identity, etc.) remain unchanged.Cons
Design Considerations
Column Mapping
column_mappingsis already optional inbulkcopy()and defaults to ordinal mapping. The same behavior can naturally apply to Arrow sources, so column mapping alone does not justify a separate API.Input Ambiguity
If we unify the API, we need to distinguish:
from
Potential approaches include:
Performance
Performance should not influence the API choice. Both approaches would use the same underlying implementation and differ only in the public surface area.
Open Questions
bulkcopy_arrow()API or a unifiedbulkcopy()that also accepts Arrow sources?bulkcopy_arrow(), or expectbulkcopy()to work directly with Arrow objects?I'd appreciate feedback before implementation begins.
cc: @saurabh500 @dlevy-msft-sql @sumitmsft
Beta Was this translation helpful? Give feedback.
All reactions