Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc()]\nfn unary_fn<'a>(a: Datum<'a>) -> bool {\n unimplem
mz_lowertest::MzReflect
)]
pub struct UnaryFn;
impl<'a> crate::func::EagerUnaryFunc<'a> for UnaryFn {
type Input = Datum<'a>;
type Output = bool;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for UnaryFn {
type Input<'a> = Datum<'a>;
type Output<'a> = bool;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
unary_fn(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc()]\nfn unary_fn<'a>(a: &i16) -> bool {\n unimplemented
mz_lowertest::MzReflect
)]
pub struct UnaryFn;
impl<'a> crate::func::EagerUnaryFunc<'a> for UnaryFn {
type Input = &'a i16;
type Output = bool;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for UnaryFn {
type Input<'a> = &'a i16;
type Output<'a> = bool;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
unary_fn(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
8 changes: 4 additions & 4 deletions src/expr-derive-impl/src/sqlfunc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,11 @@ fn unary_func(func: &syn::ItemFn, modifiers: Modifiers) -> darling::Result<Token
#[derive(proptest_derive::Arbitrary, Ord, PartialOrd, Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, Hash, mz_lowertest::MzReflect)]
pub struct #struct_name;

impl<'a> crate::func::EagerUnaryFunc<'a> for #struct_name {
type Input = #input_ty;
type Output = #output_ty;
impl crate::func::EagerUnaryFunc for #struct_name {
type Input<'a> = #input_ty;
type Output<'a> = #output_ty;

fn call(&self, a: Self::Input) -> Self::Output {
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
#fn_name(a)
}

Expand Down
8 changes: 4 additions & 4 deletions src/expr/src/scalar/func/impls/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ pub struct PadChar {
pub length: Option<CharLength>,
}

impl<'a> EagerUnaryFunc<'a> for PadChar {
type Input = &'a str;
type Output = Char<String>;
impl EagerUnaryFunc for PadChar {
type Input<'a> = &'a str;
type Output<'a> = Char<String>;

fn call(&self, a: &'a str) -> Char<String> {
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
Char(format_str_pad(a, self.length))
}

Expand Down
24 changes: 12 additions & 12 deletions src/expr/src/scalar/func/impls/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ fn cast_date_to_string(a: Date) -> String {
#[derive(Ord, PartialOrd, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)]
pub struct CastDateToTimestamp(pub Option<TimestampPrecision>);

impl<'a> EagerUnaryFunc<'a> for CastDateToTimestamp {
type Input = Date;
type Output = Result<CheckedTimestamp<NaiveDateTime>, EvalError>;
impl EagerUnaryFunc for CastDateToTimestamp {
type Input<'a> = Date;
type Output<'a> = Result<CheckedTimestamp<NaiveDateTime>, EvalError>;

fn call(&self, a: Date) -> Result<CheckedTimestamp<NaiveDateTime>, EvalError> {
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
let out =
CheckedTimestamp::from_timestamplike(NaiveDate::from(a).and_hms_opt(0, 0, 0).unwrap())?;
let updated = out.round_to_precision(self.0)?;
Expand Down Expand Up @@ -74,11 +74,11 @@ impl fmt::Display for CastDateToTimestamp {
#[derive(Ord, PartialOrd, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)]
pub struct CastDateToTimestampTz(pub Option<TimestampPrecision>);

impl<'a> EagerUnaryFunc<'a> for CastDateToTimestampTz {
type Input = Date;
type Output = Result<CheckedTimestamp<DateTime<Utc>>, EvalError>;
impl EagerUnaryFunc for CastDateToTimestampTz {
type Input<'a> = Date;
type Output<'a> = Result<CheckedTimestamp<DateTime<Utc>>, EvalError>;

fn call(&self, a: Date) -> Result<CheckedTimestamp<DateTime<Utc>>, EvalError> {
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
let out =
CheckedTimestamp::from_timestamplike(DateTime::<Utc>::from_naive_utc_and_offset(
NaiveDate::from(a).and_hms_opt(0, 0, 0).unwrap(),
Expand Down Expand Up @@ -146,11 +146,11 @@ pub fn extract_date_inner(units: DateTimeUnits, date: NaiveDate) -> Result<Numer
#[derive(Ord, PartialOrd, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)]
pub struct ExtractDate(pub DateTimeUnits);

impl<'a> EagerUnaryFunc<'a> for ExtractDate {
type Input = Date;
type Output = Result<Numeric, EvalError>;
impl EagerUnaryFunc for ExtractDate {
type Input<'a> = Date;
type Output<'a> = Result<Numeric, EvalError>;

fn call(&self, a: Date) -> Result<Numeric, EvalError> {
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
extract_date_inner(self.0, a.into())
}

Expand Down
8 changes: 4 additions & 4 deletions src/expr/src/scalar/func/impls/float32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ fn cast_float32_to_uint64(a: f32) -> Result<u64, EvalError> {
#[derive(Ord, PartialOrd, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)]
pub struct CastFloat32ToNumeric(pub Option<NumericMaxScale>);

impl<'a> EagerUnaryFunc<'a> for CastFloat32ToNumeric {
type Input = f32;
type Output = Result<Numeric, EvalError>;
impl EagerUnaryFunc for CastFloat32ToNumeric {
type Input<'a> = f32;
type Output<'a> = Result<Numeric, EvalError>;

fn call(&self, a: f32) -> Result<Numeric, EvalError> {
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
if a.is_infinite() {
return Err(EvalError::InfinityOutOfDomain(
"casting real to numeric".into(),
Expand Down
8 changes: 4 additions & 4 deletions src/expr/src/scalar/func/impls/float64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ fn cast_float64_to_uint64(a: f64) -> Result<u64, EvalError> {
#[derive(Ord, PartialOrd, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)]
pub struct CastFloat64ToNumeric(pub Option<NumericMaxScale>);

impl<'a> EagerUnaryFunc<'a> for CastFloat64ToNumeric {
type Input = f64;
type Output = Result<Numeric, EvalError>;
impl EagerUnaryFunc for CastFloat64ToNumeric {
type Input<'a> = f64;
type Output<'a> = Result<Numeric, EvalError>;

fn call(&self, a: f64) -> Result<Numeric, EvalError> {
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
if a.is_infinite() {
return Err(EvalError::InfinityOutOfDomain(
"casting double precision to numeric".into(),
Expand Down
8 changes: 4 additions & 4 deletions src/expr/src/scalar/func/impls/int16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ fn cast_int16_to_uint64(a: i16) -> Result<u64, EvalError> {
#[derive(Ord, PartialOrd, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)]
pub struct CastInt16ToNumeric(pub Option<NumericMaxScale>);

impl<'a> EagerUnaryFunc<'a> for CastInt16ToNumeric {
type Input = i16;
type Output = Result<Numeric, EvalError>;
impl EagerUnaryFunc for CastInt16ToNumeric {
type Input<'a> = i16;
type Output<'a> = Result<Numeric, EvalError>;

fn call(&self, a: i16) -> Result<Numeric, EvalError> {
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
let mut a = Numeric::from(i32::from(a));
if let Some(scale) = self.0 {
if numeric::rescale(&mut a, scale.into_u8()).is_err() {
Expand Down
8 changes: 4 additions & 4 deletions src/expr/src/scalar/func/impls/int32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ fn cast_int32_to_uint64(a: i32) -> Result<u64, EvalError> {
#[derive(Ord, PartialOrd, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)]
pub struct CastInt32ToNumeric(pub Option<NumericMaxScale>);

impl<'a> EagerUnaryFunc<'a> for CastInt32ToNumeric {
type Input = i32;
type Output = Result<Numeric, EvalError>;
impl EagerUnaryFunc for CastInt32ToNumeric {
type Input<'a> = i32;
type Output<'a> = Result<Numeric, EvalError>;

fn call(&self, a: i32) -> Result<Numeric, EvalError> {
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
let mut a = Numeric::from(a);
if let Some(scale) = self.0 {
if numeric::rescale(&mut a, scale.into_u8()).is_err() {
Expand Down
8 changes: 4 additions & 4 deletions src/expr/src/scalar/func/impls/int64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ fn cast_int64_to_uint64(a: i64) -> Result<u64, EvalError> {
#[derive(Ord, PartialOrd, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)]
pub struct CastInt64ToNumeric(pub Option<NumericMaxScale>);

impl<'a> EagerUnaryFunc<'a> for CastInt64ToNumeric {
type Input = i64;
type Output = Result<Numeric, EvalError>;
impl EagerUnaryFunc for CastInt64ToNumeric {
type Input<'a> = i64;
type Output<'a> = Result<Numeric, EvalError>;

fn call(&self, a: i64) -> Result<Numeric, EvalError> {
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
let mut a = Numeric::from(a);
if let Some(scale) = self.0 {
if numeric::rescale(&mut a, scale.into_u8()).is_err() {
Expand Down
8 changes: 4 additions & 4 deletions src/expr/src/scalar/func/impls/jsonb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ fn cast_jsonb_to_float64<'a>(a: JsonbRef<'a>) -> Result<f64, EvalError> {
#[derive(Ord, PartialOrd, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)]
pub struct CastJsonbToNumeric(pub Option<NumericMaxScale>);

impl<'a> EagerUnaryFunc<'a> for CastJsonbToNumeric {
type Input = JsonbRef<'a>;
type Output = Result<Numeric, EvalError>;
impl EagerUnaryFunc for CastJsonbToNumeric {
type Input<'a> = JsonbRef<'a>;
type Output<'a> = Result<Numeric, EvalError>;

fn call(&self, a: JsonbRef<'a>) -> Result<Numeric, EvalError> {
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
match a.into_datum() {
Datum::Numeric(mut num) => match self.0 {
None => Ok(num.into_inner()),
Expand Down
8 changes: 4 additions & 4 deletions src/expr/src/scalar/func/impls/numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ fn pg_size_pretty(mut a: Numeric) -> Result<String, EvalError> {
#[derive(Ord, PartialOrd, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash, MzReflect)]
pub struct AdjustNumericScale(pub NumericMaxScale);

impl<'a> EagerUnaryFunc<'a> for AdjustNumericScale {
type Input = Numeric;
type Output = Result<Numeric, EvalError>;
impl EagerUnaryFunc for AdjustNumericScale {
type Input<'a> = Numeric;
type Output<'a> = Result<Numeric, EvalError>;

fn call(&self, mut d: Numeric) -> Result<Numeric, EvalError> {
fn call<'a>(&self, mut d: Self::Input<'a>) -> Self::Output<'a> {
if numeric::rescale(&mut d, self.0.into_u8()).is_err() {
return Err(EvalError::NumericFieldOverflow);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc(\n sqlname = \"boolean_to_integer\",\n preserves_un
mz_lowertest::MzReflect
)]
pub struct CastBoolToInt32;
impl<'a> crate::func::EagerUnaryFunc<'a> for CastBoolToInt32 {
type Input = bool;
type Output = i32;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for CastBoolToInt32 {
type Input<'a> = bool;
type Output<'a> = i32;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
cast_bool_to_int32(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc(\n sqlname = \"boolean_to_bigint\",\n preserves_uni
mz_lowertest::MzReflect
)]
pub struct CastBoolToInt64;
impl<'a> crate::func::EagerUnaryFunc<'a> for CastBoolToInt64 {
type Input = bool;
type Output = i64;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for CastBoolToInt64 {
type Input<'a> = bool;
type Output<'a> = i64;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
cast_bool_to_int64(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc(\n sqlname = \"boolean_to_text\",\n preserves_uniqu
mz_lowertest::MzReflect
)]
pub struct CastBoolToString;
impl<'a> crate::func::EagerUnaryFunc<'a> for CastBoolToString {
type Input = bool;
type Output = &'a str;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for CastBoolToString {
type Input<'a> = bool;
type Output<'a> = &'a str;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
cast_bool_to_string(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc(\n sqlname = \"boolean_to_nonstandard_text\",\n pre
mz_lowertest::MzReflect
)]
pub struct CastBoolToStringNonstandard;
impl<'a> crate::func::EagerUnaryFunc<'a> for CastBoolToStringNonstandard {
type Input = bool;
type Output = &'a str;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for CastBoolToStringNonstandard {
type Input<'a> = bool;
type Output<'a> = &'a str;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
cast_bool_to_string_nonstandard(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc(\n sqlname = \"NOT\",\n preserves_uniqueness = true
mz_lowertest::MzReflect
)]
pub struct Not;
impl<'a> crate::func::EagerUnaryFunc<'a> for Not {
type Input = bool;
type Output = bool;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for Not {
type Input<'a> = bool;
type Output<'a> = bool;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
not(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc(sqlname = \"bit_count\")]\nfn bit_count_bytes<'a>(a: &'a
mz_lowertest::MzReflect
)]
pub struct BitCountBytes;
impl<'a> crate::func::EagerUnaryFunc<'a> for BitCountBytes {
type Input = &'a [u8];
type Output = Result<i64, EvalError>;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for BitCountBytes {
type Input<'a> = &'a [u8];
type Output<'a> = Result<i64, EvalError>;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
bit_count_bytes(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc(sqlname = \"bit_length\")]\nfn bit_length_bytes<'a>(a: &'
mz_lowertest::MzReflect
)]
pub struct BitLengthBytes;
impl<'a> crate::func::EagerUnaryFunc<'a> for BitLengthBytes {
type Input = &'a [u8];
type Output = Result<i32, EvalError>;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for BitLengthBytes {
type Input<'a> = &'a [u8];
type Output<'a> = Result<i32, EvalError>;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
bit_length_bytes(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc(sqlname = \"octet_length\")]\nfn byte_length_bytes<'a>(a:
mz_lowertest::MzReflect
)]
pub struct ByteLengthBytes;
impl<'a> crate::func::EagerUnaryFunc<'a> for ByteLengthBytes {
type Input = &'a [u8];
type Output = Result<i32, EvalError>;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for ByteLengthBytes {
type Input<'a> = &'a [u8];
type Output<'a> = Result<i32, EvalError>;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
byte_length_bytes(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc(\n sqlname = \"bytea_to_text\",\n preserves_uniquen
mz_lowertest::MzReflect
)]
pub struct CastBytesToString;
impl<'a> crate::func::EagerUnaryFunc<'a> for CastBytesToString {
type Input = &'a [u8];
type Output = String;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for CastBytesToString {
type Input<'a> = &'a [u8];
type Output<'a> = String;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
cast_bytes_to_string(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc(sqlname = \"crc32_bytes\")]\nfn crc32_bytes<'a>(a: &'a [u
mz_lowertest::MzReflect
)]
pub struct Crc32Bytes;
impl<'a> crate::func::EagerUnaryFunc<'a> for Crc32Bytes {
type Input = &'a [u8];
type Output = u32;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for Crc32Bytes {
type Input<'a> = &'a [u8];
type Output<'a> = u32;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
crc32_bytes(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ expression: "#[sqlfunc(sqlname = \"crc32_string\")]\nfn crc32_string<'a>(a: &'a
mz_lowertest::MzReflect
)]
pub struct Crc32String;
impl<'a> crate::func::EagerUnaryFunc<'a> for Crc32String {
type Input = &'a str;
type Output = u32;
fn call(&self, a: Self::Input) -> Self::Output {
impl crate::func::EagerUnaryFunc for Crc32String {
type Input<'a> = &'a str;
type Output<'a> = u32;
fn call<'a>(&self, a: Self::Input<'a>) -> Self::Output<'a> {
crc32_string(a)
}
fn output_type(&self, input_type: mz_repr::SqlColumnType) -> mz_repr::SqlColumnType {
Expand Down
Loading