[DISCUSSION] Better borrow propagation (e.g. RecordBatch::schema()
to return &SchemaRef
vs SchemaRef
)
#5463
Labels
arrow
Changes to the arrow crate
arrow-flight
Changes to the arrow-flight crate
enhancement
Any new improvement worthy of a entry in the changelog
parquet
Changes to the parquet crate
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
For reasons I am not sure of (likely historical), certain APIs of
Schema
/RecordBatch
return owned instances ofSchemaRef
.So for example
There are at least two challenges here:
Arc::clone
which is relatively inexpensive compared to the work done by most Arrow apis)An example of challenges with borrow propagation is illustrated on #5342, which observes, we can't change
Schema::try_merge
to take (&Schema
) even when it doesn't actually need owned ownership of theSchema
without creating a temporaryVec<SchemaRef>
or something similiarDescribe the solution you'd like
I recommend we add new functions that return a reference to the
SchemaRef
So new functions like
Describe alternatives you've considered
One alternative is to change the existing APIs as proposed in #5448
However I think this requires a substantial amount of downstream code change (as explained on #5448 (review))
Additional context
This came up recently on #5342
@tustvold notes we have made similar changes in the past, e.g. #2035 and #313
The text was updated successfully, but these errors were encountered: