You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Perf: Allow User defined functions to potentially reuse their argument arrays (to avoid new allocations) #13516
Is your feature request related to a problem or challenge?
Arrow Arrays are designed to be immutable and use shared references extensively, but it is possible to reuse the underlying buffer in some cases when there are no other references (see the arrow unary_mut kernel for example)
At the time of writing, DataFusion scalar functions (ScalarFunctionImpl must always allocate a new array when generating output. They can not reuse the existing underlying memory, even if the source array will never be used again
This is because the invoke signature gets the arguments as reference (slice of ColumnarValue) rather than by ownership
Activity
alamb commentedon Nov 23, 2024
I think @joseph-isaacs has done this in #13491
findepi commentedon Nov 23, 2024
For closing this issue could we have an example showing how to do this reuse and proving that it really takes place?
Is this maybe part of #13491?
alamb commentedon Nov 23, 2024
This is a good idea -- I agree an example should be written
Omega359 commentedon Dec 2, 2024
Are you sure? I took a look at ScalarFunctionArgs in main and it seems to use
&'a [ColumnarValue]alamb commentedon Dec 2, 2024
Good call @Omega359 -- I think it was removed eventually. I'll try and make the change with an example over the next few days/weeks
alamb commentedon Dec 4, 2024
Here is a PR that implements the change and adds an example:
ScalarFunctionArgsgets ownedColumnReference) #13637