Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod query;
mod query_source;
mod root_query;
mod schema;
pub mod transforms;
pub mod visitor;

pub use aggregate_multiplied_subquery::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use cubenativeutils::CubeError;
use std::rc::Rc;

/// Leaf CTE of a multi-stage chain — a base query that produces the
/// raw aggregated values feeding the rest of the chain. Optional
/// state rendering and time shifts come from `evaluation_context`.
/// raw aggregated values feeding the rest of the chain. The measures
/// carry their own render form; time shifts and row-grain evaluation
/// come from `evaluation_context`.
pub struct MultiStageLeafMeasure {
pub measures: Vec<Rc<MemberSymbol>>,
pub evaluation_context: EvaluationContext,
Expand All @@ -20,9 +21,6 @@ impl PrettyPrint for MultiStageLeafMeasure {
for measure in self.measures.iter() {
result.println(&format!("measure: {}", measure.full_name()), &state);
}
if self.evaluation_context.measure_as_state {
result.println("render_measure_as_state: true", &state);
}
if self.evaluation_context.measure_for_ungrouped {
result.println("render_measure_for_ungrouped: true", &state);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! Transformations that derive new logical-plan pieces (schemas,
//! filters) from existing ones by lifting symbol-level transforms
//! over their members.
//!
//! The level rule: a transform lives at the level of what it takes as
//! input. Symbol-to-symbol transforms belong to
//! `planner::symbols::transforms`; anything that rewrites a plan-level
//! container of symbols belongs here.

mod render_modifier;
mod tz_converted_at_source;

pub use render_modifier::*;
pub use tz_converted_at_source::*;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use super::super::LogicalSchema;
use crate::planner::symbols::transforms;
use crate::planner::{MeasureRenderModifier, MemberSymbol};
use cubenativeutils::CubeError;
use std::rc::Rc;

/// Copy of the schema with `modifier` set on every measure that has
/// no render modifier yet. Every schema member is rewritten, so
/// measures embedded in a dimension's expression tree get the form
/// too — the form belongs to the measure as rendered in this select,
/// not to its position in the schema.
pub fn measures_render_modifier_in_schema(
schema: &LogicalSchema,
modifier: &MeasureRenderModifier,
) -> Result<Rc<LogicalSchema>, CubeError> {
let stamp = |members: &Vec<Rc<MemberSymbol>>| {
members
.iter()
.map(|m| transforms::measures_render_modifier(m, modifier))
.collect::<Result<Vec<_>, _>>()
};
let mut new = schema.clone();
new.time_dimensions = stamp(&new.time_dimensions)?;
new.dimensions = stamp(&new.dimensions)?;
new.measures = stamp(&new.measures)?;
Ok(Rc::new(new))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use super::super::LogicalSchema;
use crate::planner::symbols::transforms;
use crate::planner::MemberSymbol;
use cubenativeutils::CubeError;
use std::collections::HashSet;
use std::rc::Rc;

/// Copy of the schema with every time dimension marked as
/// timezone-converted at the source (a pre-aggregation rollup or an
/// input CTE). Every schema member is rewritten, so occurrences of
/// the marked time dimensions embedded in other members' expression
/// trees carry the mark too.
pub fn mark_tz_converted_at_source_in_schema(
schema: &LogicalSchema,
) -> Result<Rc<LogicalSchema>, CubeError> {
let names = schema
.time_dimensions
.iter()
.map(|d| d.full_name())
.collect::<HashSet<_>>();
let mark = |members: &Vec<Rc<MemberSymbol>>| {
members
.iter()
.map(|m| transforms::mark_tz_converted_at_source(m, &names))
.collect::<Result<Vec<_>, _>>()
};
let mut new = schema.clone();
new.time_dimensions = mark(&new.time_dimensions)?;
new.dimensions = mark(&new.dimensions)?;
new.measures = mark(&new.measures)?;
Ok(Rc::new(new))
}

This file was deleted.

Loading
Loading