semanticdb-core 1.0.29 → 1.0.30
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SchemaType } from '../schema/schema';
|
|
1
2
|
import { GroupbyItemType, LogicformType, PredItemType } from './logicform';
|
|
2
3
|
import { QueryType } from './types/query';
|
|
3
4
|
/**
|
|
@@ -73,3 +74,11 @@ export declare const getFlattenQuery: (query: QueryType) => QueryType;
|
|
|
73
74
|
* ```
|
|
74
75
|
*/
|
|
75
76
|
export declare const getValueByChain: (query: QueryType, chain: string) => any;
|
|
77
|
+
/**
|
|
78
|
+
* 肯定是返回flatten的dimension
|
|
79
|
+
* @param logicform
|
|
80
|
+
*/
|
|
81
|
+
export declare const getDimensionsInLogicform: (logicform: LogicformType, schemasDict: Record<string, SchemaType>) => {
|
|
82
|
+
_id: string;
|
|
83
|
+
level?: string;
|
|
84
|
+
}[];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getValueByChain = exports.getFlattenQuery = exports.isDimensionInLogicform = exports.isDimensionInPred = exports.isDimensionInGroupby = exports.isDimensionInQuery = void 0;
|
|
3
|
+
exports.getDimensionsInLogicform = exports.getValueByChain = exports.getFlattenQuery = exports.isDimensionInLogicform = exports.isDimensionInPred = exports.isDimensionInGroupby = exports.isDimensionInQuery = void 0;
|
|
4
4
|
const date_1 = require("../common/date");
|
|
5
|
+
const schema_utils_1 = require("../schema/schema.utils");
|
|
5
6
|
const tws = (0, date_1.getSupportedTimeWindows)();
|
|
6
7
|
/**
|
|
7
8
|
* 判断一个维度是否在查询中被使用
|
|
@@ -211,3 +212,28 @@ const getValueByChain = (query, chain) => {
|
|
|
211
212
|
return undefined;
|
|
212
213
|
};
|
|
213
214
|
exports.getValueByChain = getValueByChain;
|
|
215
|
+
/**
|
|
216
|
+
* 肯定是返回flatten的dimension
|
|
217
|
+
* @param logicform
|
|
218
|
+
*/
|
|
219
|
+
const getDimensionsInLogicform = (logicform, schemasDict) => {
|
|
220
|
+
const dimensions = [];
|
|
221
|
+
if (logicform.query) {
|
|
222
|
+
const flattenQuery = (0, exports.getFlattenQuery)(logicform.query);
|
|
223
|
+
for (const [k, v] of Object.entries(flattenQuery)) {
|
|
224
|
+
const property = (0, schema_utils_1.findPropertyByName)(logicform.schema, k, schemasDict);
|
|
225
|
+
if ((property === null || property === void 0 ? void 0 : property.primal_type) === 'date') {
|
|
226
|
+
const gran = (0, date_1.getMinGran)(v);
|
|
227
|
+
dimensions.push({ _id: k, level: gran || 'day' });
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
dimensions.push({ _id: k });
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (logicform.groupby) {
|
|
235
|
+
dimensions.push(...logicform.groupby);
|
|
236
|
+
}
|
|
237
|
+
return dimensions;
|
|
238
|
+
};
|
|
239
|
+
exports.getDimensionsInLogicform = getDimensionsInLogicform;
|