2010YOUY01 commented on code in PR #7978:
URL: https://github.com/apache/arrow-datafusion/pull/7978#discussion_r1378387482
##########
datafusion/expr/src/udf.rs:
##########
@@ -17,12 +17,67 @@
//! Udf module contains foundational types that are used to represent UDFs in
DataFusion.
-use crate::{Expr, ReturnTypeFunction, ScalarFunctionImplementation, Signature};
+use crate::{
+ ColumnarValue, Expr, FuncMonotonicity, ReturnTypeFunction,
+ ScalarFunctionImplementation, Signature, TypeSignature, Volatility,
+};
+use arrow::array::ArrayRef;
+use arrow::datatypes::DataType;
+use datafusion_common::{internal_err, DataFusionError, Result};
+use std::any::Any;
use std::fmt;
use std::fmt::Debug;
use std::fmt::Formatter;
use std::sync::Arc;
+// TODO(PR): add doc comments
+pub trait ScalarFunctionDef: Any + Sync + Send + std::fmt::Debug {
+ /// Return as [`Any`] so that it can be
+ /// downcast to a specific implementation.
+ fn as_any(&self) -> &dyn Any;
+
+ // May return 1 or more name as aliasing
+ fn name(&self) -> &[&str];
+
+ fn input_type(&self) -> TypeSignature;
+
+ fn return_type(&self) -> FunctionReturnType;
+
+ fn execute(&self, _args: &[ArrayRef]) -> Result<ArrayRef> {
+ internal_err!("This method should be implemented if
`supports_execute_raw()` returns `false`")
+ }
+
+ fn volatility(&self) -> Volatility;
+
+ fn monotonicity(&self) -> Option<FuncMonotonicity>;
+
+ // ===============================
+ // OPTIONAL METHODS START BELOW
+ // ===============================
+
+ /// `execute()` and `execute_raw()` are two possible alternative for
function definition:
+ /// If returns `false`, `execute()` will be used for execution;
+ /// If returns `true`, `execute_raw()` will be called.
+ fn use_execute_raw_instead(&self) -> bool {
Review Comment:
I agree we should make the initial implementation concise
--
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]