Skip to content

Commit b586a2e

Browse files
committed
fix
1 parent 798cb6a commit b586a2e

File tree

9 files changed

+18
-23
lines changed

9 files changed

+18
-23
lines changed

packages/cubejs-schema-compiler/src/adapter/BaseQuery.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -3487,8 +3487,7 @@ export class BaseQuery {
34873487
});
34883488
} else if (preAggregation.type === 'rollup') {
34893489
const query = this.preAggregations.rollupPreAggregationQuery(cube, preAggregation);
3490-
const params = query.buildSqlAndParams();
3491-
return query.evaluateSymbolSqlWithContext(() => params, {
3490+
return query.evaluateSymbolSqlWithContext(() => query.buildSqlAndParams(), {
34923491
collectOriginalSqlPreAggregations
34933492
});
34943493
} else if (preAggregation.type === 'originalSql') {

packages/cubejs-schema-compiler/src/adapter/PreAggregations.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -874,12 +874,8 @@ export class PreAggregations {
874874
const canUsePreAggregation = () => true;
875875
const preAggregation = R.pipe(
876876
R.toPairs,
877-
// eslint-disable-next-line no-unused-vars
878-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
879-
R.filter(([k, a]) => a.type === 'rollup' || a.type === 'rollupJoin' || a.type === 'rollupLambda'),
880-
// eslint-disable-next-line no-unused-vars
881-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
882-
R.find(([k, a]) => k === preAggregationName)
877+
R.filter(([_, a]) => a.type === 'rollup' || a.type === 'rollupJoin' || a.type === 'rollupLambda'),
878+
R.find(([_, a]) => a.name === preAggregationName)
883879
)(this.query.cubeEvaluator.preAggregationsForCube(cube));
884880
if (preAggregation) {
885881
const tableName = this.preAggregationTableName(cube, preAggregation[0], preAggregation[1]);

packages/cubejs-schema-compiler/src/compiler/CubeEvaluator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ export class CubeEvaluator extends CubeSymbols {
520520
return this.cubeFromPath(path).preAggregations || {};
521521
}
522522

523-
public preAggregationsForCubeAsArray(path: string) {
523+
public preAggregationsForCubeAsArray(path: string): Record<string, any> {
524524
return Object.entries(this.cubeFromPath(path).preAggregations || {}).map(([name, preAggregation]) => ({
525525
name,
526526
...(preAggregation as Record<string, any>)

packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3138,7 +3138,7 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL
31383138
}]
31393139
));
31403140

3141-
it('multi stage complex graph 111', async () => runQueryTest(
3141+
it('multi stage complex graph', async () => runQueryTest(
31423142
{
31433143
measures: ['visitors.adjusted_rank_sum', 'visitors.visitor_revenue'],
31443144
dimensions: ['visitors.source'],

rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/compiled_pre_aggregation.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl CompiledPreAggregation {
4343
) -> Result<Rc<Self>, CubeError> {
4444
let static_data = description.static_data();
4545
let measures = if let Some(refs) = description.measure_references()? {
46-
Self::symbols_from_ref(query_tools.clone(), cube_name, refs, Self::check_if_measure)?
46+
Self::symbols_from_ref(query_tools.clone(), cube_name, refs, Self::check_is_measure)?
4747
} else {
4848
Vec::new()
4949
};
@@ -52,7 +52,7 @@ impl CompiledPreAggregation {
5252
query_tools.clone(),
5353
cube_name,
5454
refs,
55-
Self::check_if_dimension,
55+
Self::check_is_dimension,
5656
)?
5757
} else {
5858
Vec::new()
@@ -62,7 +62,7 @@ impl CompiledPreAggregation {
6262
query_tools.clone(),
6363
cube_name,
6464
refs,
65-
Self::check_if_time_dimension,
65+
Self::check_is_time_dimension,
6666
)?;
6767
/* if dims.len() != 1 {
6868
return Err(CubeError::user(format!(
@@ -107,21 +107,21 @@ impl CompiledPreAggregation {
107107
Ok(res)
108108
}
109109

110-
fn check_if_measure(symbol: &MemberSymbol) -> Result<(), CubeError> {
110+
fn check_is_measure(symbol: &MemberSymbol) -> Result<(), CubeError> {
111111
symbol
112112
.as_measure()
113113
.map_err(|_| CubeError::user(format!("Pre-aggregation measure must be a measure")))?;
114114
Ok(())
115115
}
116116

117-
fn check_if_dimension(symbol: &MemberSymbol) -> Result<(), CubeError> {
117+
fn check_is_dimension(symbol: &MemberSymbol) -> Result<(), CubeError> {
118118
symbol.as_dimension().map_err(|_| {
119119
CubeError::user(format!("Pre-aggregation dimension must be a dimension"))
120120
})?;
121121
Ok(())
122122
}
123123

124-
fn check_if_time_dimension(symbol: &MemberSymbol) -> Result<(), CubeError> {
124+
fn check_is_time_dimension(symbol: &MemberSymbol) -> Result<(), CubeError> {
125125
let dimension = symbol.as_dimension().map_err(|_| {
126126
CubeError::user(format!(
127127
"Pre-aggregation time dimension must be a dimension"

rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/dimension_matcher.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl<'a> DimensionMatcher<'a> {
119119
MemberSymbol::TimeDimension(time_dimension) => {
120120
self.try_match_time_dimension(time_dimension, add_to_matched_dimension)
121121
}
122-
MemberSymbol::MemberExpression(_member_expression) => Ok(MatchState::NotMatched), //TODO We not allow to use pre-aggregations with member expressions before sqlapi ready for it
122+
MemberSymbol::MemberExpression(_member_expression) => Ok(MatchState::NotMatched), //TODO We don't allow to use pre-aggregations with member expressions before SQL API is ready for it
123123
_ => Ok(MatchState::NotMatched),
124124
}
125125
}

rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/optimizer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl PreAggregationOptimizer {
370370
rewrited_multistage: &mut HashMap<String, bool>,
371371
pre_aggregation: &Rc<CompiledPreAggregation>,
372372
) -> Result<(), CubeError> {
373-
if let Some(rewrited) =
373+
if let Some(rewritten) =
374374
self.try_rewrite_query(multi_stage_leaf_measure.query.clone(), pre_aggregation)?
375375
{
376376
let new_leaf = MultiStageLeafMeasure {
@@ -380,7 +380,7 @@ impl PreAggregationOptimizer {
380380
.render_measure_for_ungrouped
381381
.clone(),
382382
time_shifts: multi_stage_leaf_measure.time_shifts.clone(),
383-
query: rewrited,
383+
query: rewritten,
384384
};
385385
let new_multistage = Rc::new(LogicalMultiStageMember {
386386
name: multi_stage_name.clone(),

rust/cubesqlplanner/cubesqlplanner/src/planner/sql_evaluator/collectors/cube_names_collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub fn collect_cube_names(node: &Rc<MemberSymbol>) -> Result<Vec<String>, CubeEr
7777
Ok(visitor.extract_result())
7878
}
7979

80-
pub fn collect_cube_names_from_vec(
80+
pub fn collect_cube_names_from_symbols(
8181
nodes: &Vec<Rc<MemberSymbol>>,
8282
) -> Result<Vec<String>, CubeError> {
8383
let mut visitor = CubeNamesCollector::new();

rust/cubesqlplanner/cubesqlplanner/src/planner/sql_evaluator/symbols/dimension_symbol.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct DimensionSymbol {
3232
longitude: Option<Rc<SqlCall>>,
3333
case: Option<DimensionCaseDefinition>,
3434
definition: Rc<dyn DimensionDefinition>,
35-
is_reference: bool, // Is symbol is direct reference to another symbol without any calculations
35+
is_reference: bool, // Symbol is a direct reference to another symbol without any calculations
3636
}
3737

3838
impl DimensionSymbol {
@@ -248,7 +248,7 @@ impl SymbolFactory for DimensionSymbolFactory {
248248
None
249249
};
250250

251-
let is_sql_is_direct_ref = if let Some(sql) = &sql {
251+
let is_sql_direct_ref = if let Some(sql) = &sql {
252252
sql.is_direct_reference()?
253253
} else {
254254
false
@@ -304,7 +304,7 @@ impl SymbolFactory for DimensionSymbolFactory {
304304
let is_multi_stage = definition.static_data().multi_stage.unwrap_or(false);
305305
let is_reference = !owned_by_cube
306306
&& !is_sub_query
307-
&& is_sql_is_direct_ref
307+
&& is_sql_direct_ref
308308
&& case.is_none()
309309
&& latitude.is_none()
310310
&& longitude.is_none()

0 commit comments

Comments
 (0)