kosiew commented on code in PR #22608:
URL: https://github.com/apache/datafusion/pull/22608#discussion_r3332864389
##########
datafusion/ffi/src/udf/mod.rs:
##########
@@ -91,6 +92,14 @@ pub struct FFI_ScalarUDF {
arg_types: SVec<WrappedSchema>,
) -> FFI_Result<SVec<WrappedSchema>>,
+ /// FFI equivalent to the `placement` of a [`ScalarUDFImpl`]. Returns the
+ /// placement hint for the underlying [`ScalarUDF`] given each argument's
+ /// placement. Infallible, so it returns the value directly, not an
`FFI_Result`.
+ pub placement: unsafe extern "C" fn(
Review Comment:
Adding `placement` changes the layout of the `#[repr(C)]` `FFI_ScalarUDF`
struct. I only see the `ffi` label on this PR right now, but this also looks
like an API/ABI change for downstream FFI consumers. Could you please add the
`api change` label before merge so users are aware they will need to recompile
against the updated ABI?
##########
datafusion/ffi/src/placement.rs:
##########
@@ -0,0 +1,72 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use datafusion_expr::ExpressionPlacement;
+
+#[expect(non_camel_case_types)]
+#[repr(u8)]
+#[derive(Debug, Clone)]
Review Comment:
Small cleanup suggestion: since `FFI_ExpressionPlacement` is a tiny
`#[repr(u8)]` enum, it could derive `Copy` and implement
`From<FFI_ExpressionPlacement> for ExpressionPlacement`. That would let call
sites convert by value and avoid patterns like `(&result).into()`. Something
along the lines of `#[derive(Debug, Clone, Copy, PartialEq, Eq)]` plus a
by-value `From` impl would simplify the conversion code a bit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]