MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / eval

Method eval

src/expr/src/scalar/func/binary.rs:129–154  ·  view source on GitHub ↗
(
        &'a self,
        datums: &[Datum<'a>],
        temp_storage: &'a RowArena,
        exprs: &[&'a impl Eval],
    )

Source from the content-addressed store, hash-verified

127
128impl<T: EagerBinaryFunc> LazyBinaryFunc for T {
129 fn eval<'a>(
130 &'a self,
131 datums: &[Datum<'a>],
132 temp_storage: &'a RowArena,
133 exprs: &[&'a impl Eval],
134 ) -> Result<Datum<'a>, EvalError> {
135 let mut datums = exprs
136 .into_iter()
137 .map(|expr| expr.eval(datums, temp_storage));
138 let input = match T::Input::try_from_iter(&mut datums) {
139 // If we can convert to the input type then we call the function
140 Ok(input) => input,
141 // If we can't and we got a non-null datum something went wrong in the planner
142 Err(Ok(Some(datum))) if !datum.is_null() => {
143 return Err(EvalError::Internal("invalid input type".into()));
144 }
145 Err(Ok(None)) => {
146 return Err(EvalError::Internal("unexpectedly missing parameter".into()));
147 }
148 // Otherwise we just propagate NULLs and errors
149 Err(Ok(Some(datum))) => return Ok(datum),
150 Err(Err(res)) => return Err(res),
151 };
152 assert_none!(datums.next(), "No leftover input arguments");
153 self.call(input, temp_storage).into_result(temp_storage)
154 }
155
156 fn output_sql_type(&self, input_types: &[SqlColumnType]) -> SqlColumnType {
157 self.output_sql_type(input_types)

Callers

nothing calls this directly

Calls 5

mapMethod · 0.45
into_iterMethod · 0.45
is_nullMethod · 0.45
into_resultMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected