Skip to content

Commit 4eecf01

Browse files
mcheshkovFrank-TXS
authored andcommitted
fix(schema-compiler): Use member expression definition as measure key (cube-js#9154)
Without this when measure was a member expression m.measure.name can be undefined, and different measures will have same key in collectRootMeasureToHieararchy
1 parent 8c0d32a commit 4eecf01

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,6 +2100,7 @@ export class BaseQuery {
21002100
const cubeName = m.expressionCubeName ? `\`${m.expressionCubeName}\` ` : '';
21012101
throw new UserError(`The query contains \`COUNT(*)\` expression but cube/view ${cubeName}is missing \`count\` measure`);
21022102
}
2103+
21032104
if (collectedMeasures.length === 0 && m.isMemberExpression) {
21042105
// `m` is member expression measure, but does not reference any other measure
21052106
// Consider this dimensions-only measure. This can happen at least in 2 cases:
@@ -2110,8 +2111,17 @@ export class BaseQuery {
21102111
// TODO return measure object for every measure
21112112
return this.dimensionOnlyMeasureToHierarchy(context, m);
21122113
}
2113-
const measureName = typeof m.measure === 'string' ? m.measure : `${m.measure.cubeName}.${m.measure.name}`;
2114-
return [measureName, collectedMeasures];
2114+
2115+
let measureKey;
2116+
if (typeof m.measure === 'string') {
2117+
measureKey = m.measure;
2118+
} else if (m.isMemberExpression) {
2119+
// TODO expressionName vs definition?
2120+
measureKey = m.expressionName;
2121+
} else {
2122+
measureKey = `${m.measure.cubeName}.${m.measure.name}`;
2123+
}
2124+
return [measureKey, collectedMeasures];
21152125
}));
21162126
}
21172127

0 commit comments

Comments
 (0)