sidra_split: Split an explicit SIDRA query into disjoint batches

View source: R/collect.R

sidra_splitR Documentation

Split an explicit SIDRA query into disjoint batches

Description

Divides one explicit query dimension without downloading values. The resulting batches can be executed with sidra_collect(). Special selectors such as all, allxt, first, and last must first be resolved to explicit codes. Each vector element must represent one member; embedded comma lists and period ranges are rejected because their cardinality cannot be enforced by size.

Usage

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

Arguments

query

A structured sidra_query() object. Queries created from ⁠api =⁠ URLs cannot be split because their original argument structure is unavailable.

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. 18, 2026, 9:14 a.m.