Skip to content

Commit 2afa4de

Browse files
committed
refactor(schema-compiler): Make joinHintFromPath static
1 parent ebc178e commit 2afa4de

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

packages/cubejs-schema-compiler/src/adapter/BaseDimension.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { BaseQuery } from './BaseQuery';
22
import type { DimensionDefinition, SegmentDefinition } from '../compiler/CubeEvaluator';
3+
import { CubeSymbols } from "../compiler/CubeSymbols";
34

45
export class BaseDimension {
56
public readonly expression: any;
@@ -26,7 +27,7 @@ export class BaseDimension {
2627
// TODO move this `as` to static types
2728
const dimensionPath = dimension as string | null;
2829
if (dimensionPath !== null) {
29-
const { path, joinHint } = this.query.cubeEvaluator.joinHintFromPath(dimensionPath);
30+
const { path, joinHint } = CubeSymbols.joinHintFromPath(dimensionPath);
3031
this.dimension = path;
3132
this.joinHint = joinHint;
3233
}

packages/cubejs-schema-compiler/src/adapter/BaseMeasure.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { UserError } from '../compiler/UserError';
22
import type { BaseQuery } from './BaseQuery';
33
import { MeasureDefinition } from '../compiler/CubeEvaluator';
4+
import { CubeSymbols } from "../compiler/CubeSymbols";
45

56
export class BaseMeasure {
67
public readonly expression: any;
@@ -128,7 +129,7 @@ export class BaseMeasure {
128129
} else {
129130
// TODO move this `as` to static types
130131
const measurePath = measure as string;
131-
const { path, joinHint } = this.query.cubeEvaluator.joinHintFromPath(measurePath);
132+
const { path, joinHint } = CubeSymbols.joinHintFromPath(measurePath);
132133
this.measure = path;
133134
this.joinHint = joinHint;
134135
}

packages/cubejs-schema-compiler/src/adapter/BaseSegment.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { BaseQuery } from './BaseQuery';
2+
import { CubeSymbols } from "../compiler/CubeSymbols";
23

34
export class BaseSegment {
45
public readonly expression: any;
@@ -24,7 +25,7 @@ export class BaseSegment {
2425
} else {
2526
// TODO move this `as` to static types
2627
const segmentPath = segment as string;
27-
const { path, joinHint } = this.query.cubeEvaluator.joinHintFromPath(segmentPath);
28+
const { path, joinHint } = CubeSymbols.joinHintFromPath(segmentPath);
2829
this.segment = path;
2930
this.joinHint = joinHint;
3031
}

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import R from 'ramda';
22
import { FROM_PARTITION_RANGE, getEnv, TO_PARTITION_RANGE } from '@cubejs-backend/shared';
33

4+
import { CubeSymbols } from "../compiler/CubeSymbols";
45
import { UserError } from '../compiler/UserError';
56

67
export class PreAggregations {
@@ -173,7 +174,7 @@ export class PreAggregations {
173174

174175
// timeDimensionsReference[*].dimension can contain full join path, so we should trim it
175176
// TODO check full join path match here
176-
const timeDimensionReferenceDimension = this.query.cubeEvaluator.joinHintFromPath(timeDimensionReference.dimension).path;
177+
const timeDimensionReferenceDimension = CubeSymbols.joinHintFromPath(timeDimensionReference.dimension).path;
177178

178179
if (td.dimension === timeDimensionReferenceDimension) {
179180
return true;
@@ -1095,7 +1096,7 @@ export class PreAggregations {
10951096
!!references.dimensions.find((d) => {
10961097
// `d` can contain full join path, so we should trim it
10971098
// TODO check full join path match here
1098-
const trimmedDimension = this.query.cubeEvaluator.joinHintFromPath(d).path;
1099+
const trimmedDimension = CubeSymbols.joinHintFromPath(d).path;
10991100
return this.query.cubeEvaluator.dimensionByPath(trimmedDimension).primaryKey;
11001101
}),
11011102
});

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ export class CubeSymbols {
656656
* Split join path to member to join hint and member path: `A.B.C.D.E.dim` => `[A, B, C, D, E]` + `E.dim`
657657
* @param path
658658
*/
659-
public joinHintFromPath(path: string): { path: string, joinHint: Array<string> } {
659+
public static joinHintFromPath(path: string): { path: string, joinHint: Array<string> } {
660660
const parts = path.split('.');
661661
if (parts.length > 2) {
662662
// Path contains join path

0 commit comments

Comments
 (0)