Learn R Programming

shard (version 0.1.0)

stream_sum: Stream sum of a numeric column

Description

Computes the sum of col across all partitions without collecting the full dataset. When partitions are native-encoded, this avoids decoding string columns entirely.

Usage

stream_sum(x, col, na_rm = TRUE)

Value

A single numeric value giving the sum of the column across all partitions.

Arguments

x

A shard_row_groups or shard_dataset handle.

col

Column name to sum.

na_rm

Logical; drop NAs (default TRUE).

Examples

Run this code
# \donttest{
s <- schema(x = float64())
sink <- table_sink(s, mode = "row_groups")
table_write(sink, 1L, data.frame(x = c(1.0, 2.0, 3.0)))
rg <- table_finalize(sink)
stream_sum(rg, "x")
# }

Run the code above in your browser using DataLab