risingwave_expr::sig

Trait UdfImpl

source
pub trait UdfImpl:
    Debug
    + Send
    + Sync {
    // Required methods
    fn call<'life0, 'life1, 'async_trait>(
        &'life0 self,
        input: &'life1 RecordBatch,
    ) -> Pin<Box<dyn Future<Output = Result<RecordBatch>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn call_table_function<'a, 'async_trait>(
        &'a self,
        input: &'a RecordBatch,
    ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, Result<RecordBatch>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait;

    // Provided methods
    fn call_agg_create_state(&self) -> Result<ArrayRef> { ... }
    fn call_agg_accumulate_or_retract(
        &self,
        _state: &ArrayRef,
        _ops: &BooleanArray,
        _input: &RecordBatch,
    ) -> Result<ArrayRef> { ... }
    fn call_agg_finish(&self, _state: &ArrayRef) -> Result<ArrayRef> { ... }
    fn is_legacy(&self) -> bool { ... }
    fn memory_usage(&self) -> usize { ... }
}
Expand description

UDF implementation.

Required Methods§

source

fn call<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 RecordBatch, ) -> Pin<Box<dyn Future<Output = Result<RecordBatch>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Call the scalar function.

source

fn call_table_function<'a, 'async_trait>( &'a self, input: &'a RecordBatch, ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, Result<RecordBatch>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Call the table function.

Provided Methods§

source

fn call_agg_create_state(&self) -> Result<ArrayRef>

For aggregate function, create the initial state.

source

fn call_agg_accumulate_or_retract( &self, _state: &ArrayRef, _ops: &BooleanArray, _input: &RecordBatch, ) -> Result<ArrayRef>

For aggregate function, accumulate or retract the state.

source

fn call_agg_finish(&self, _state: &ArrayRef) -> Result<ArrayRef>

For aggregate function, get aggregate result from the state.

source

fn is_legacy(&self) -> bool

Whether the UDF talks in legacy mode.

If true, decimal and jsonb types are mapped to Arrow LargeBinary and LargeUtf8 types. Otherwise, they are mapped to Arrow extension types. See https://github.com/risingwavelabs/arrow-udf/tree/main#extension-types.

source

fn memory_usage(&self) -> usize

Return the memory size consumed by UDF runtime in bytes.

If not available, return 0.

Implementors§