Skip to content

Commit f1c33a6

Browse files
committed
inject CubeJoinsResolver into inheritance chain
CubeEvaluator extends CubeJoinsResolver extends CubeSymbols
1 parent 417da79 commit f1c33a6

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { BaseQuery, PreAggregationDefinitionExtended } from '../adapter';
1717
import type { CubeValidator } from './CubeValidator';
1818
import type { ErrorReporter } from './ErrorReporter';
1919
import { CompilerInterface } from './PrepareCompiler';
20+
import { CubeJoinsResolver } from './CubeJoinsResolver';
2021

2122
export type SegmentDefinition = {
2223
type: string;
@@ -157,7 +158,7 @@ export interface EvaluatedCube {
157158
accessPolicy?: AccessPolicyDefinition[];
158159
}
159160

160-
export class CubeEvaluator extends CubeSymbols implements CompilerInterface {
161+
export class CubeEvaluator extends CubeJoinsResolver implements CompilerInterface {
161162
public evaluatedCubes: Record<string, EvaluatedCube> = {};
162163

163164
public primaryKeys: Record<string, string[]> = {};

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export class CubeJoinsResolver extends CubeSymbols implements CompilerInterface
1616
// 2nd level value: join definition
1717
private cubeJoinTargets: Record<string, Record<string, JoinDefinition>>;
1818

19-
public constructor() {
20-
super(false); // It seems that we don't need to evaluate views
19+
public constructor(evaluateViews = false) {
20+
super(evaluateViews);
2121
this.cubeJoins = {};
2222
this.cubeJoinAliases = {};
2323
this.cubeJoinTargets = {};
@@ -55,4 +55,19 @@ export class CubeJoinsResolver extends CubeSymbols implements CompilerInterface
5555
});
5656
});
5757
}
58+
59+
public resolveSymbol(cubeName: string | null, name: string) {
60+
if (this.isCurrentCube(name) && !cubeName) {
61+
return null;
62+
}
63+
64+
if (cubeName && this.cubeJoinAliases[cubeName]?.[name]) {
65+
// TODO: Write a full implementation
66+
// Some kind of proxy like in symbols
67+
68+
return super.resolveSymbol(cubeName, this.cubeJoinAliases[cubeName]?.[name].name);
69+
}
70+
71+
return super.resolveSymbol(cubeName, name);
72+
}
5873
}

0 commit comments

Comments
 (0)