ElastiCubeBuilder

Struct ElastiCubeBuilder 

Source
pub struct ElastiCubeBuilder { /* private fields */ }
Expand description

Builder for constructing an ElastiCube

Provides a fluent API for defining dimensions, measures, hierarchies, and loading data from various sources.

Implementations§

Source§

impl ElastiCubeBuilder

Source

pub fn new(name: impl Into<String>) -> Self

Create a new builder

Source

pub fn add_dimension( self, name: impl Into<String>, data_type: DataType, ) -> Result<Self>

Add a dimension

Source

pub fn add_measure( self, name: impl Into<String>, data_type: DataType, agg_func: AggFunc, ) -> Result<Self>

Add a measure

Source

pub fn add_hierarchy( self, name: impl Into<String>, levels: Vec<String>, ) -> Result<Self>

Add a hierarchy

Source

pub fn add_calculated_measure( self, name: impl Into<String>, expression: impl Into<String>, data_type: DataType, agg_func: AggFunc, ) -> Result<Self>

Add a calculated measure (derived from an expression)

§Arguments
  • name - Name for the calculated measure
  • expression - SQL expression (e.g., “revenue - cost”)
  • data_type - Expected result data type
  • agg_func - Default aggregation function
§Example
let cube = ElastiCubeBuilder::new("sales")
    .add_measure("revenue", DataType::Float64, AggFunc::Sum)?
    .add_measure("cost", DataType::Float64, AggFunc::Sum)?
    .add_calculated_measure(
        "profit",
        "revenue - cost",
        DataType::Float64,
        AggFunc::Sum
    )?
    .build()?;
Source

pub fn add_virtual_dimension( self, name: impl Into<String>, expression: impl Into<String>, data_type: DataType, ) -> Result<Self>

Add a virtual dimension (computed dimension)

§Arguments
  • name - Name for the virtual dimension
  • expression - SQL expression (e.g., “EXTRACT(YEAR FROM date)”)
  • data_type - Expected result data type
§Example
let cube = ElastiCubeBuilder::new("sales")
    .add_dimension("sale_date", DataType::Date32)?
    .add_virtual_dimension(
        "year",
        "EXTRACT(YEAR FROM sale_date)",
        DataType::Int32
    )?
    .build()?;
Source

pub fn with_description(self, description: impl Into<String>) -> Self

Set the cube description

Source

pub fn load_csv(self, path: impl Into<String>) -> Self

Load data from a CSV file

§Arguments
  • path - Path to the CSV file
§Example
let cube = ElastiCubeBuilder::new("sales")
    .load_csv("data.csv")?
    .build()?;
Source

pub fn load_csv_with(self, source: CsvSource) -> Self

Load data from a CSV file with custom configuration

§Arguments
  • source - Configured CsvSource
§Example
let source = CsvSource::new("data.csv")
    .with_delimiter(b';')
    .with_batch_size(4096);
let cube = ElastiCubeBuilder::new("sales")
    .load_csv_with(source)
    .build()?;
Source

pub fn load_parquet(self, path: impl Into<String>) -> Self

Load data from a Parquet file

§Arguments
  • path - Path to the Parquet file
Source

pub fn load_parquet_with(self, source: ParquetSource) -> Self

Load data from a Parquet file with custom configuration

Source

pub fn load_json(self, path: impl Into<String>) -> Self

Load data from a JSON file

§Arguments
  • path - Path to the JSON file
Source

pub fn load_json_with(self, source: JsonSource) -> Self

Load data from a JSON file with custom configuration

Source

pub fn load_record_batches( self, schema: Arc<ArrowSchema>, batches: Vec<RecordBatch>, ) -> Result<Self>

Load data from Arrow RecordBatches

§Arguments
  • schema - Arrow schema for the batches
  • batches - Vector of RecordBatches containing the data
Source

pub fn with_data(self, batches: Vec<RecordBatch>) -> Result<Self>

Load data from RecordBatches (convenience method for testing)

Infers schema from the first batch. All batches must have the same schema.

§Arguments
  • batches - Vector of RecordBatches containing the data
§Example
let batch = RecordBatch::try_new(schema, columns)?;
let cube = ElastiCubeBuilder::new("test")
    .with_data(vec![batch])?
    .build()?;
Source

pub fn build(self) -> Result<ElastiCube>

Build the cube

Loads data from the configured source and creates an ElastiCube. If dimensions and measures were explicitly defined, validates that the data schema matches. Otherwise, infers the schema from the data.

Trait Implementations§

Source§

impl Debug for ElastiCubeBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,