Temporal Expression APIs¶
All temporal operations are valid for both scalars and columns.
TemporalValue
¶
Bases: Value
Functions¶
strftime(format_str)
¶
Format timestamp according to format_str
.
Format string may depend on the backend, but we try to conform to ANSI
strftime
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
format_str |
str
|
|
required |
Returns:
Type | Description |
---|---|
StringValue
|
Formatted version of |
TimestampValue
¶
Bases: _DateComponentMixin
, _TimeComponentMixin
, TemporalValue
Functions¶
__add__(other)
¶
Add an interval to a timestamp.
__rsub__(other)
¶
Subtract a timestamp or an interval from a timestamp.
__sub__(other)
¶
Subtract a timestamp or an interval from a timestamp.
date()
¶
Return the date component of the expression.
Returns:
Type | Description |
---|---|
DateValue
|
The date component of |
truncate(unit)
¶
Truncate timestamp expression to units of unit
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit |
Literal['Y', 'Q', 'M', 'W', 'D', 'h', 'm', 's', 'ms', 'us', 'ns']
|
Unit to truncate to |
required |
Returns:
Type | Description |
---|---|
TimestampValue
|
Truncated timestamp expression |
DateValue
¶
Bases: TemporalValue
, _DateComponentMixin
TimeValue
¶
IntervalValue
¶
Bases: Value
Attributes¶
days: ir.IntegerValue
property
¶
Extract the number of days from an interval.
hours: ir.IntegerValue
property
¶
Extract the number of hours from an interval.
microseconds: ir.IntegerValue
property
¶
Extract the number of microseconds from an interval.
milliseconds: ir.IntegerValue
property
¶
Extract the number of milliseconds from an interval.
minutes: ir.IntegerValue
property
¶
Extract the number of minutes from an interval.
months: ir.IntegerValue
property
¶
Extract the number of months from an interval.
nanoseconds: ir.IntegerValue
property
¶
Extract the number of nanoseconds from an interval.
quarters: ir.IntegerValue
property
¶
Extract the number of quarters from an interval.
seconds: ir.IntegerValue
property
¶
Extract the number of seconds from an interval.
weeks: ir.IntegerValue
property
¶
Extract the number of weeks from an interval.
years: ir.IntegerValue
property
¶
Extract the number of years from an interval.
Functions¶
__add__(other)
¶
Add this interval to other
.
__floordiv__(other)
¶
Floor-divide this interval by other
.
__mul__(other)
¶
Multiply this interval by other
.
__rsub__(other)
¶
Subtract other
from this interval.
__sub__(other)
¶
Subtract other
from this interval.
negate()
¶
Negate an interval expression.
Returns:
Type | Description |
---|---|
IntervalValue
|
A negated interval value expression |
to_unit(target_unit)
¶
Convert this interval to units of target_unit
.