QueryBuilder

Struct QueryBuilder 

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

Query builder for ElastiCube queries

Provides a fluent API for building and executing queries against a cube. Supports both SQL queries and a DataFrame-style fluent API.

§Examples

// SQL query
let results = cube.query()
    .sql("SELECT region, SUM(sales) FROM cube GROUP BY region")
    .execute()
    .await?;

// Fluent API query
let results = cube.query()
    .select(&["region", "SUM(sales) as total_sales"])
    .filter("sales > 1000")
    .group_by(&["region"])
    .order_by(&["total_sales DESC"])
    .limit(10)
    .execute()
    .await?;

Implementations§

Source§

impl QueryBuilder

Source

pub fn sql(self, query: impl Into<String>) -> Self

Execute a raw SQL query

§Arguments
  • query - SQL query string (can reference the cube as “cube”)
§Example
let results = cube.query()
    .sql("SELECT region, SUM(sales) as total FROM cube GROUP BY region")
    .execute()
    .await?;
Source

pub fn select(self, columns: &[impl AsRef<str>]) -> Self

Select specific columns or expressions

§Arguments
  • columns - Column names or SQL expressions
§Example
.select(&["region", "product", "SUM(sales) as total_sales"])
Source

pub fn filter(self, condition: impl Into<String>) -> Self

Add a WHERE filter condition

§Arguments
  • condition - SQL filter expression
§Example
.filter("sales > 1000 AND region = 'North'")
Source

pub fn where_clause(self, condition: impl Into<String>) -> Self

Add WHERE filter (alias for filter)

Source

pub fn group_by(self, columns: &[impl AsRef<str>]) -> Self

Group by columns

§Arguments
  • columns - Column names to group by
§Example
.group_by(&["region", "product"])
Source

pub fn order_by(self, columns: &[impl AsRef<str>]) -> Self

Order results by columns

§Arguments
  • columns - Column names with optional ASC/DESC
§Example
.order_by(&["total_sales DESC", "region ASC"])
Source

pub fn limit(self, count: usize) -> Self

Limit the number of results

§Example
.limit(100)
Source

pub fn offset(self, count: usize) -> Self

Skip a number of results

§Example
.offset(50)
Source

pub fn slice(self, dimension: impl AsRef<str>, value: impl AsRef<str>) -> Self

OLAP Operation: Slice - filter on a single dimension

§Example
.slice("region", "North")
Source

pub fn dice(self, filters: &[(impl AsRef<str>, impl AsRef<str>)]) -> Self

OLAP Operation: Dice - filter on multiple dimensions

§Example
.dice(&[("region", "North"), ("product", "Widget")])
Source

pub fn drill_down( self, _parent_level: impl AsRef<str>, child_levels: &[impl AsRef<str>], ) -> Self

OLAP Operation: Drill-down - navigate down a hierarchy

This selects data at a more granular level by including a lower-level dimension.

§Example
// Drill down from year to month
.drill_down("year", &["year", "month"])
Source

pub fn roll_up(self, dimensions_to_remove: &[impl AsRef<str>]) -> Self

OLAP Operation: Roll-up - aggregate across dimensions

This aggregates data by removing one or more dimensions from grouping.

§Example
.roll_up(&["region"]) // Aggregate across all regions
Source

pub async fn execute(self) -> Result<QueryResult>

Execute the query and return results

§Returns

A QueryResult containing the data and metadata

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,