uwheel/datafusion-uwheel

Add IndexBuilder to enable configuration of indexes

Closed this issue · 0 comments

Define the API to build wheel indices.

Current approach:

/// Builder for creating wheel indices
pub struct IndexBuilder {
  /// The column to build the wheel index on
  pub col: Column,
  /// The type of aggregation to use
  pub agg_type: AggregateType,
  /// Optional filter to apply to the column
  pub filter: Option<Expr>,
  /// Wheel configuration
  pub conf: HawConf,
}

// Build an index on fare_amount column using SUM() where id equals to ´1`
let builder = IndexBuilder::with_col_and_aggregate("fare_amount", AggregateType::Sum)
  .with_filter(col("id").eq(lit(1)));

// Add the index to the optimizer
optimizer.build_index(builder).await?;

// which would then enable the following query to execute through our index.
let sum_plan = ctx
   .sql(
    "SELECT SUM(fare_amount) FROM yellow_tripdata
     WHERE tpep_dropoff_datetime >= '2022-01-01T00:00:00Z'
     AND tpep_dropoff_datetime < '2022-02-01T00:00:00Z'
     AND id  = 1",
   ).await?