Skip to content
Closed
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
10 changes: 5 additions & 5 deletions src/compute-types/tests/snapshots/func_registry.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/compute-types/tests/snapshots/func_registry_source.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/expr/src/scalar/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,12 @@ func_name! {
CastTimestampToTimestampTz => "cast_timestamp_to_timestamp_tz",
CastTimestampTzToTimestamp => "cast_timestamp_tz_to_timestamp",
DatePartInterval => "date_part_interval",
DatePartTime => "date_part_time",
DatePartTimestamp => "date_part_timestamp",
DatePartTimestampTz => "date_part_timestamp_tz",
DateTruncTimestamp => "date_trunc_timestamp",
DateTruncTimestampTz => "date_trunc_timestamp_tz",
variadic::ErrorIfNull => "error_if_null",
ExtractInterval => "extract_interval",
ExtractTime => "extract_time",
ExtractTimestamp => "extract_timestamp",
ExtractTimestampTz => "extract_timestamp_tz",
IsLikeMatch => "is_like_match",
Expand All @@ -177,7 +175,6 @@ func_name! {
RegexpMatch => "regexp_match",
RegexpReplace => "regexp_replace",
RegexpSplitToArray => "regexp_split_to_array",
TimezoneTime => "timezone_time",
TimezoneTimestamp => "timezone_timestamp",
TimezoneTimestampTz => "timezone_timestamp_tz",
ToCharTimestamp => "to_char_timestamp",
Expand Down
46 changes: 11 additions & 35 deletions src/expr/src/scalar/func/impls/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ use mz_repr::adt::datetime::{DateTimeField, DateTimeUnits};
use mz_repr::adt::interval::Interval;
use mz_repr::adt::numeric::{DecimalLike, Numeric};
use mz_repr::adt::timestamp::TimeLike;
use mz_repr::{RowArena, SqlColumnType, SqlScalarType, strconv};
use mz_repr::strconv;
use serde::{Deserialize, Serialize};

use crate::EvalError;
use crate::scalar::func::EagerUnaryFunc;

#[sqlfunc(
sqlname = "time_to_text",
Expand Down Expand Up @@ -99,17 +98,9 @@ where
)]
pub struct ExtractTime(pub DateTimeUnits);

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

fn call<'a>(&self, a: Self::Input<'a>, _temp_storage: &'a RowArena) -> Self::Output<'a> {
date_part_time_inner(self.0, a)
}

fn output_sql_type(&self, input: SqlColumnType) -> SqlColumnType {
SqlScalarType::Numeric { max_scale: None }.nullable(input.nullable)
}
#[sqlfunc(ExtractTime, skip_display = true)]
fn extract_time(&self, a: NaiveTime) -> Result<Numeric, EvalError> {
date_part_time_inner(self.0, a)
}

impl fmt::Display for ExtractTime {
Expand All @@ -131,17 +122,9 @@ impl fmt::Display for ExtractTime {
)]
pub struct DatePartTime(pub DateTimeUnits);

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

fn call<'a>(&self, a: Self::Input<'a>, _temp_storage: &'a RowArena) -> Self::Output<'a> {
date_part_time_inner(self.0, a)
}

fn output_sql_type(&self, input: SqlColumnType) -> SqlColumnType {
SqlScalarType::Float64.nullable(input.nullable)
}
#[sqlfunc(DatePartTime, skip_display = true)]
fn date_part_time(&self, a: NaiveTime) -> Result<f64, EvalError> {
date_part_time_inner(self.0, a)
}

impl fmt::Display for DatePartTime {
Expand Down Expand Up @@ -176,17 +159,10 @@ pub struct TimezoneTime {
pub wall_time: NaiveDateTime,
}

impl EagerUnaryFunc for TimezoneTime {
type Input<'a> = NaiveTime;
type Output<'a> = NaiveTime;

fn call<'a>(&self, a: Self::Input<'a>, _temp_storage: &'a RowArena) -> Self::Output<'a> {
timezone_time(self.tz, a, &self.wall_time)
}

fn output_sql_type(&self, input: SqlColumnType) -> SqlColumnType {
SqlScalarType::Time.nullable(input.nullable)
}
#[sqlfunc(TimezoneTime, skip_display = true)]
fn timezone_time(&self, a: NaiveTime) -> NaiveTime {
// NOTE: `self::` reaches the free function of the same name, not this method.
self::timezone_time(self.tz, a, &self.wall_time)
}

impl fmt::Display for TimezoneTime {
Expand Down
Loading