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
impl ElastiCubeBuilder
Sourcepub fn add_dimension(
self,
name: impl Into<String>,
data_type: DataType,
) -> Result<Self>
pub fn add_dimension( self, name: impl Into<String>, data_type: DataType, ) -> Result<Self>
Add a dimension
Sourcepub fn add_measure(
self,
name: impl Into<String>,
data_type: DataType,
agg_func: AggFunc,
) -> Result<Self>
pub fn add_measure( self, name: impl Into<String>, data_type: DataType, agg_func: AggFunc, ) -> Result<Self>
Add a measure
Sourcepub fn add_hierarchy(
self,
name: impl Into<String>,
levels: Vec<String>,
) -> Result<Self>
pub fn add_hierarchy( self, name: impl Into<String>, levels: Vec<String>, ) -> Result<Self>
Add a hierarchy
Sourcepub fn add_calculated_measure(
self,
name: impl Into<String>,
expression: impl Into<String>,
data_type: DataType,
agg_func: AggFunc,
) -> Result<Self>
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 measureexpression- SQL expression (e.g., “revenue - cost”)data_type- Expected result data typeagg_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()?;Sourcepub fn add_virtual_dimension(
self,
name: impl Into<String>,
expression: impl Into<String>,
data_type: DataType,
) -> Result<Self>
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 dimensionexpression- 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()?;Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set the cube description
Sourcepub fn load_csv_with(self, source: CsvSource) -> Self
pub fn load_csv_with(self, source: CsvSource) -> Self
Sourcepub fn load_parquet(self, path: impl Into<String>) -> Self
pub fn load_parquet(self, path: impl Into<String>) -> Self
Sourcepub fn load_parquet_with(self, source: ParquetSource) -> Self
pub fn load_parquet_with(self, source: ParquetSource) -> Self
Load data from a Parquet file with custom configuration
Sourcepub fn load_json_with(self, source: JsonSource) -> Self
pub fn load_json_with(self, source: JsonSource) -> Self
Load data from a JSON file with custom configuration
Sourcepub fn load_record_batches(
self,
schema: Arc<ArrowSchema>,
batches: Vec<RecordBatch>,
) -> Result<Self>
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 batchesbatches- Vector of RecordBatches containing the data
Sourcepub fn with_data(self, batches: Vec<RecordBatch>) -> Result<Self>
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()?;Sourcepub fn build(self) -> Result<ElastiCube>
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§
Auto Trait Implementations§
impl Freeze for ElastiCubeBuilder
impl !RefUnwindSafe for ElastiCubeBuilder
impl Send for ElastiCubeBuilder
impl Sync for ElastiCubeBuilder
impl Unpin for ElastiCubeBuilder
impl !UnwindSafe for ElastiCubeBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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