Skip to content

Commit 229401f

Browse files
committed
fix aliasMember set for segments
1 parent 7a6b3b9 commit 229401f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,15 @@ export class CubeEvaluator extends CubeSymbols {
530530
if (member.sql && !member.subQuery) {
531531
const funcArgs = this.funcArguments(member.sql);
532532
const { cubeReferencesUsed, evaluatedSql, pathReferencesUsed } = this.collectUsedCubeReferences(cube.name, member.sql);
533-
// We won't check for FILTER_PARAMS here as it shouldn't affect ownership and it should obey the same reference rules.
533+
// We won't check for FILTER_PARAMS here as it shouldn't affect ownership, and it should obey the same reference rules.
534534
// To affect ownership FILTER_PARAMS can be declared as `${FILTER_PARAMS.Foo.bar.filter(`${Foo.bar}`)}`.
535535
// It isn't owned if there are non {CUBE} references
536536
if (funcArgs.length > 0 && cubeReferencesUsed.length === 0) {
537537
ownedByCube = false;
538538
}
539539
// Aliases one to one some another member as in case of views
540-
if (!ownedByCube && !member.filters && CubeSymbols.isCalculatedMeasureType(member.type) && pathReferencesUsed.length === 1 && this.pathFromArray(pathReferencesUsed[0]) === evaluatedSql) {
540+
// Note: Segments do not have type set
541+
if (!ownedByCube && !member.filters && (!member.type || CubeSymbols.isCalculatedMeasureType(member.type)) && pathReferencesUsed.length === 1 && this.pathFromArray(pathReferencesUsed[0]) === evaluatedSql) {
541542
aliasMember = this.pathFromArray(pathReferencesUsed[0]);
542543
}
543544
const foreignCubes = cubeReferencesUsed.filter(usedCube => usedCube !== cube.name);

0 commit comments

Comments
 (0)