sidra_split: Split a SIDRA query into disjoint batches

View source: R/collect.R

sidra_splitR Documentation

Split a SIDRA query into disjoint batches

Description

Divides one explicit query dimension without downloading values. The resulting batches can be executed with sidra_collect(). Period selectors all, first, last, and ranges are resolved through sidra_periods() into a fixed inventory before splitting. Other special selections must be expanded explicitly. No values are downloaded during splitting.

Usage

sidra_split(
  query,
  by = c("period", "variable", "geo.filter", "category"),
  size,
  index = 1L
)

Arguments

query

A sidra_query() object or relative/complete SIDRA values URL. URL parameter order and unsplit selections are preserved. URL geographic splitting requires direct explicit codes at one non-Brazil level.

by

One of "period", "variable", "geo.filter", or "category".

size

Maximum number of selected members in each batch.

index

For list-valued geo.filter and category, the element to split. The default is the first element.

Details

Geographic filters can be split only when the query requests one non-Brazil geographic level. Queries with multiple territorial levels are rejected because unchanged levels would overlap across batches. Classifications already resolved in the original URL are reused without another metadata request.

Value

An object of class sidra_batch containing disjoint queries in their original order.

See Also

sidra_query(), sidra_plan(), sidra_collect()

Examples

query <- sidra_query(
  1612,
  variable = 214,
  period = as.character(2018:2022),
  geo = "Brazil",
  classific = "c81",
  category = list(2702)
)
batches <- sidra_split(query, by = "period", size = 2)
length(batches$queries)

sidrar documentation built on Sept. 28, 2026, 5:07 p.m.