mod aggregate;
mod builtin;
mod index;
mod macros;
mod method;
mod projection;
mod registry;
mod signature;
use std::fmt::Debug;
pub use aggregate::{Accumulator, AggregateFunction};
use anyhow::Result;
pub use index::{
IndexContext, IndexContextKind, IndexFunction, KnnContext, MatchInfo, MatchesContext,
};
pub use method::MethodDescriptor;
pub use projection::ProjectionFunction;
pub use registry::FunctionRegistry;
pub use signature::Signature;
use crate::exec::physical_expr::EvalContext;
use crate::exec::{BoxFut, SendSyncRequirement};
use crate::expr::Kind;
use crate::val::Value;
pub trait ScalarFunction: SendSyncRequirement + Debug {
fn name(&self) -> &'static str;
#[allow(unused)]
fn signature(&self) -> Signature;
#[allow(unused)]
fn return_type(&self, _arg_types: &[Kind]) -> Result<Kind> {
Ok(self.signature().returns)
}
fn required_context(&self) -> crate::exec::ContextLevel {
crate::exec::ContextLevel::Root
}
fn is_pure(&self) -> bool {
true
}
fn is_async(&self) -> bool {
false
}
fn invoke(&self, _args: Vec<Value>) -> Result<Value> {
Err(anyhow::anyhow!("Function '{}' requires context or async execution", self.name()))
}
#[allow(unused_variables)]
fn invoke_async<'a>(
&'a self,
ctx: &'a EvalContext<'_>,
args: Vec<Value>,
) -> BoxFut<'a, Result<Value>> {
Box::pin(async move { self.invoke(args) })
}
}