API Review: Apache Arrow Support in Bulk Copy #669
Replies: 10 comments 2 replies
-
|
Adding @amachanic @jschuba for any feedback. |
Beta Was this translation helpful? Give feedback.
-
|
Adding @oscarrobertson who had opened this issue #551 |
Beta Was this translation helpful? Give feedback.
-
|
Q1: I'd go with Q3: |
Beta Was this translation helpful? Give feedback.
-
|
i don't care either way, just give us arrow :) |
Beta Was this translation helpful? Give feedback.
-
|
Overloading the existing |
Beta Was this translation helpful? Give feedback.
-
|
I'm with @djouallah :D (also agree with @azhangd ) For users this really makes no difference, especially given how new this lib is, it's tough to have a strong opinion either way. If I were a maintainer I'd probably lean towards |
Beta Was this translation helpful? Give feedback.
-
|
I vote for one method: As a user, if a library has multiple methods that do the same thing and only differ by their input type, I find this annoying. I usually end up writing my own little wrapper function that takes any valid object and dispatches it to the appropriate library method. However, I agree with the other comment that if the methods actually differ meaningfully (eg the arrow path takes more/different arguments) then they should be different functions. |
Beta Was this translation helpful? Give feedback.
-
|
At first I was Team |
Beta Was this translation helpful? Give feedback.
-
|
Thank you all for the thoughtful feedback here. After an internal discussion and weighing the suggestions raised on this thread, we've decided to go with the dedicated bulkcopy_arrow() API (Option A). Thanks again, everyone. 🙂 |
Beta Was this translation helpful? Give feedback.
-
|
Although, already discussed with Saumya internally - felt like adding my view point here. To me, dedicated bulkcopy_arrow() is safer because Arrow inputs have different validation rules (schema, nullability, type coercion) than tuple-row inputs, so errors can be precise instead of mixed. A separate API gives cleaner compatibility/versioning promises as Arrow protocol support evolves independently from existing bulkcopy() behavior. From future integration perspective which other reviewers have already written about, I feel bulkcopy_arrow() makes more sense. |
Beta Was this translation helpful? Give feedback.
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