Skip to main content

date_bin_stride

Function date_bin_stride 

Source
fn date_bin_stride(
    ts_col_name: &str,
    unit: TimeUnit,
    expr: &Expr,
) -> Option<i64>
Expand description

Returns the stride of date_bin(stride, ts_col[, origin]), converted to unit and rounded up, if expr is that call with a literal, fixed-width stride.

date_bin floors a timestamp to the start of its bucket, so for every row bucket_start <= ts < bucket_start + stride, whatever the origin. That lets a filter on the bucket start bound the time index itself, which is what a filter on a view’s date_bin(...) AS time column becomes once it is pushed below the view’s aggregate.

This holds in nanoseconds. DataFusion computes the bucket start in nanoseconds and truncates it to the column unit, so on a coarser column the returned value can be up to one unit below the true start; see date_bin_range.