@cubejs-backend/schema-compiler 0.35.79 → 0.35.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/adapter/BaseGroupFilter.d.ts.map +1 -1
- package/dist/src/adapter/BaseGroupFilter.js +1 -5
- package/dist/src/adapter/BaseGroupFilter.js.map +1 -1
- package/dist/src/adapter/BaseQuery.d.ts +9 -3
- package/dist/src/adapter/BaseQuery.d.ts.map +1 -1
- package/dist/src/adapter/BaseQuery.js +134 -27
- package/dist/src/adapter/BaseQuery.js.map +1 -1
- package/dist/src/adapter/PreAggregations.d.ts +2 -4
- package/dist/src/adapter/PreAggregations.d.ts.map +1 -1
- package/dist/src/adapter/PreAggregations.js +8 -34
- package/dist/src/adapter/PreAggregations.js.map +1 -1
- package/dist/src/compiler/CubeEvaluator.d.ts.map +1 -1
- package/dist/src/compiler/CubeEvaluator.js +5 -0
- package/dist/src/compiler/CubeEvaluator.js.map +1 -1
- package/dist/src/compiler/CubeValidator.d.ts.map +1 -1
- package/dist/src/compiler/CubeValidator.js +11 -2
- package/dist/src/compiler/CubeValidator.js.map +1 -1
- package/dist/src/compiler/transpilers/CubePropContextTranspiler.d.ts.map +1 -1
- package/dist/src/compiler/transpilers/CubePropContextTranspiler.js +1 -0
- package/dist/src/compiler/transpilers/CubePropContextTranspiler.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseGroupFilter.d.ts","sourceRoot":"","sources":["../../../src/adapter/BaseGroupFilter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseGroupFilter.d.ts","sourceRoot":"","sources":["../../../src/adapter/BaseGroupFilter.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAe;IAC1B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IAE/B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC;IAEjC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IAEhC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC;gBAEf,MAAM,EAAE,GAAG;IAOvB,cAAc,IAAI,OAAO;IAIzB,YAAY,CAAC,MAAM,KAAA;IAInB,aAAa;IAeb,YAAY;IAIZ,UAAU;CAQlB"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.BaseGroupFilter = void 0;
|
|
7
|
-
const ramda_1 = __importDefault(require("ramda"));
|
|
8
4
|
class BaseGroupFilter {
|
|
9
5
|
constructor(filter) {
|
|
10
6
|
this.values = filter.values;
|
|
@@ -25,7 +21,7 @@ class BaseGroupFilter {
|
|
|
25
21
|
return null;
|
|
26
22
|
}
|
|
27
23
|
return `(${sql})`;
|
|
28
|
-
}).filter(
|
|
24
|
+
}).filter(x => x).join(` ${this.operator.toUpperCase()} `);
|
|
29
25
|
if (!r.length) {
|
|
30
26
|
return null;
|
|
31
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseGroupFilter.js","sourceRoot":"","sources":["../../../src/adapter/BaseGroupFilter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseGroupFilter.js","sourceRoot":"","sources":["../../../src/adapter/BaseGroupFilter.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAe;IAS1B,YAAmB,MAAW;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,SAAS,GA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uery {
|
|
|
38
38
|
};
|
|
39
39
|
static contextSymbolsProxyFrom(symbols: any, allocateParam: any): any;
|
|
40
40
|
static extractFilterMembers(filter: any): any;
|
|
41
|
-
static findAndSubTreeForFilterGroup(filter: any, groupMembers: any, newGroupFilter: any): any;
|
|
42
|
-
static renderFilterParams(filter: any, filterParamArgs: any, allocateParam: any, newGroupFilter: any): any;
|
|
41
|
+
static findAndSubTreeForFilterGroup(filter: any, groupMembers: any, newGroupFilter: any, aliases: any): any;
|
|
42
|
+
static renderFilterParams(filter: any, filterParamArgs: any, allocateParam: any, newGroupFilter: any, aliases: any): any;
|
|
43
43
|
static filterProxyFromAllFilters(allFilters: any, cubeEvaluator: any, allocateParam: any, newGroupFilter: any): {};
|
|
44
44
|
/**
|
|
45
45
|
* BaseQuery class constructor.
|
|
@@ -355,7 +355,7 @@ export class BaseQuery {
|
|
|
355
355
|
withCubeAliasPrefix(cubeAliasPrefix: any, fn: any): any;
|
|
356
356
|
/**
|
|
357
357
|
* Evaluate escaped SQL-alias for cube or cube's property
|
|
358
|
-
* (measure,
|
|
358
|
+
* (measure, dimension).
|
|
359
359
|
* @param {string} cubeName
|
|
360
360
|
* @returns string
|
|
361
361
|
*/
|
|
@@ -430,6 +430,8 @@ export class BaseQuery {
|
|
|
430
430
|
evaluateIndexColumns(cube: any, index: any): any;
|
|
431
431
|
createIndexSql(indexName: any, tableName: any, escapedColumns: any): string;
|
|
432
432
|
preAggregationSql(cube: any, preAggregation: any): any;
|
|
433
|
+
preAggregationOutputColumnTypes(cube: any, preAggregation: any): any;
|
|
434
|
+
preAggregationUniqueKeyColumns(cube: any, preAggregation: any): any;
|
|
433
435
|
preAggregationReadOnly(_cube: any, _preAggregation: any): boolean;
|
|
434
436
|
preAggregationAllowUngroupingWithPrimaryKey(_cube: any, _preAggregation: any): boolean;
|
|
435
437
|
/**
|
|
@@ -489,6 +491,10 @@ export class BaseQuery {
|
|
|
489
491
|
contextSymbolsProxy(symbols: any): any;
|
|
490
492
|
filtersProxy(): {};
|
|
491
493
|
filterGroupFunction(): (...filterParamArgs: any[]) => string;
|
|
494
|
+
flattenAllMembers(excludeSegments?: boolean): any[];
|
|
495
|
+
allBackAliasMembersExceptSegments(): any;
|
|
496
|
+
allBackAliasMembers(): any;
|
|
497
|
+
backAliasMembers(members: any): any;
|
|
492
498
|
}
|
|
493
499
|
/**
|
|
494
500
|
* Set of the schema compilers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseQuery.d.ts","sourceRoot":"","sources":["../../../src/adapter/BaseQuery.js"],"names":[],"mappings":"AAmDA;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;GAYG;AACH;
|
|
1
|
+
{"version":3,"file":"BaseQuery.d.ts","sourceRoot":"","sources":["../../../src/adapter/BaseQuery.js"],"names":[],"mappings":"AAmDA;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;GAYG;AACH;IA+6EE,mDAEC;IAED;;MAEE;IACF,wCAEC;IA68BD;;;;;;;MASC;IAMD,sEAgCC;IAED,8CAcC;IAED,4GAsBC;IAYD,yHA0CC;IA8BD,mHA+CC;IA9lHD;;;;OAIG;IACH,uBAHW,SAAS,MAAE,gBAgBrB;IAZC,eAA0B;IAC1B,gEAAgE;IAChE,eADW,OAAO,2BAA2B,EAAE,aAAa,CAChB;IAC5C,wDAAwD;IACxD,WADW,OAAO,uBAAuB,EAAE,SAAS,CAChB;IACpC,aAA4B;IAk1D9B,4CAaC;IAnjDD;;;QA2BC;IAnUC,6BAA6B;IAC7B,gBADW,cAAc,CACiF;IAI5G,qDAoBC;IAED,sDAYC;IAED,2CAuDC;IAED;;OAEG;IACH,kCAiFC;IAhFC,oBAGC;IACD,mBAA0D;IAC1D,gBA4BE;IACF,UAA6B;IAC7B,wBAAyD;IACzD,cAAqC;IACrC,cAAqC;IACrC,YAAiC;IACjC,6CAAgD;IAChD,cAA6E;IAC7E,gBAAmF;IACnF,6BAA6G;IAC7G,iCAAyH;IACzH,cAA6E;IA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;IAED,kEAEC;IAED,uFAEC;IAED;;;OAGG;IACH,uBAFa,GAAG,CA8If;IAGD,yEAQC;IAED;;;;MA0BC;IAED;;;;MAwBC;IAED,6DAwBC;IAED,kGAoDC;IAED;;;;OAIG;IACH,kCAHW,MAAM,GACL,CAAC,MAAM,EAAE,MAAM,CAAC,CAW3B;IAED,sCAIC;IAED,2CAKC;IAED,+BAEC;IAED,8EAcC;IAED,4CAEC;IAED;;MAIC;IAED;;;;;;;;;;;;;;;OAeG;IACH,gCAHW,MAAM,GACL,MAAM,CAIjB;IAED,iGAqGC;IAED,0FAqBC;IAED,mEAcC;IAED,kCAcC;IAZG,qCASE;IAgBN,uCAEC;IA4ED,mBAQC;IA8CD,6DA0BC;IAmDD,oDAUC;IAED,yCAEC;IAED,2BAEC;IAED,oCAoBC;CACF;;;;;cAhqHa,OAAO,gCAAgC,EAAE,kBAAkB;qBAC3D,OAAO,mCAAmC,EAAE,qBAAqB;mBACjE,OAAO,2BAA2B,EAAE,aAAa;sBACjD,OAAO,8BAA8B,EAAE,gBAAgB;eACvD,OAAO,uBAAuB,EAAE,SAAS;mBACzC,OAAO,2BAA2B,EAAE,aAAa;;;+BAjChC,kBAAkB;gCACjB,mBAAmB;2BAJxB,cAAc;gCACT,mBAAmB;4BAJvB,eAAe;8BACb,iBAAiB;4BACnB,eAAe;kCAGT,qBAAqB;cAjBzC,OAAO;mBAGF,iBAAiB;uBAFb,aAAa"}
|
|
@@ -350,7 +350,7 @@ class BaseQuery {
|
|
|
350
350
|
return 'AS';
|
|
351
351
|
}
|
|
352
352
|
defaultOrder() {
|
|
353
|
-
if (this.options.preAggregationQuery) {
|
|
353
|
+
if (this.options.preAggregationQuery || this.options.totalQuery) {
|
|
354
354
|
return [];
|
|
355
355
|
}
|
|
356
356
|
const res = [];
|
|
@@ -1621,14 +1621,16 @@ class BaseQuery {
|
|
|
1621
1621
|
const memberPathArray = [cubeName, name];
|
|
1622
1622
|
const memberPath = this.cubeEvaluator.pathFromArray(memberPathArray);
|
|
1623
1623
|
let type = memberExpressionType;
|
|
1624
|
-
if (!type
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1624
|
+
if (!type) {
|
|
1625
|
+
if (this.cubeEvaluator.isMeasure(memberPathArray)) {
|
|
1626
|
+
type = 'measure';
|
|
1627
|
+
}
|
|
1628
|
+
else if (this.cubeEvaluator.isDimension(memberPathArray)) {
|
|
1629
|
+
type = 'dimension';
|
|
1630
|
+
}
|
|
1631
|
+
else if (this.cubeEvaluator.isSegment(memberPathArray)) {
|
|
1632
|
+
type = 'segment';
|
|
1633
|
+
}
|
|
1632
1634
|
}
|
|
1633
1635
|
const parentMember = this.safeEvaluateSymbolContext().currentMember;
|
|
1634
1636
|
if (this.safeEvaluateSymbolContext().memberChildren && parentMember) {
|
|
@@ -1769,7 +1771,7 @@ class BaseQuery {
|
|
|
1769
1771
|
}
|
|
1770
1772
|
/**
|
|
1771
1773
|
* Evaluate escaped SQL-alias for cube or cube's property
|
|
1772
|
-
* (measure,
|
|
1774
|
+
* (measure, dimension).
|
|
1773
1775
|
* @param {string} cubeName
|
|
1774
1776
|
* @returns string
|
|
1775
1777
|
*/
|
|
@@ -2078,9 +2080,11 @@ class BaseQuery {
|
|
|
2078
2080
|
return new QueryClass(this.compilers, this.subQueryOptions(options));
|
|
2079
2081
|
}
|
|
2080
2082
|
newSubQueryForCube(cube, options) {
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2083
|
+
if (this.options.queryFactory) {
|
|
2084
|
+
options.paramAllocator = null;
|
|
2085
|
+
return this.options.queryFactory.createQuery(cube, this.compilers, this.subQueryOptions(options));
|
|
2086
|
+
}
|
|
2087
|
+
return this.newSubQuery(options);
|
|
2084
2088
|
}
|
|
2085
2089
|
subQueryOptions(options) {
|
|
2086
2090
|
return {
|
|
@@ -2239,6 +2243,47 @@ class BaseQuery {
|
|
|
2239
2243
|
throw new UserError_1.UserError(`Unknown pre-aggregation type '${preAggregation.type}' in '${cube}'`);
|
|
2240
2244
|
}, { inputProps: { collectOriginalSqlPreAggregations: [] }, cache: this.queryCache });
|
|
2241
2245
|
}
|
|
2246
|
+
preAggregationOutputColumnTypes(cube, preAggregation) {
|
|
2247
|
+
return this.cacheValue(['preAggregationOutputColumnTypes', cube, JSON.stringify(preAggregation)], () => {
|
|
2248
|
+
if (!preAggregation.outputColumnTypes) {
|
|
2249
|
+
return null;
|
|
2250
|
+
}
|
|
2251
|
+
if (preAggregation.type === 'rollup') {
|
|
2252
|
+
const query = this.preAggregations.rollupPreAggregationQuery(cube, preAggregation);
|
|
2253
|
+
const evaluatedMapOutputColumnTypes = preAggregation.outputColumnTypes.reduce((acc, outputColumnType) => {
|
|
2254
|
+
acc.set(outputColumnType.name, outputColumnType);
|
|
2255
|
+
return acc;
|
|
2256
|
+
}, new Map());
|
|
2257
|
+
const findSchemaType = member => {
|
|
2258
|
+
const outputSchemaType = evaluatedMapOutputColumnTypes.get(member);
|
|
2259
|
+
if (!outputSchemaType) {
|
|
2260
|
+
throw new UserError_1.UserError(`Output schema type for ${member} not found in pre-aggregation ${preAggregation}`);
|
|
2261
|
+
}
|
|
2262
|
+
return {
|
|
2263
|
+
name: this.aliasName(member),
|
|
2264
|
+
type: outputSchemaType.type,
|
|
2265
|
+
};
|
|
2266
|
+
};
|
|
2267
|
+
// The order of the output columns is important, it should match the order in the select statement
|
|
2268
|
+
const outputColumnTypes = [
|
|
2269
|
+
...(query.dimensions || []).map(d => findSchemaType(d.dimension)),
|
|
2270
|
+
...(query.timeDimensions || []).map(t => ({
|
|
2271
|
+
name: `${this.aliasName(t.dimension)}_${t.granularity}`,
|
|
2272
|
+
type: 'TIMESTAMP'
|
|
2273
|
+
})),
|
|
2274
|
+
...(query.measures || []).map(m => findSchemaType(m.measure)),
|
|
2275
|
+
];
|
|
2276
|
+
return outputColumnTypes;
|
|
2277
|
+
}
|
|
2278
|
+
throw new UserError_1.UserError('Output schema is only supported for rollup pre-aggregations');
|
|
2279
|
+
}, { inputProps: {}, cache: this.queryCache });
|
|
2280
|
+
}
|
|
2281
|
+
preAggregationUniqueKeyColumns(cube, preAggregation) {
|
|
2282
|
+
if (preAggregation.uniqueKeyColumns) {
|
|
2283
|
+
return preAggregation.uniqueKeyColumns.map(key => this.aliasName(`${cube}.${key}`));
|
|
2284
|
+
}
|
|
2285
|
+
return this.dimensionColumns();
|
|
2286
|
+
}
|
|
2242
2287
|
preAggregationReadOnly(_cube, _preAggregation) {
|
|
2243
2288
|
return false;
|
|
2244
2289
|
}
|
|
@@ -2730,25 +2775,30 @@ class BaseQuery {
|
|
|
2730
2775
|
if (filter.operator === 'and' || filter.operator === 'or') {
|
|
2731
2776
|
return filter.values.map(f => BaseQuery.extractFilterMembers(f)).reduce((a, b) => ((a && b) ? { ...a, ...b } : null), {});
|
|
2732
2777
|
}
|
|
2733
|
-
else if (filter.measure
|
|
2778
|
+
else if (filter.measure) {
|
|
2779
|
+
return {
|
|
2780
|
+
[filter.measure]: true
|
|
2781
|
+
};
|
|
2782
|
+
}
|
|
2783
|
+
else if (filter.dimension) {
|
|
2734
2784
|
return {
|
|
2735
|
-
[filter.
|
|
2785
|
+
[filter.dimension]: true
|
|
2736
2786
|
};
|
|
2737
2787
|
}
|
|
2738
2788
|
else {
|
|
2739
2789
|
return null;
|
|
2740
2790
|
}
|
|
2741
2791
|
}
|
|
2742
|
-
static findAndSubTreeForFilterGroup(filter, groupMembers, newGroupFilter) {
|
|
2792
|
+
static findAndSubTreeForFilterGroup(filter, groupMembers, newGroupFilter, aliases) {
|
|
2743
2793
|
if ((filter.operator === 'and' || filter.operator === 'or') && !filter.values?.length) {
|
|
2744
2794
|
return null;
|
|
2745
2795
|
}
|
|
2746
2796
|
const filterMembers = BaseQuery.extractFilterMembers(filter);
|
|
2747
|
-
if (filterMembers && Object.keys(filterMembers).every(m => groupMembers.indexOf(m) !== -1)) {
|
|
2797
|
+
if (filterMembers && Object.keys(filterMembers).every(m => (groupMembers.indexOf(m) !== -1 || aliases.indexOf(m) !== -1))) {
|
|
2748
2798
|
return filter;
|
|
2749
2799
|
}
|
|
2750
2800
|
if (filter.operator === 'and') {
|
|
2751
|
-
const result = filter.values.map(f => BaseQuery.findAndSubTreeForFilterGroup(f, groupMembers, newGroupFilter)).filter(f => !!f);
|
|
2801
|
+
const result = filter.values.map(f => BaseQuery.findAndSubTreeForFilterGroup(f, groupMembers, newGroupFilter, aliases)).filter(f => !!f);
|
|
2752
2802
|
if (!result.length) {
|
|
2753
2803
|
return null;
|
|
2754
2804
|
}
|
|
@@ -2766,18 +2816,24 @@ class BaseQuery {
|
|
|
2766
2816
|
const { allFilters } = this;
|
|
2767
2817
|
return BaseQuery.filterProxyFromAllFilters(allFilters, this.cubeEvaluator, this.paramAllocator.allocateParam.bind(this.paramAllocator), this.newGroupFilter.bind(this));
|
|
2768
2818
|
}
|
|
2769
|
-
static renderFilterParams(filter, filterParamArgs, allocateParam, newGroupFilter) {
|
|
2819
|
+
static renderFilterParams(filter, filterParamArgs, allocateParam, newGroupFilter, aliases) {
|
|
2770
2820
|
if (!filter) {
|
|
2771
2821
|
return '1 = 1';
|
|
2772
2822
|
}
|
|
2773
2823
|
if (filter.operator === 'and' || filter.operator === 'or') {
|
|
2774
2824
|
const values = filter.values
|
|
2775
|
-
.map(f => BaseQuery.renderFilterParams(f, filterParamArgs, allocateParam, newGroupFilter))
|
|
2825
|
+
.map(f => BaseQuery.renderFilterParams(f, filterParamArgs, allocateParam, newGroupFilter, aliases))
|
|
2776
2826
|
.map(v => ({ filterToWhere: () => v }));
|
|
2777
2827
|
return newGroupFilter({ operator: filter.operator, values }).filterToWhere();
|
|
2778
2828
|
}
|
|
2779
|
-
const filterParams = filter
|
|
2780
|
-
const filterParamArg = filterParamArgs.filter(p =>
|
|
2829
|
+
const filterParams = filter.filterParams();
|
|
2830
|
+
const filterParamArg = filterParamArgs.filter(p => {
|
|
2831
|
+
const member = p.__member();
|
|
2832
|
+
return member === filter.measure ||
|
|
2833
|
+
member === filter.dimension ||
|
|
2834
|
+
(aliases[member] && (aliases[member] === filter.measure ||
|
|
2835
|
+
aliases[member] === filter.dimension));
|
|
2836
|
+
})[0];
|
|
2781
2837
|
if (!filterParamArg) {
|
|
2782
2838
|
throw new Error(`FILTER_PARAMS arg not found for ${filter.measure || filter.dimension}`);
|
|
2783
2839
|
}
|
|
@@ -2805,13 +2861,18 @@ class BaseQuery {
|
|
|
2805
2861
|
}
|
|
2806
2862
|
return f.__member();
|
|
2807
2863
|
});
|
|
2808
|
-
const
|
|
2809
|
-
|
|
2864
|
+
const aliases = allFilters ?
|
|
2865
|
+
allFilters
|
|
2866
|
+
.map(v => (v.query ? v.query.allBackAliasMembersExceptSegments() : {}))
|
|
2867
|
+
.reduce((a, b) => ({ ...a, ...b }), {})
|
|
2868
|
+
: {};
|
|
2869
|
+
const filter = BaseQuery.findAndSubTreeForFilterGroup(newGroupFilter({ operator: 'and', values: allFilters }), groupMembers, newGroupFilter, Object.values(aliases));
|
|
2870
|
+
return `(${BaseQuery.renderFilterParams(filter, filterParamArgs, allocateParam, newGroupFilter, aliases)})`;
|
|
2810
2871
|
};
|
|
2811
2872
|
}
|
|
2812
2873
|
static filterProxyFromAllFilters(allFilters, cubeEvaluator, allocateParam, newGroupFilter) {
|
|
2813
2874
|
return new Proxy({}, {
|
|
2814
|
-
get: (
|
|
2875
|
+
get: (_target, name) => {
|
|
2815
2876
|
if (name === '_objectWithResolvedProperties') {
|
|
2816
2877
|
return true;
|
|
2817
2878
|
}
|
|
@@ -2828,8 +2889,22 @@ class BaseQuery {
|
|
|
2828
2889
|
return cubeEvaluator.pathFromArray([cubeNameObj.cube, propertyName]);
|
|
2829
2890
|
},
|
|
2830
2891
|
toString() {
|
|
2831
|
-
|
|
2832
|
-
|
|
2892
|
+
// Segments should be excluded because they are evaluated separately in cubeReferenceProxy
|
|
2893
|
+
// In other case this falls into the recursive loop/stack exceeded caused by:
|
|
2894
|
+
// collectFrom() -> traverseSymbol() -> evaluateSymbolSql() ->
|
|
2895
|
+
// evaluateSql() -> resolveSymbolsCall() -> cubeReferenceProxy->toString() ->
|
|
2896
|
+
// evaluateSymbolSql() -> evaluateSql()... -> and got here again
|
|
2897
|
+
const aliases = allFilters ?
|
|
2898
|
+
allFilters
|
|
2899
|
+
.map(v => (v.query ? v.query.allBackAliasMembersExceptSegments() : {}))
|
|
2900
|
+
.reduce((a, b) => ({ ...a, ...b }), {})
|
|
2901
|
+
: {};
|
|
2902
|
+
// Filtering aliases that somehow relate to this cube
|
|
2903
|
+
const filteredAliases = Object.entries(aliases)
|
|
2904
|
+
.filter(([key, value]) => key.startsWith(cubeNameObj.cube) || value.startsWith(cubeNameObj.cube))
|
|
2905
|
+
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
|
|
2906
|
+
const filter = BaseQuery.findAndSubTreeForFilterGroup(newGroupFilter({ operator: 'and', values: allFilters }), [cubeEvaluator.pathFromArray([cubeNameObj.cube, propertyName])], newGroupFilter, Object.values(filteredAliases));
|
|
2907
|
+
return `(${BaseQuery.renderFilterParams(filter, [this], allocateParam, newGroupFilter, aliases)})`;
|
|
2833
2908
|
}
|
|
2834
2909
|
})
|
|
2835
2910
|
})
|
|
@@ -2837,6 +2912,38 @@ class BaseQuery {
|
|
|
2837
2912
|
}
|
|
2838
2913
|
});
|
|
2839
2914
|
}
|
|
2915
|
+
flattenAllMembers(excludeSegments = false) {
|
|
2916
|
+
return ramda_1.default.flatten(this.measures
|
|
2917
|
+
.concat(this.dimensions)
|
|
2918
|
+
.concat(excludeSegments ? [] : this.segments)
|
|
2919
|
+
.concat(this.filters)
|
|
2920
|
+
.concat(this.measureFilters)
|
|
2921
|
+
.concat(this.timeDimensions)
|
|
2922
|
+
.map(m => m.getMembers()));
|
|
2923
|
+
}
|
|
2924
|
+
allBackAliasMembersExceptSegments() {
|
|
2925
|
+
return this.backAliasMembers(this.flattenAllMembers(true));
|
|
2926
|
+
}
|
|
2927
|
+
allBackAliasMembers() {
|
|
2928
|
+
return this.backAliasMembers(this.flattenAllMembers());
|
|
2929
|
+
}
|
|
2930
|
+
backAliasMembers(members) {
|
|
2931
|
+
const query = this;
|
|
2932
|
+
return members.map(member => {
|
|
2933
|
+
const collectedMembers = query
|
|
2934
|
+
.collectFrom([member], query.collectMemberNamesFor.bind(query), 'collectMemberNamesFor');
|
|
2935
|
+
const memberPath = member.expressionPath();
|
|
2936
|
+
let nonAliasSeen = false;
|
|
2937
|
+
return collectedMembers
|
|
2938
|
+
.filter(d => {
|
|
2939
|
+
if (!query.cubeEvaluator.byPathAnyType(d).aliasMember) {
|
|
2940
|
+
nonAliasSeen = true;
|
|
2941
|
+
}
|
|
2942
|
+
return !nonAliasSeen;
|
|
2943
|
+
})
|
|
2944
|
+
.map(d => ({ [query.cubeEvaluator.byPathAnyType(d).aliasMember]: memberPath })).reduce((a, b) => ({ ...a, ...b }), {});
|
|
2945
|
+
}).reduce((a, b) => ({ ...a, ...b }), {});
|
|
2946
|
+
}
|
|
2840
2947
|
}
|
|
2841
2948
|
exports.BaseQuery = BaseQuery;
|
|
2842
2949
|
//# sourceMappingURL=BaseQuery.js.map
|