Skip to main content

downsample

Function downsample 

Source
pub fn downsample(
    batch: &RecordBatch,
    value_column: &str,
    interval: i64,
    function: &AggFn,
    memory_tracker: Option<&MemoryTracker>,
) -> Result<RecordBatch>
Expand description

Downsample a RecordBatch into fixed-width time buckets.

For each bucket [bucket_start, bucket_start + interval), the aggregation function is applied to the values in the value_column.

Returns a new RecordBatch with two columns: _time (bucket start) and the aggregated value column.

§Arguments

  • batch – input data (must have a _time Int64 column)
  • value_column – name of the column to aggregate
  • interval – bucket width in the same unit as timestamps (e.g. nanos)
  • function – aggregation function to apply per bucket

§Errors

Returns an error if columns are missing or have unexpected types.