#[repr(transparent)]pub struct Timestamp(pub NaiveDateTime);
Tuple Fields§
§0: NaiveDateTime
Implementations§
source§impl Timestamp
impl Timestamp
pub fn with_secs_nsecs( secs: i64, nsecs: u32, ) -> Result<Self, InvalidParamsError>
pub fn from_protobuf(cur: &mut Cursor<&[u8]>) -> ArrayResult<Timestamp>
sourcepub fn to_protobuf<T: Write>(self, output: &mut T) -> ArrayResult<usize>
pub fn to_protobuf<T: Write>(self, output: &mut T) -> ArrayResult<usize>
Although Timestamp
takes 12 bytes, we drop 4 bytes in protobuf encoding.
pub fn get_timestamp_nanos(&self) -> i64
pub fn with_millis(timestamp_millis: i64) -> Result<Self, InvalidParamsError>
pub fn with_micros(timestamp_micros: i64) -> Result<Self, InvalidParamsError>
pub fn from_timestamp_uncheck(secs: i64, nsecs: u32) -> Self
sourcepub fn truncate_micros(self) -> Self
pub fn truncate_micros(self) -> Self
Truncate the timestamp to the precision of microseconds.
§Example
let ts = "2001-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_micros().to_string(),
"2001-05-16 20:38:40.123456"
);
sourcepub fn truncate_millis(self) -> Self
pub fn truncate_millis(self) -> Self
Truncate the timestamp to the precision of milliseconds.
§Example
let ts = "2001-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_millis().to_string(),
"2001-05-16 20:38:40.123"
);
sourcepub fn truncate_second(self) -> Self
pub fn truncate_second(self) -> Self
Truncate the timestamp to the precision of seconds.
§Example
let ts = "2001-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_second().to_string(),
"2001-05-16 20:38:40"
);
sourcepub fn truncate_minute(self) -> Self
pub fn truncate_minute(self) -> Self
Truncate the timestamp to the precision of minutes.
§Example
let ts = "2001-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_minute().to_string(),
"2001-05-16 20:38:00"
);
sourcepub fn truncate_hour(self) -> Self
pub fn truncate_hour(self) -> Self
Truncate the timestamp to the precision of hours.
§Example
let ts = "2001-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_hour().to_string(),
"2001-05-16 20:00:00"
);
sourcepub fn truncate_day(self) -> Self
pub fn truncate_day(self) -> Self
Truncate the timestamp to the precision of days.
§Example
let ts = "2001-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_day().to_string(),
"2001-05-16 00:00:00"
);
sourcepub fn truncate_week(self) -> Self
pub fn truncate_week(self) -> Self
Truncate the timestamp to the precision of weeks.
§Example
let ts = "2001-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_week().to_string(),
"2001-05-14 00:00:00"
);
sourcepub fn truncate_month(self) -> Self
pub fn truncate_month(self) -> Self
Truncate the timestamp to the precision of months.
§Example
let ts = "2001-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_month().to_string(),
"2001-05-01 00:00:00"
);
sourcepub fn truncate_quarter(self) -> Self
pub fn truncate_quarter(self) -> Self
Truncate the timestamp to the precision of quarters.
§Example
let ts = "2001-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_quarter().to_string(),
"2001-04-01 00:00:00"
);
sourcepub fn truncate_year(self) -> Self
pub fn truncate_year(self) -> Self
Truncate the timestamp to the precision of years.
§Example
let ts = "2001-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_year().to_string(),
"2001-01-01 00:00:00"
);
sourcepub fn truncate_decade(self) -> Self
pub fn truncate_decade(self) -> Self
Truncate the timestamp to the precision of decades.
§Example
let ts = "2001-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_decade().to_string(),
"2000-01-01 00:00:00"
);
sourcepub fn truncate_century(self) -> Self
pub fn truncate_century(self) -> Self
Truncate the timestamp to the precision of centuries.
§Example
let ts = "3202-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_century().to_string(),
"3201-01-01 00:00:00"
);
sourcepub fn truncate_millennium(self) -> Self
pub fn truncate_millennium(self) -> Self
Truncate the timestamp to the precision of millenniums.
§Example
let ts = "3202-05-16T20:38:40.123456789".parse().unwrap();
assert_eq!(
Timestamp::new(ts).truncate_millennium().to_string(),
"3001-01-01 00:00:00"
);
Trait Implementations§
source§impl CheckedAdd<Interval> for Timestamp
impl CheckedAdd<Interval> for Timestamp
source§impl ChronoFieldInner for Timestamp
impl ChronoFieldInner for Timestamp
source§impl From<NaiveDateTime> for Timestamp
impl From<NaiveDateTime> for Timestamp
source§fn from(data: NaiveDateTime) -> Self
fn from(data: NaiveDateTime) -> Self
source§impl From<Timestamp> for Date
impl From<Timestamp> for Date
In PostgreSQL
, casting from timestamp to date discards the time part.
§Example
use std::str::FromStr;
use risingwave_common::types::{Date, Timestamp};
let ts = Timestamp::from_str("1999-01-08 04:02").unwrap();
let date = Date::from(ts);
assert_eq!(date, Date::from_str("1999-01-08").unwrap());
source§impl From<Timestamp> for ScalarImpl
impl From<Timestamp> for ScalarImpl
source§impl<'scalar> From<Timestamp> for ScalarRefImpl<'scalar>
impl<'scalar> From<Timestamp> for ScalarRefImpl<'scalar>
source§impl From<Timestamp> for Time
impl From<Timestamp> for Time
In PostgreSQL
, casting from timestamp to time discards the date part.
§Example
use std::str::FromStr;
use risingwave_common::types::{Time, Timestamp};
let ts = Timestamp::from_str("1999-01-08 04:02").unwrap();
let time = Time::from(ts);
assert_eq!(time, Time::from_str("04:02").unwrap());
source§impl FromIntoArrowWithUnit for Timestamp
impl FromIntoArrowWithUnit for Timestamp
type ArrowType = i64
source§type TimestampType = TimeUnit
type TimestampType = TimeUnit
fn from_arrow_with_unit( value: Self::ArrowType, time_unit: Self::TimestampType, ) -> Self
fn into_arrow_with_unit(self, time_unit: Self::TimestampType) -> Self::ArrowType
source§impl FromIntoArrowWithUnit for Timestamp
impl FromIntoArrowWithUnit for Timestamp
type ArrowType = i64
source§type TimestampType = TimeUnit
type TimestampType = TimeUnit
fn from_arrow_with_unit( value: Self::ArrowType, time_unit: Self::TimestampType, ) -> Self
fn into_arrow_with_unit(self, time_unit: Self::TimestampType) -> Self::ArrowType
source§impl<'a> FromSql<'a> for Timestamp
impl<'a> FromSql<'a> for Timestamp
source§fn from_sql(
ty: &Type,
raw: &'a [u8],
) -> Result<Self, Box<dyn Error + Sync + Send>>
fn from_sql( ty: &Type, raw: &'a [u8], ) -> Result<Self, Box<dyn Error + Sync + Send>>
Type
in its binary format. Read moresource§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type
.source§impl FromStr for Timestamp
impl FromStr for Timestamp
Parse a timestamp from varchar.
§Example
use std::str::FromStr;
use risingwave_common::types::Timestamp;
Timestamp::from_str("1999-01-08 04:02").unwrap();
Timestamp::from_str("1999-01-08 04:05:06").unwrap();
Timestamp::from_str("1999-01-08T04:05:06").unwrap();
source§impl HashKeyDe for Timestamp
impl HashKeyDe for Timestamp
fn deserialize(_data_type: &DataType, buf: impl Buf) -> Self
source§impl HashKeySer<'_> for Timestamp
impl HashKeySer<'_> for Timestamp
source§fn serialize_into(self, buf: impl BufMut)
fn serialize_into(self, buf: impl BufMut)
source§fn exact_size() -> Option<usize>
fn exact_size() -> Option<usize>
Some
if the serialized size is known for this scalar type.source§fn estimated_size(self) -> usize
fn estimated_size(self) -> usize
source§impl Ord for Timestamp
impl Ord for Timestamp
source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
source§impl PrimitiveArrayItemType for Timestamp
impl PrimitiveArrayItemType for Timestamp
source§fn erase_array_type(arr: PrimitiveArray<Self>) -> ArrayImpl
fn erase_array_type(arr: PrimitiveArray<Self>) -> ArrayImpl
ArrayImpl
.source§fn try_into_array(arr: ArrayImpl) -> Option<PrimitiveArray<Self>>
fn try_into_array(arr: ArrayImpl) -> Option<PrimitiveArray<Self>>
ArrayImpl
to self.source§fn try_into_array_ref(arr: &ArrayImpl) -> Option<&PrimitiveArray<Self>>
fn try_into_array_ref(arr: &ArrayImpl) -> Option<&PrimitiveArray<Self>>
ArrayImpl
to self.source§fn array_type() -> ArrayType
fn array_type() -> ArrayType
fn to_protobuf<T: Write>(self, output: &mut T) -> ArrayResult<usize>
fn from_protobuf(cur: &mut Cursor<&[u8]>) -> ArrayResult<Self>
source§impl Scalar for Timestamp
impl Scalar for Timestamp
Implement Scalar
for Timestamp
.
source§type ScalarRefType<'a> = Timestamp
type ScalarRefType<'a> = Timestamp
Scalar
source§fn as_scalar_ref(&self) -> Timestamp
fn as_scalar_ref(&self) -> Timestamp
fn to_scalar_value(self) -> ScalarImpl
source§impl ScalarRef<'_> for Timestamp
impl ScalarRef<'_> for Timestamp
Implement ScalarRef
for Timestamp
.
source§type ScalarType = Timestamp
type ScalarType = Timestamp
ScalarType
is the owned type of current ScalarRef
.source§fn to_owned_scalar(&self) -> Timestamp
fn to_owned_scalar(&self) -> Timestamp
ScalarRef
to an owned scalar.source§fn hash_scalar<H: Hasher>(&self, state: &mut H)
fn hash_scalar<H: Hasher>(&self, state: &mut H)
source§impl ToBinary for Timestamp
impl ToBinary for Timestamp
fn to_binary_with_type(&self, ty: &DataType) -> Result<Bytes, ToBinaryError>
source§impl ToSql for Timestamp
impl ToSql for Timestamp
source§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type
.source§fn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql_checked( &self, ty: &Type, out: &mut BytesMut, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
source§fn to_sql(
&self,
ty: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn to_sql(
&self,
ty: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self
into the binary format of the specified
Postgres Type
, appending it to out
. Read more§fn encode_format(&self, _ty: &Type) -> Format
fn encode_format(&self, _ty: &Type) -> Format
source§impl ToText for Timestamp
impl ToText for Timestamp
source§fn write<W: Write>(&self, f: &mut W) -> Result
fn write<W: Write>(&self, f: &mut W) -> Result
source§fn write_with_type<W: Write>(&self, ty: &DataType, f: &mut W) -> Result
fn write_with_type<W: Write>(&self, ty: &DataType, f: &mut W) -> Result
source§fn to_text_with_type(&self, ty: &DataType) -> String
fn to_text_with_type(&self, ty: &DataType) -> String
source§impl TryFrom<ScalarImpl> for Timestamp
impl TryFrom<ScalarImpl> for Timestamp
source§type Error = ArrayError
type Error = ArrayError
source§fn try_from(val: ScalarImpl) -> ArrayResult<Self>
fn try_from(val: ScalarImpl) -> ArrayResult<Self>
source§impl<'scalar> TryFrom<ScalarRefImpl<'scalar>> for Timestamp
impl<'scalar> TryFrom<ScalarRefImpl<'scalar>> for Timestamp
source§type Error = ArrayError
type Error = ArrayError
source§fn try_from(val: ScalarRefImpl<'scalar>) -> ArrayResult<Self>
fn try_from(val: ScalarRefImpl<'scalar>) -> ArrayResult<Self>
source§impl<'a> WithDataType for &'a Timestamp
impl<'a> WithDataType for &'a Timestamp
source§fn default_data_type() -> DataType
fn default_data_type() -> DataType
DataType
for the rust type.source§impl<'a> WithDataType for &'a mut Timestamp
impl<'a> WithDataType for &'a mut Timestamp
source§fn default_data_type() -> DataType
fn default_data_type() -> DataType
DataType
for the rust type.source§impl WithDataType for Box<Timestamp>
impl WithDataType for Box<Timestamp>
source§fn default_data_type() -> DataType
fn default_data_type() -> DataType
DataType
for the rust type.source§impl WithDataType for Timestamp
impl WithDataType for Timestamp
source§fn default_data_type() -> DataType
fn default_data_type() -> DataType
DataType
for the rust type.impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralPartialEq for Timestamp
impl ZeroHeapSize for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> BorrowToSql for Twhere
T: ToSql,
impl<T> BorrowToSql for Twhere
T: ToSql,
§fn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
self
as a ToSql
trait object.source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
source§impl<T> EstimateSize for Twhere
T: ZeroHeapSize,
impl<T> EstimateSize for Twhere
T: ZeroHeapSize,
source§fn estimated_heap_size(&self) -> usize
fn estimated_heap_size(&self) -> usize
source§fn estimated_size(&self) -> usizewhere
Self: Sized,
fn estimated_size(&self) -> usizewhere
Self: Sized,
estimated_heap_size
and the size of Self
.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
source§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
source§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level
.source§fn relabel_n(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
relabel_num: usize,
) -> RelabeledMetricVec<M>
fn relabel_n( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, relabel_num: usize, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
.source§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
with metric_level
set to
MetricLevel::Debug
and relabel_num
set to 1.§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> ScalarPartialOrd for Twhere
T: PrimitiveArrayItemType + Scalar,
impl<T> ScalarPartialOrd for Twhere
T: PrimitiveArrayItemType + Scalar,
fn scalar_cmp(&self, other: T) -> Option<Ordering>
source§impl<T> ToOwnedDatum for Twhere
T: Into<ScalarImpl>,
impl<T> ToOwnedDatum for Twhere
T: Into<ScalarImpl>,
source§fn to_owned_datum(self) -> Option<ScalarImpl>
fn to_owned_datum(self) -> Option<ScalarImpl>
Datum
.