mz_expr/scalar/func/impls/
int2vector.rs1use mz_expr_derive::sqlfunc;
11use mz_repr::adt::array::Array;
12use mz_repr::{Datum, Int2Vector, SqlScalarType};
13
14use crate::EvalError;
15use crate::scalar::func::stringify_datum;
16
17#[sqlfunc(
18 sqlname = "int2vectortoarray",
19 is_monotone = true,
20 output_type_expr = SqlScalarType::Array(Box::from(SqlScalarType::Int16))
21 .nullable(input_type.nullable)
22)]
23fn cast_int2_vector_to_array<'a>(a: Int2Vector<'a>) -> Array<'a> {
24 a.0
25}
26
27#[sqlfunc(
28 sqlname = "int2vectortostr",
29 preserves_uniqueness = true,
30 inverse = super::CastStringToInt2Vector
31)]
32fn cast_int2_vector_to_string<'a>(a: Int2Vector<'a>) -> Result<String, EvalError> {
33 let mut buf = String::new();
34 stringify_datum(&mut buf, Datum::Array(a.0), &SqlScalarType::Int2Vector)?;
35 Ok(buf)
36}