@cubejs-backend/api-gateway 1.8.6 → 1.8.7
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/gateway.d.ts +35 -1
- package/dist/src/gateway.d.ts.map +1 -1
- package/dist/src/gateway.js +176 -14
- package/dist/src/gateway.js.map +1 -1
- package/dist/src/helpers/prepare-annotation.d.ts +8 -3
- package/dist/src/helpers/prepare-annotation.d.ts.map +1 -1
- package/dist/src/helpers/prepare-annotation.js +11 -8
- package/dist/src/helpers/prepare-annotation.js.map +1 -1
- package/dist/src/helpers/to-config-map.d.ts +1 -1
- package/dist/src/helpers/to-config-map.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/interfaces.d.ts +1 -1
- package/dist/src/interfaces.d.ts.map +1 -1
- package/dist/src/query.d.ts +10 -2
- package/dist/src/query.d.ts.map +1 -1
- package/dist/src/query.js +29 -10
- package/dist/src/query.js.map +1 -1
- package/dist/src/sql-server.d.ts.map +1 -1
- package/dist/src/sql-server.js +31 -3
- package/dist/src/sql-server.js.map +1 -1
- package/dist/src/types/auth.d.ts +1 -1
- package/dist/src/types/auth.d.ts.map +1 -1
- package/dist/src/types/gateway.d.ts +1 -1
- package/dist/src/types/gateway.d.ts.map +1 -1
- package/dist/src/types/query.d.ts +1 -1
- package/dist/src/types/query.d.ts.map +1 -1
- package/dist/src/types/request.d.ts +10 -1
- package/dist/src/types/request.d.ts.map +1 -1
- package/dist/src/types/strings.d.ts +1 -1
- package/dist/src/types/strings.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/src/gateway.d.ts
CHANGED
|
@@ -198,11 +198,45 @@ declare class ApiGateway {
|
|
|
198
198
|
disablePostProcessing: boolean;
|
|
199
199
|
} & BaseRequest): Promise<void>;
|
|
200
200
|
sql({ query, context, res, memberToAlias, exportAnnotatedSql, memberExpressions, expressionParams, disableExternalPreAggregations, disableLimitEnforcing, }: QueryRequest): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Resolves member paths through the data model's joins, so a path through a
|
|
203
|
+
* join alias can be told apart from a time dimension with a granularity.
|
|
204
|
+
*/
|
|
205
|
+
protected memberPathResolver(context: RequestContext, compilerApi?: any): Promise<((path: string) => any) | undefined>;
|
|
206
|
+
/**
|
|
207
|
+
* The member paths a query names, in its raw or normalized form. Only
|
|
208
|
+
* `order` may name a time dimension with a granularity.
|
|
209
|
+
*/
|
|
210
|
+
private memberPaths;
|
|
211
|
+
/**
|
|
212
|
+
* Whether the query names a member by a path longer than `cube.member`,
|
|
213
|
+
* which takes the data model to read.
|
|
214
|
+
*/
|
|
215
|
+
protected hasLongMemberPaths(query: Query | NormalizedQuery): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* A member path is a cube or a cube instance reached through join aliases,
|
|
218
|
+
* and a member; other join paths are not part of the query format.
|
|
219
|
+
*/
|
|
220
|
+
protected checkMemberPaths(query: NormalizedQuery, resolve?: (path: string) => any): NormalizedQuery;
|
|
221
|
+
protected granularitySplitter(resolve?: (path: string) => any): ((path: string) => {
|
|
222
|
+
dimension: any;
|
|
223
|
+
granularity: any;
|
|
224
|
+
} | null | undefined) | undefined;
|
|
225
|
+
protected memberTarget(resolve?: (path: string) => any): ((path: string) => any) | undefined;
|
|
201
226
|
private hasExpressionsInQuery;
|
|
202
227
|
private parseMemberExpressionsInQuery;
|
|
203
228
|
private parseMemberExpression;
|
|
204
229
|
private evalMemberExpressionsInQuery;
|
|
205
230
|
private evalMemberExpression;
|
|
231
|
+
/**
|
|
232
|
+
* Which of `queries` a Cube Store pre-aggregation would serve, in order: cubesql asks
|
|
233
|
+
* before it renders SQL for Cube Store. Matching only, with the normalization `sql` gets.
|
|
234
|
+
*/
|
|
235
|
+
preAggregationMatch({ queries, context, res }: {
|
|
236
|
+
queries: Query[];
|
|
237
|
+
context: RequestContext;
|
|
238
|
+
res: ResponseResultFn;
|
|
239
|
+
}): Promise<void>;
|
|
206
240
|
sqlGenerators({ context, res }: {
|
|
207
241
|
context: RequestContext;
|
|
208
242
|
res: ResponseResultFn;
|
|
@@ -303,5 +337,5 @@ declare class ApiGateway {
|
|
|
303
337
|
protected liveness: RequestHandler;
|
|
304
338
|
release(): void;
|
|
305
339
|
}
|
|
306
|
-
export { UserBackgroundContext, ApiGatewayOptions, ApiGateway, };
|
|
340
|
+
export { type UserBackgroundContext, type ApiGatewayOptions, ApiGateway, };
|
|
307
341
|
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/gateway.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAQjC,OAAO,EAKL,SAAS,EACT,QAAQ,EACT,MAAM,wBAAwB,CAAC;AAQhC,OAAO,KAAK,EACV,WAAW,IAAI,kBAAkB,EACjC,mBAAmB,EAEnB,cAAc,EAEd,QAAQ,IAAI,eAAe,EAC5B,MAAM,SAAS,CAAC;AAIjB,OAAO,EACL,SAAS,EACT,SAAS,EACV,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EACL,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,OAAO,EACP,cAAc,EACd,0BAA0B,EAC1B,eAAe,EACf,gBAAgB,EAChB,YAAY,EAMZ,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,WAAW,EACX,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,EACL,eAAe,EAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,yBAAyB,EACzB,4BAA4B,EAC5B,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAE,kBAAkB,EAAE,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,WAAW,EAAE,mBAAmB,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,KAAA;IAoC3G,SAAS,CAAC,SAAS,EAAE,cAAc,CAEjC;IAEF,SAAS,CAAC,yBAAyB,EAAE,cAAc,CAEjD;IAEF,SAAS,CAAC,wBAAwB,EAAE,cAAc,CAchD;IAEF,SAAS,CAAC,aAAa,EAAE,cAAc,CAQrC;IAEF,SAAS,CAAC,eAAe,EAAE,cAAc,CAkBvC;IAEF,SAAS,CAAC,2BAA2B,CAAC,KAAK,KAAA;IAoCpC,GAAG,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAezF,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM;IAMxE,SAAS,CAAC,0BAA0B,GAAI,UAAU,MAAM,KAAG,cAAc,CAUvE;IAEF,OAAO,CAAC,aAAa;IASrB,SAAS,CAAC,SAAS,EAAE,cAAc,CAkBjC;IAEF,SAAS,CAAC,QAAQ,EAAE,cAAc,CAahC;IAEK,OAAO;CAKf;AACD,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,UAAU,GACX,CAAC"}
|
package/dist/src/gateway.js
CHANGED
|
@@ -86,6 +86,30 @@ function publicUsedPreAggregations(usedPreAggregations) {
|
|
|
86
86
|
.map((field) => [field, usage[field]])),
|
|
87
87
|
]));
|
|
88
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Descriptions the pushed-down SQL reads, one per table: a rollup read by several cube
|
|
91
|
+
* queries has its name swapped in once, so one read over different periods is read whole.
|
|
92
|
+
* Copies them, as a cube query's descriptions are shared through the SQL cache.
|
|
93
|
+
*/
|
|
94
|
+
function mergePreAggregationDescriptions(...descriptions) {
|
|
95
|
+
const merged = [];
|
|
96
|
+
for (const description of descriptions.flatMap((d) => d || [])) {
|
|
97
|
+
const known = description?.tableName !== undefined &&
|
|
98
|
+
merged.find((m) => m.tableName === description.tableName);
|
|
99
|
+
if (!known) {
|
|
100
|
+
merged.push({ ...description });
|
|
101
|
+
}
|
|
102
|
+
else if (JSON.stringify(known) !== JSON.stringify(description)) {
|
|
103
|
+
// Every usage of either description reads every partition
|
|
104
|
+
delete known.matchedTimeDimensionDateRange;
|
|
105
|
+
const usages = Object.entries({ ...known.usageMapping, ...description.usageMapping });
|
|
106
|
+
if (usages.length > 0) {
|
|
107
|
+
known.usageMapping = Object.fromEntries(usages.map(([suffix, usage]) => [suffix, { ...usage, dateRange: undefined }]));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return merged;
|
|
112
|
+
}
|
|
89
113
|
function hasDevTokenScope(securityContext) {
|
|
90
114
|
if (typeof securityContext !== 'object' || securityContext === null) {
|
|
91
115
|
return false;
|
|
@@ -1053,7 +1077,15 @@ class ApiGateway {
|
|
|
1053
1077
|
}, context);
|
|
1054
1078
|
const startTime = new Date().getTime();
|
|
1055
1079
|
const compilerApi = await this.getCompilerApi(context);
|
|
1056
|
-
|
|
1080
|
+
// The data model is read only for queries it takes to tell their paths apart
|
|
1081
|
+
let resolver;
|
|
1082
|
+
const normalize = async (q) => {
|
|
1083
|
+
const resolve = this.hasLongMemberPaths(q)
|
|
1084
|
+
? await (resolver ??= this.memberPathResolver(context, compilerApi))
|
|
1085
|
+
: undefined;
|
|
1086
|
+
return this.checkMemberPaths((0, query_1.normalizeQuery)(q, persistent, cacheMode, this.granularitySplitter(resolve)), resolve);
|
|
1087
|
+
};
|
|
1088
|
+
const queryNormalizationResult = await Promise.all(queries.map(async (currentQuery) => {
|
|
1057
1089
|
const hasExpressionsInQuery = this.hasExpressionsInQuery(currentQuery);
|
|
1058
1090
|
if (hasExpressionsInQuery) {
|
|
1059
1091
|
if (!memberExpressions) {
|
|
@@ -1065,10 +1097,10 @@ class ApiGateway {
|
|
|
1065
1097
|
throw new user_error_1.UserError('maskedMembers cannot be provided in the query');
|
|
1066
1098
|
}
|
|
1067
1099
|
return {
|
|
1068
|
-
normalizedQuery:
|
|
1100
|
+
normalizedQuery: await normalize(currentQuery),
|
|
1069
1101
|
hasExpressionsInQuery
|
|
1070
1102
|
};
|
|
1071
|
-
});
|
|
1103
|
+
}));
|
|
1072
1104
|
let normalizedQueries = await Promise.all(queryNormalizationResult.map(async ({ normalizedQuery, hasExpressionsInQuery }) => {
|
|
1073
1105
|
let evaluatedQuery = normalizedQuery;
|
|
1074
1106
|
if (hasExpressionsInQuery) {
|
|
@@ -1088,7 +1120,7 @@ class ApiGateway {
|
|
|
1088
1120
|
rewrittenQuery = this.parseMemberExpressionsInQuery(rewrittenQuery);
|
|
1089
1121
|
rewrittenQuery = this.evalMemberExpressionsInQuery(rewrittenQuery);
|
|
1090
1122
|
}
|
|
1091
|
-
return (
|
|
1123
|
+
return normalize(rewrittenQuery);
|
|
1092
1124
|
}));
|
|
1093
1125
|
this.log({
|
|
1094
1126
|
type: 'Query Rewrite completed',
|
|
@@ -1151,6 +1183,86 @@ class ApiGateway {
|
|
|
1151
1183
|
});
|
|
1152
1184
|
}
|
|
1153
1185
|
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Resolves member paths through the data model's joins, so a path through a
|
|
1188
|
+
* join alias can be told apart from a time dimension with a granularity.
|
|
1189
|
+
*/
|
|
1190
|
+
async memberPathResolver(context, compilerApi) {
|
|
1191
|
+
const api = compilerApi ?? await this.getCompilerApi(context);
|
|
1192
|
+
if (typeof api?.getCompilers !== 'function') {
|
|
1193
|
+
return undefined;
|
|
1194
|
+
}
|
|
1195
|
+
const { cubeEvaluator } = await api.getCompilers({ requestId: context.requestId });
|
|
1196
|
+
if (typeof cubeEvaluator?.resolveMemberPath !== 'function') {
|
|
1197
|
+
return undefined;
|
|
1198
|
+
}
|
|
1199
|
+
return (path) => cubeEvaluator.resolveMemberPath(path);
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* The member paths a query names, in its raw or normalized form. Only
|
|
1203
|
+
* `order` may name a time dimension with a granularity.
|
|
1204
|
+
*/
|
|
1205
|
+
memberPaths(query) {
|
|
1206
|
+
const filterMembers = (filters = []) => filters.flatMap(f => (f.and || f.or ? filterMembers(f.and || f.or) : [f.member ?? f.dimension]));
|
|
1207
|
+
const { order } = query;
|
|
1208
|
+
const orderMembers = Array.isArray(order)
|
|
1209
|
+
? order.map(o => (Array.isArray(o) ? o[0] : o?.id))
|
|
1210
|
+
: Object.keys(order || {});
|
|
1211
|
+
return {
|
|
1212
|
+
members: [
|
|
1213
|
+
...(query.measures || []),
|
|
1214
|
+
...(query.dimensions || []),
|
|
1215
|
+
...(query.segments || []),
|
|
1216
|
+
...(query.timeDimensions || []).map(td => td.dimension),
|
|
1217
|
+
...filterMembers(query.filters),
|
|
1218
|
+
],
|
|
1219
|
+
order: orderMembers,
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Whether the query names a member by a path longer than `cube.member`,
|
|
1224
|
+
* which takes the data model to read.
|
|
1225
|
+
*/
|
|
1226
|
+
hasLongMemberPaths(query) {
|
|
1227
|
+
const { members, order } = this.memberPaths(query);
|
|
1228
|
+
return [...members, ...order].some(path => typeof path === 'string' && path.split('.').length > 2);
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* A member path is a cube or a cube instance reached through join aliases,
|
|
1232
|
+
* and a member; other join paths are not part of the query format.
|
|
1233
|
+
*/
|
|
1234
|
+
checkMemberPaths(query, resolve) {
|
|
1235
|
+
if (!resolve) {
|
|
1236
|
+
return query;
|
|
1237
|
+
}
|
|
1238
|
+
const { members, order } = this.memberPaths(query);
|
|
1239
|
+
for (const path of [...members, ...order]) {
|
|
1240
|
+
const resolved = typeof path === 'string' ? resolve(path) : null;
|
|
1241
|
+
const memberPath = resolved && `${resolved.instancePath}.${resolved.member}`;
|
|
1242
|
+
if (resolved && resolved.fullPath !== memberPath) {
|
|
1243
|
+
throw new user_error_1.UserError(`'${path}' goes through joins that are not join aliases. Query it as '${memberPath}'`);
|
|
1244
|
+
}
|
|
1245
|
+
if (resolved?.granularity && members.includes(path)) {
|
|
1246
|
+
throw new user_error_1.UserError(`'${path}' names the '${resolved.granularity}' granularity of '${resolved.fullPath}'. Only dimensions and order can name a granularity; filter on '${resolved.fullPath}' instead`);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
return query;
|
|
1250
|
+
}
|
|
1251
|
+
granularitySplitter(resolve) {
|
|
1252
|
+
return resolve && ((path) => {
|
|
1253
|
+
const resolved = resolve(path);
|
|
1254
|
+
if (!resolved) {
|
|
1255
|
+
return undefined;
|
|
1256
|
+
}
|
|
1257
|
+
return resolved.granularity ? { dimension: resolved.fullPath, granularity: resolved.granularity } : null;
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
memberTarget(resolve) {
|
|
1261
|
+
return resolve && ((path) => {
|
|
1262
|
+
const resolved = resolve(path);
|
|
1263
|
+
return resolved?.aliased ? resolved.targetPath : undefined;
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1154
1266
|
hasExpressionsInQuery(query) {
|
|
1155
1267
|
const arraysToCheck = [
|
|
1156
1268
|
query.measures,
|
|
@@ -1255,6 +1367,34 @@ class ApiGateway {
|
|
|
1255
1367
|
}
|
|
1256
1368
|
throw new Error(`Unexpected member expression to evaluate: ${memberExpression}`);
|
|
1257
1369
|
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Which of `queries` a Cube Store pre-aggregation would serve, in order: cubesql asks
|
|
1372
|
+
* before it renders SQL for Cube Store. Matching only, with the normalization `sql` gets.
|
|
1373
|
+
*/
|
|
1374
|
+
async preAggregationMatch({ queries, context, res }) {
|
|
1375
|
+
const requestStarted = new Date();
|
|
1376
|
+
try {
|
|
1377
|
+
await this.assertApiScope('sql', context.securityContext);
|
|
1378
|
+
const compilerApi = await this.getCompilerApi(context);
|
|
1379
|
+
const matches = await Promise.all(queries.map(async (query) => {
|
|
1380
|
+
const [, normalizedQueries] = await this.getNormalizedQueries(query, context, true, true);
|
|
1381
|
+
const results = await Promise.all(normalizedQueries.map(async (normalizedQuery) => {
|
|
1382
|
+
const sqlQuery = await compilerApi.getSql(this.coerceForSqlQuery({ ...normalizedQuery, disableExternalPreAggregations: false }, context), { preAggregationsOnly: true });
|
|
1383
|
+
// A lambda rollup unioned with source data loads fresh rows with the filters of
|
|
1384
|
+
// one cube query, which the pushed-down SQL does not have in general
|
|
1385
|
+
return Boolean(sqlQuery.external) &&
|
|
1386
|
+
!(sqlQuery.preAggregations || []).some((p) => p.unionWithSourceData);
|
|
1387
|
+
}));
|
|
1388
|
+
return results.every(Boolean);
|
|
1389
|
+
}));
|
|
1390
|
+
await res({ matches });
|
|
1391
|
+
}
|
|
1392
|
+
catch (e) {
|
|
1393
|
+
this.handleError({
|
|
1394
|
+
e, context, query: queries, res, requestStarted
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1258
1398
|
async sqlGenerators({ context, res }) {
|
|
1259
1399
|
const requestStarted = new Date();
|
|
1260
1400
|
try {
|
|
@@ -1265,7 +1405,22 @@ class ApiGateway {
|
|
|
1265
1405
|
const memberToDataSource = await compilerApi.memberToDataSource(query);
|
|
1266
1406
|
const dataSources = new Set(Object.values(memberToDataSource));
|
|
1267
1407
|
const dataSourceToSqlGenerator = (await Promise.all([...dataSources].map(async (dataSource) => ({ [dataSource]: (await compilerApi.getSqlGenerator(query, dataSource)).sqlGenerator })))).reduce((a, b) => ({ ...a, ...b }), {});
|
|
1268
|
-
|
|
1408
|
+
// Cube Store is not a data source of the model, but SQL pushed down over a rollup
|
|
1409
|
+
// is rendered in its dialect, so it needs templates of its own. cubesql plans such
|
|
1410
|
+
// SQL only for scans whose members fit a rollup, so the rollups' members go along
|
|
1411
|
+
const anySqlGenerator = Object.values(dataSourceToSqlGenerator)[0];
|
|
1412
|
+
const externalPreAggregationMembers = (0, shared_1.getEnv)('sqlPushDownPreAggregations') ?
|
|
1413
|
+
await compilerApi.externalPreAggregationMembers() :
|
|
1414
|
+
[];
|
|
1415
|
+
const externalSqlGenerator = anySqlGenerator?.externalQueryClass && externalPreAggregationMembers.length > 0 ?
|
|
1416
|
+
anySqlGenerator.externalQuery() :
|
|
1417
|
+
undefined;
|
|
1418
|
+
await res({
|
|
1419
|
+
memberToDataSource,
|
|
1420
|
+
dataSourceToSqlGenerator,
|
|
1421
|
+
externalSqlGenerator,
|
|
1422
|
+
externalPreAggregationMembers,
|
|
1423
|
+
});
|
|
1269
1424
|
}
|
|
1270
1425
|
catch (e) {
|
|
1271
1426
|
this.handleError({
|
|
@@ -1580,13 +1735,14 @@ class ApiGateway {
|
|
|
1580
1735
|
requestId: context.requestId
|
|
1581
1736
|
});
|
|
1582
1737
|
metaConfigResult = this.filterVisibleItemsInMeta(context, metaConfigResult);
|
|
1738
|
+
const memberTarget = this.memberTarget(normalizedQueries.some(q => this.hasLongMemberPaths(q)) ? await this.memberPathResolver(context) : undefined);
|
|
1583
1739
|
const sqlQueries = await this.getSqlQueriesInternal(context, normalizedQueries);
|
|
1584
1740
|
let slowQuery = false;
|
|
1585
1741
|
const results = await Promise.all(normalizedQueries.map(async (normalizedQuery, index) => {
|
|
1586
1742
|
slowQuery = slowQuery ||
|
|
1587
1743
|
Boolean(sqlQueries[index].slowQuery);
|
|
1588
1744
|
const response = await this.getSqlResponseInternal(context, normalizedQuery, sqlQueries[index]);
|
|
1589
|
-
const annotation = (0, prepare_annotation_1.prepareAnnotation)(metaConfigResult, normalizedQuery);
|
|
1745
|
+
const annotation = (0, prepare_annotation_1.prepareAnnotation)(metaConfigResult, normalizedQuery, memberTarget);
|
|
1590
1746
|
return this.prepareResultTransformData(context, queryType, normalizedQuery, sqlQueries[index], annotation, response, resType);
|
|
1591
1747
|
}));
|
|
1592
1748
|
// A request may consist of several queries; the oldest refresh time
|
|
@@ -1641,8 +1797,13 @@ class ApiGateway {
|
|
|
1641
1797
|
requestId: context.requestId
|
|
1642
1798
|
});
|
|
1643
1799
|
metaConfigResult = this.filterVisibleItemsInMeta(context, metaConfigResult);
|
|
1800
|
+
const memberTarget = this.memberTarget(normalizedQueries.some(q => this.hasLongMemberPaths(q)) ? await this.memberPathResolver(context) : undefined);
|
|
1801
|
+
// A pushed down `sqlQuery` is rendered in the dialect of the data source it runs
|
|
1802
|
+
// on, so its cube query can only read a Cube Store rollup when cubesql rendered the
|
|
1803
|
+
// SQL on top for Cube Store and says so with `external`
|
|
1804
|
+
const external = Boolean(request.sqlQuery && request.external);
|
|
1644
1805
|
const sqlQueries = await this
|
|
1645
|
-
.getSqlQueriesInternal(context, normalizedQueries.map(q => ({ ...q, disableExternalPreAggregations: request.sqlQuery })));
|
|
1806
|
+
.getSqlQueriesInternal(context, normalizedQueries.map(q => ({ ...q, disableExternalPreAggregations: Boolean(request.sqlQuery) && !external })));
|
|
1646
1807
|
let results;
|
|
1647
1808
|
let slowQuery = false;
|
|
1648
1809
|
const streamResponse = async (sqlQuery) => {
|
|
@@ -1671,6 +1832,12 @@ class ApiGateway {
|
|
|
1671
1832
|
...sqlQueries[0],
|
|
1672
1833
|
// TODO Can we just pass through data? Ensure hidden members can't be queried
|
|
1673
1834
|
aliasNameToMember: null,
|
|
1835
|
+
// The SQL can be built over several cube queries, and `sqlQueries[0]` describes
|
|
1836
|
+
// one of them: the rollups the others read come along with the request
|
|
1837
|
+
...(external ? {
|
|
1838
|
+
external: true,
|
|
1839
|
+
preAggregations: mergePreAggregationDescriptions(sqlQueries[0].preAggregations, request.preAggregations),
|
|
1840
|
+
} : {}),
|
|
1674
1841
|
};
|
|
1675
1842
|
if (request.streaming) {
|
|
1676
1843
|
results = [await streamResponse(finalQuery)];
|
|
@@ -1678,7 +1845,7 @@ class ApiGateway {
|
|
|
1678
1845
|
else {
|
|
1679
1846
|
const adapterApi = await this.getAdapterApi(context);
|
|
1680
1847
|
const response = await adapterApi.executeQuery(finalQuery);
|
|
1681
|
-
const annotation = (0, prepare_annotation_1.prepareAnnotation)(metaConfigResult, normalizedQueries[0]);
|
|
1848
|
+
const annotation = (0, prepare_annotation_1.prepareAnnotation)(metaConfigResult, normalizedQueries[0], memberTarget);
|
|
1682
1849
|
// TODO Can we just pass through data? Ensure hidden members can't be queried
|
|
1683
1850
|
results = [{
|
|
1684
1851
|
/**
|
|
@@ -1706,11 +1873,6 @@ class ApiGateway {
|
|
|
1706
1873
|
// which is not a Playground path, and its result object carries
|
|
1707
1874
|
// none of the other dev-only fields either.
|
|
1708
1875
|
usedPreAggregations: publicUsedPreAggregations(response.usedPreAggregations),
|
|
1709
|
-
// Always false: this branch builds its sqlQuery with
|
|
1710
|
-
// `disableExternalPreAggregations` set (above), which makes
|
|
1711
|
-
// `externalPreAggregationQuery()` return false, and the
|
|
1712
|
-
// orchestrator only echoes that flag back. Mirrored anyway for
|
|
1713
|
-
// shape parity with `prepareResultTransformData`.
|
|
1714
1876
|
external: response.external,
|
|
1715
1877
|
}];
|
|
1716
1878
|
}
|
|
@@ -1720,7 +1882,7 @@ class ApiGateway {
|
|
|
1720
1882
|
results = await Promise.all(normalizedQueries.map(async (normalizedQuery, index) => {
|
|
1721
1883
|
slowQuery = slowQuery ||
|
|
1722
1884
|
Boolean(sqlQueries[index].slowQuery);
|
|
1723
|
-
const annotation = (0, prepare_annotation_1.prepareAnnotation)(metaConfigResult, normalizedQuery);
|
|
1885
|
+
const annotation = (0, prepare_annotation_1.prepareAnnotation)(metaConfigResult, normalizedQuery, memberTarget);
|
|
1724
1886
|
if (request.streaming) {
|
|
1725
1887
|
return streamResponse(sqlQueries[index]);
|
|
1726
1888
|
}
|