Skip to main content

tessera/readers/
mod.rs

1//! Data-engine plumbing shared by the Polars and DuckDB readers.
2
3#[cfg(feature = "duckdb")]
4pub mod duckdb;
5#[cfg(feature = "polars")]
6pub mod polars;
7
8use crate::error::TesseraError;
9use crate::models::{IntoCoins, IntoMonths, PartitionRef};
10#[cfg(any(feature = "polars", feature = "duckdb"))]
11/// A resolved partition: its reference plus one presigned URL per object.
12///
13/// A finalised month is one object; the day-backed open month is one per day.
14pub type ResolvedPartition = (PartitionRef, Vec<String>);
15
16/// Expand `(asset, coins, months)` into the cartesian list of partitions.
17///
18/// Coin-major ordering: every month of the first coin, then the second, …
19///
20/// # Errors
21///
22/// Returns [`TesseraError::InvalidArgument`] when either argument is empty or
23/// contains an invalid month.
24pub fn expand_refs(
25    asset: &str,
26    coin: impl IntoCoins,
27    month: impl IntoMonths,
28) -> Result<Vec<PartitionRef>, TesseraError> {
29    let coins = coin.into_coins()?;
30    let months = month.into_months()?;
31    let mut refs = Vec::with_capacity(coins.len() * months.len());
32    for coin in &coins {
33        for month in &months {
34            refs.push(PartitionRef::new(asset, coin, month)?);
35        }
36    }
37    Ok(refs)
38}