Skip to content

Commit a171be9

Browse files
committed
fix
1 parent b586a2e commit a171be9

File tree

3 files changed

+38
-43
lines changed

3 files changed

+38
-43
lines changed

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

+35-40
Original file line numberDiff line numberDiff line change
@@ -748,51 +748,46 @@ export class BaseQuery {
748748

749749
// FIXME Temporary solution
750750
findPreAggregationForQueryRust() {
751-
if (!this.preAggregations.preAggregationForQuery) {
752-
let optionsOrder = this.options.order;
753-
if (optionsOrder && !Array.isArray(optionsOrder)) {
754-
optionsOrder = [optionsOrder];
755-
}
756-
const order = optionsOrder ? R.pipe(
757-
R.map((hash) => ((!hash || !hash.id) ? null : hash)),
758-
R.reject(R.isNil),
759-
)(optionsOrder) : undefined;
760-
761-
const queryParams = {
762-
measures: this.options.measures,
763-
dimensions: this.options.dimensions,
764-
segments: this.options.segments,
765-
timeDimensions: this.options.timeDimensions,
766-
timezone: this.options.timezone,
767-
joinGraph: this.joinGraph,
768-
cubeEvaluator: this.cubeEvaluator,
769-
order,
770-
filters: this.options.filters,
771-
limit: this.options.limit ? this.options.limit.toString() : null,
772-
rowLimit: this.options.rowLimit ? this.options.rowLimit.toString() : null,
773-
offset: this.options.offset ? this.options.offset.toString() : null,
774-
baseTools: this,
775-
ungrouped: this.options.ungrouped,
776-
exportAnnotatedSql: false,
777-
preAggregationQuery: this.options.preAggregationQuery
778-
};
751+
let optionsOrder = this.options.order;
752+
if (optionsOrder && !Array.isArray(optionsOrder)) {
753+
optionsOrder = [optionsOrder];
754+
}
755+
const order = optionsOrder ? R.pipe(
756+
R.map((hash) => ((!hash || !hash.id) ? null : hash)),
757+
R.reject(R.isNil),
758+
)(optionsOrder) : undefined;
779759

780-
const buildResult = nativeBuildSqlAndParams(queryParams);
760+
const queryParams = {
761+
measures: this.options.measures,
762+
dimensions: this.options.dimensions,
763+
segments: this.options.segments,
764+
timeDimensions: this.options.timeDimensions,
765+
timezone: this.options.timezone,
766+
joinGraph: this.joinGraph,
767+
cubeEvaluator: this.cubeEvaluator,
768+
order,
769+
filters: this.options.filters,
770+
limit: this.options.limit ? this.options.limit.toString() : null,
771+
rowLimit: this.options.rowLimit ? this.options.rowLimit.toString() : null,
772+
offset: this.options.offset ? this.options.offset.toString() : null,
773+
baseTools: this,
774+
ungrouped: this.options.ungrouped,
775+
exportAnnotatedSql: false,
776+
preAggregationQuery: this.options.preAggregationQuery
777+
};
781778

782-
if (buildResult.error) {
783-
if (buildResult.error.cause === 'User') {
784-
throw new UserError(buildResult.error.message);
785-
} else {
786-
throw new Error(buildResult.error.message);
787-
}
788-
}
779+
const buildResult = nativeBuildSqlAndParams(queryParams);
789780

790-
const [, , preAggregation] = buildResult.result;
791-
if (preAggregation) {
792-
this.preAggregations.preAggregationForQuery = preAggregation;
781+
if (buildResult.error) {
782+
if (buildResult.error.cause === 'User') {
783+
throw new UserError(buildResult.error.message);
784+
} else {
785+
throw new Error(buildResult.error.message);
793786
}
794787
}
795-
return this.preAggregations.preAggregationForQuery;
788+
789+
const [, , preAggregation] = buildResult.result;
790+
return preAggregation;
796791
}
797792

798793
allCubeMembers(path) {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ export class PreAggregations {
783783
findPreAggregationForQuery() {
784784
if (!this.preAggregationForQuery) {
785785
if (this.query.useNativeSqlPlanner && this.query.canUseNativeSqlPlannerPreAggregation) {
786-
this.query.findPreAggregationForQueryRust();
786+
this.preAggregationForQuery = this.query.findPreAggregationForQueryRust();
787787
} else {
788788
this.preAggregationForQuery =
789789
this
@@ -875,7 +875,7 @@ export class PreAggregations {
875875
const preAggregation = R.pipe(
876876
R.toPairs,
877877
R.filter(([_, a]) => a.type === 'rollup' || a.type === 'rollupJoin' || a.type === 'rollupLambda'),
878-
R.find(([_, a]) => a.name === preAggregationName)
878+
R.find(([k, _]) => k === preAggregationName)
879879
)(this.query.cubeEvaluator.preAggregationsForCube(cube));
880880
if (preAggregation) {
881881
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): Record<string, any> {
523+
public preAggregationsForCubeAsArray(path: string) {
524524
return Object.entries(this.cubeFromPath(path).preAggregations || {}).map(([name, preAggregation]) => ({
525525
name,
526526
...(preAggregation as Record<string, any>)

0 commit comments

Comments
 (0)