Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Nov 20, 2024

Builds on #13290 from @joseph-isaacs

Which issue does this PR close?

Rationale for this change

If we are going to change the signature of invoke I would to make it possible in the future to reuse allocations -- at the moment the API requires creating new arrays even when the input array is not used because the functions get the input as &[ColumnarValues] meaning they don't own them (the caller retains a reference)

What changes are included in this PR?

Change ScalarFunctionArgs to pass by value

1,

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates functions Changes to functions implementation labels Nov 20, 2024
// evaluate the function
let output = self.fun.invoke_batch(&inputs, batch.num_rows())?;
let output = self.fun.invoke_with_args(ScalarFunctionArgs {
args: inputs,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the whole point of this PR is to pass in inputs here rather than inputs.as_ref

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we should probably consider doing the same thing for evaluate 🤔

@findepi
Copy link
Member

findepi commented Nov 23, 2024

Can we have one example function doing that, with some tests proving this indeed works?

@alamb
Copy link
Contributor Author

alamb commented Dec 6, 2024

Can we have one example function doing that, with some tests proving this indeed works?

Just OCD following up here, there is an example / tests in this PR:

@alamb alamb deleted the alamb/arg_improvements branch December 6, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Perf: Allow User defined functions to potentially reuse their argument arrays (to avoid new allocations)

3 participants