@devrev/meerkat-core 0.0.105 → 0.0.106
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/package.json +1 -1
- package/src/constants/exports/index.d.ts +1 -0
- package/src/constants/exports/index.js +5 -0
- package/src/constants/exports/index.js.map +1 -0
- package/src/get-wrapped-base-query-with-projections/get-aliased-columns-from-filters.d.ts +1 -1
- package/src/get-wrapped-base-query-with-projections/get-aliased-columns-from-filters.js.map +1 -1
- package/src/get-wrapped-base-query-with-projections/index.d.ts +3 -0
- package/src/get-wrapped-base-query-with-projections/index.js +9 -0
- package/src/get-wrapped-base-query-with-projections/index.js.map +1 -0
- package/src/get-wrapped-base-query-with-projections/modifiers/array-flatten-modifier.d.ts +4 -0
- package/src/get-wrapped-base-query-with-projections/modifiers/array-flatten-modifier.js +24 -0
- package/src/get-wrapped-base-query-with-projections/modifiers/array-flatten-modifier.js.map +1 -0
- package/src/get-wrapped-base-query-with-projections/modifiers/array-unnest-modifier.d.ts +4 -0
- package/src/get-wrapped-base-query-with-projections/modifiers/array-unnest-modifier.js +21 -0
- package/src/get-wrapped-base-query-with-projections/modifiers/array-unnest-modifier.js.map +1 -0
- package/src/get-wrapped-base-query-with-projections/sql-expression-modifiers.d.ts +2 -15
- package/src/get-wrapped-base-query-with-projections/sql-expression-modifiers.js +17 -21
- package/src/get-wrapped-base-query-with-projections/sql-expression-modifiers.js.map +1 -1
- package/src/get-wrapped-base-query-with-projections/types.d.ts +12 -0
- package/src/get-wrapped-base-query-with-projections/types.js +3 -0
- package/src/get-wrapped-base-query-with-projections/types.js.map +1 -0
- package/src/index.d.ts +6 -1
- package/src/index.js +7 -3
- package/src/index.js.map +1 -1
- package/src/member-formatters/constants.js.map +1 -1
- package/src/member-formatters/index.d.ts +1 -1
- package/src/member-formatters/index.js +2 -1
- package/src/member-formatters/index.js.map +1 -1
- package/src/resolution/generators/generate-resolution-join-paths.d.ts +4 -0
- package/src/resolution/generators/generate-resolution-join-paths.js +23 -0
- package/src/resolution/generators/generate-resolution-join-paths.js.map +1 -0
- package/src/resolution/generators/generate-resolution-schemas.d.ts +3 -0
- package/src/resolution/generators/generate-resolution-schemas.js +51 -0
- package/src/resolution/generators/generate-resolution-schemas.js.map +1 -0
- package/src/resolution/generators/generate-resolved-dimensions.d.ts +3 -0
- package/src/resolution/generators/generate-resolved-dimensions.js +25 -0
- package/src/resolution/generators/generate-resolved-dimensions.js.map +1 -0
- package/src/resolution/generators/generate-row-number-sql.d.ts +15 -0
- package/src/resolution/generators/generate-row-number-sql.js +35 -0
- package/src/resolution/generators/generate-row-number-sql.js.map +1 -0
- package/src/resolution/generators/index.d.ts +4 -0
- package/src/resolution/generators/index.js +8 -0
- package/src/resolution/generators/index.js.map +1 -0
- package/src/resolution/resolution.d.ts +50 -5
- package/src/resolution/resolution.js +73 -81
- package/src/resolution/resolution.js.map +1 -1
- package/src/resolution/steps/aggregation-step.d.ts +24 -0
- package/src/resolution/steps/aggregation-step.js +81 -0
- package/src/resolution/steps/aggregation-step.js.map +1 -0
- package/src/resolution/steps/resolution-step.d.ts +21 -0
- package/src/resolution/steps/resolution-step.js +85 -0
- package/src/resolution/steps/resolution-step.js.map +1 -0
- package/src/resolution/steps/unnest-step.d.ts +19 -0
- package/src/resolution/steps/unnest-step.js +28 -0
- package/src/resolution/steps/unnest-step.js.map +1 -0
- package/src/resolution/types.d.ts +2 -1
- package/src/resolution/types.js.map +1 -1
- package/src/types/cube-types/table.d.ts +1 -0
- package/src/utils/find-in-table-schema.js +8 -1
- package/src/utils/find-in-table-schema.js.map +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ROW_ID_DIMENSION_NAME = "__row_id";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../meerkat-core/src/constants/exports/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,UAAU,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MeerkatQueryFilter, Query, TableSchema } from '../types/cube-types';
|
|
2
|
-
import { Modifier } from './
|
|
2
|
+
import { Modifier } from './types';
|
|
3
3
|
export declare const getDimensionProjection: ({ key, tableSchema, modifiers, query, }: {
|
|
4
4
|
key: string;
|
|
5
5
|
tableSchema: TableSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-aliased-columns-from-filters.js","sourceRoot":"","sources":["../../../../meerkat-core/src/get-wrapped-base-query-with-projections/get-aliased-columns-from-filters.ts"],"names":[],"mappings":";;;AAAA,8DAAoE;AACpE,8GAAsG;AAEtG,wEAGuC;AACvC,
|
|
1
|
+
{"version":3,"file":"get-aliased-columns-from-filters.js","sourceRoot":"","sources":["../../../../meerkat-core/src/get-wrapped-base-query-with-projections/get-aliased-columns-from-filters.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MODIFIERS = exports.getModifiedSqlExpression = exports.getWrappedBaseQueryWithProjections = void 0;
|
|
4
|
+
var get_wrapped_base_query_with_projections_1 = require("./get-wrapped-base-query-with-projections");
|
|
5
|
+
Object.defineProperty(exports, "getWrappedBaseQueryWithProjections", { enumerable: true, get: function () { return get_wrapped_base_query_with_projections_1.getWrappedBaseQueryWithProjections; } });
|
|
6
|
+
var sql_expression_modifiers_1 = require("./sql-expression-modifiers");
|
|
7
|
+
Object.defineProperty(exports, "getModifiedSqlExpression", { enumerable: true, get: function () { return sql_expression_modifiers_1.getModifiedSqlExpression; } });
|
|
8
|
+
Object.defineProperty(exports, "MODIFIERS", { enumerable: true, get: function () { return sql_expression_modifiers_1.MODIFIERS; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../meerkat-core/src/get-wrapped-base-query-with-projections/index.ts"],"names":[],"mappings":";;;AAAA,qGAA+F;AAAtF,6JAAA,kCAAkC,OAAA;AAC3C,uEAGoC;AAFlC,oIAAA,wBAAwB,OAAA;AACxB,qHAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DimensionModifier, Modifier } from '../types';
|
|
2
|
+
export declare const arrayFlattenModifier: ({ sqlExpression, }: DimensionModifier) => string;
|
|
3
|
+
export declare const shouldFlattenArray: ({ dimension, }: DimensionModifier) => boolean;
|
|
4
|
+
export declare const arrayFlattenModifierConfig: Modifier;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrayFlattenModifierConfig = exports.shouldFlattenArray = exports.arrayFlattenModifier = void 0;
|
|
4
|
+
const is_array_member_type_1 = require("../../utils/is-array-member-type");
|
|
5
|
+
const arrayFlattenModifier = ({ sqlExpression, }) => {
|
|
6
|
+
// Ensure NULL or empty arrays produce at least one row with NULL value
|
|
7
|
+
// This prevents rows from being dropped when arrays are NULL or empty
|
|
8
|
+
// COALESCE handles NULL, and len() = 0 check handles empty arrays []
|
|
9
|
+
return `unnest(CASE WHEN ${sqlExpression} IS NULL OR len(COALESCE(${sqlExpression}, [])) = 0 THEN [NULL] ELSE ${sqlExpression} END)`;
|
|
10
|
+
};
|
|
11
|
+
exports.arrayFlattenModifier = arrayFlattenModifier;
|
|
12
|
+
const shouldFlattenArray = ({ dimension, }) => {
|
|
13
|
+
var _a;
|
|
14
|
+
const isArrayType = (0, is_array_member_type_1.isArrayTypeMember)(dimension.type);
|
|
15
|
+
const shouldFlattenArray = (_a = dimension.modifier) === null || _a === void 0 ? void 0 : _a.shouldFlattenArray;
|
|
16
|
+
return !!(isArrayType && shouldFlattenArray);
|
|
17
|
+
};
|
|
18
|
+
exports.shouldFlattenArray = shouldFlattenArray;
|
|
19
|
+
exports.arrayFlattenModifierConfig = {
|
|
20
|
+
name: 'shouldFlattenArray',
|
|
21
|
+
matcher: exports.shouldFlattenArray,
|
|
22
|
+
modifier: exports.arrayFlattenModifier,
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=array-flatten-modifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-flatten-modifier.js","sourceRoot":"","sources":["../../../../../meerkat-core/src/get-wrapped-base-query-with-projections/modifiers/array-flatten-modifier.ts"],"names":[],"mappings":";;;AAAA,2EAAqE;AAG9D,MAAM,oBAAoB,GAAG,CAAC,EACnC,aAAa,GACK,EAAU,EAAE;IAC9B,uEAAuE;IACvE,sEAAsE;IACtE,qEAAqE;IACrE,OAAO,oBAAoB,aAAa,4BAA4B,aAAa,+BAA+B,aAAa,OAAO,CAAC;AACvI,CAAC,CAAC;AAPW,QAAA,oBAAoB,wBAO/B;AAEK,MAAM,kBAAkB,GAAG,CAAC,EACjC,SAAS,GACS,EAAW,EAAE;;IAC/B,MAAM,WAAW,GAAG,IAAA,wCAAiB,EAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,kBAAkB,GAAG,MAAA,SAAS,CAAC,QAAQ,0CAAE,kBAAkB,CAAC;IAClE,OAAO,CAAC,CAAC,CAAC,WAAW,IAAI,kBAAkB,CAAC,CAAC;AAC/C,CAAC,CAAC;AANW,QAAA,kBAAkB,sBAM7B;AAEW,QAAA,0BAA0B,GAAa;IAClD,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,0BAAkB;IAC3B,QAAQ,EAAE,4BAAoB;CAC/B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DimensionModifier, Modifier } from '../types';
|
|
2
|
+
export declare const arrayFieldUnNestModifier: ({ sqlExpression, }: DimensionModifier) => string;
|
|
3
|
+
export declare const shouldUnnest: ({ dimension, query, }: DimensionModifier) => boolean;
|
|
4
|
+
export declare const arrayUnnestModifier: Modifier;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrayUnnestModifier = exports.shouldUnnest = exports.arrayFieldUnNestModifier = void 0;
|
|
4
|
+
const is_array_member_type_1 = require("../../utils/is-array-member-type");
|
|
5
|
+
const arrayFieldUnNestModifier = ({ sqlExpression, }) => {
|
|
6
|
+
return `array[unnest(${sqlExpression})]`;
|
|
7
|
+
};
|
|
8
|
+
exports.arrayFieldUnNestModifier = arrayFieldUnNestModifier;
|
|
9
|
+
const shouldUnnest = ({ dimension, query, }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const isArrayType = (0, is_array_member_type_1.isArrayTypeMember)(dimension.type);
|
|
12
|
+
const hasUnNestedGroupBy = (_a = dimension.modifier) === null || _a === void 0 ? void 0 : _a.shouldUnnestGroupBy;
|
|
13
|
+
return !!(isArrayType && hasUnNestedGroupBy && query.measures.length > 0);
|
|
14
|
+
};
|
|
15
|
+
exports.shouldUnnest = shouldUnnest;
|
|
16
|
+
exports.arrayUnnestModifier = {
|
|
17
|
+
name: 'shouldUnnestGroupBy',
|
|
18
|
+
matcher: exports.shouldUnnest,
|
|
19
|
+
modifier: exports.arrayFieldUnNestModifier,
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=array-unnest-modifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-unnest-modifier.js","sourceRoot":"","sources":["../../../../../meerkat-core/src/get-wrapped-base-query-with-projections/modifiers/array-unnest-modifier.ts"],"names":[],"mappings":";;;AAAA,2EAAqE;AAG9D,MAAM,wBAAwB,GAAG,CAAC,EACvC,aAAa,GACK,EAAU,EAAE;IAC9B,OAAO,gBAAgB,aAAa,IAAI,CAAC;AAC3C,CAAC,CAAC;AAJW,QAAA,wBAAwB,4BAInC;AAEK,MAAM,YAAY,GAAG,CAAC,EAC3B,SAAS,EACT,KAAK,GACa,EAAW,EAAE;;IAC/B,MAAM,WAAW,GAAG,IAAA,wCAAiB,EAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,kBAAkB,GAAG,MAAA,SAAS,CAAC,QAAQ,0CAAE,mBAAmB,CAAC;IACnE,OAAO,CAAC,CAAC,CAAC,WAAW,IAAI,kBAAkB,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC5E,CAAC,CAAC;AAPW,QAAA,YAAY,gBAOvB;AAEW,QAAA,mBAAmB,GAAa;IAC3C,IAAI,EAAE,qBAAqB;IAC3B,OAAO,EAAE,oBAAY;IACrB,QAAQ,EAAE,gCAAwB;CACnC,CAAC"}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface DimensionModifier {
|
|
3
|
-
sqlExpression: string;
|
|
4
|
-
dimension: Dimension;
|
|
5
|
-
key: string;
|
|
6
|
-
query: Query;
|
|
7
|
-
}
|
|
8
|
-
export declare const arrayFieldUnNestModifier: ({ sqlExpression }: DimensionModifier) => string;
|
|
9
|
-
export declare const shouldUnnest: ({ dimension, query }: DimensionModifier) => boolean;
|
|
10
|
-
export type Modifier = {
|
|
11
|
-
name: string;
|
|
12
|
-
matcher: (modifier: DimensionModifier) => boolean;
|
|
13
|
-
modifier: (modifier: DimensionModifier) => string;
|
|
14
|
-
};
|
|
1
|
+
import { DimensionModifier, Modifier } from './types';
|
|
15
2
|
export declare const MODIFIERS: Modifier[];
|
|
16
|
-
export declare const getModifiedSqlExpression: ({ sqlExpression, dimension, key, modifiers, query }: DimensionModifier & {
|
|
3
|
+
export declare const getModifiedSqlExpression: ({ sqlExpression, dimension, key, modifiers, query, }: DimensionModifier & {
|
|
17
4
|
modifiers: Modifier[];
|
|
18
5
|
}) => string;
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getModifiedSqlExpression = exports.MODIFIERS =
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
exports.arrayFieldUnNestModifier = arrayFieldUnNestModifier;
|
|
9
|
-
const shouldUnnest = ({ dimension, query }) => {
|
|
10
|
-
var _a;
|
|
11
|
-
const isArrayType = (0, is_array_member_type_1.isArrayTypeMember)(dimension.type);
|
|
12
|
-
const hasUnNestedGroupBy = (_a = dimension.modifier) === null || _a === void 0 ? void 0 : _a.shouldUnnestGroupBy;
|
|
13
|
-
return !!(isArrayType && hasUnNestedGroupBy && query.measures.length > 0);
|
|
14
|
-
};
|
|
15
|
-
exports.shouldUnnest = shouldUnnest;
|
|
16
|
-
exports.MODIFIERS = [{
|
|
17
|
-
name: 'shouldUnnestGroupBy',
|
|
18
|
-
matcher: exports.shouldUnnest,
|
|
19
|
-
modifier: exports.arrayFieldUnNestModifier
|
|
20
|
-
}];
|
|
21
|
-
const getModifiedSqlExpression = ({ sqlExpression, dimension, key, modifiers, query }) => {
|
|
3
|
+
exports.getModifiedSqlExpression = exports.MODIFIERS = void 0;
|
|
4
|
+
const array_flatten_modifier_1 = require("./modifiers/array-flatten-modifier");
|
|
5
|
+
const array_unnest_modifier_1 = require("./modifiers/array-unnest-modifier");
|
|
6
|
+
exports.MODIFIERS = [array_unnest_modifier_1.arrayUnnestModifier, array_flatten_modifier_1.arrayFlattenModifierConfig];
|
|
7
|
+
const getModifiedSqlExpression = ({ sqlExpression, dimension, key, modifiers, query, }) => {
|
|
22
8
|
let finalDimension = sqlExpression;
|
|
23
9
|
modifiers.forEach(({ modifier, matcher }) => {
|
|
24
|
-
const shouldModify = matcher({
|
|
10
|
+
const shouldModify = matcher({
|
|
11
|
+
sqlExpression: finalDimension,
|
|
12
|
+
dimension,
|
|
13
|
+
key,
|
|
14
|
+
query,
|
|
15
|
+
});
|
|
25
16
|
if (shouldModify) {
|
|
26
|
-
finalDimension = modifier({
|
|
17
|
+
finalDimension = modifier({
|
|
18
|
+
sqlExpression: finalDimension,
|
|
19
|
+
dimension,
|
|
20
|
+
key,
|
|
21
|
+
query,
|
|
22
|
+
});
|
|
27
23
|
}
|
|
28
24
|
});
|
|
29
25
|
return finalDimension;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-expression-modifiers.js","sourceRoot":"","sources":["../../../../meerkat-core/src/get-wrapped-base-query-with-projections/sql-expression-modifiers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sql-expression-modifiers.js","sourceRoot":"","sources":["../../../../meerkat-core/src/get-wrapped-base-query-with-projections/sql-expression-modifiers.ts"],"names":[],"mappings":";;;AAAA,+EAAgF;AAChF,6EAAwE;AAG3D,QAAA,SAAS,GAAG,CAAC,2CAAmB,EAAE,mDAA0B,CAAC,CAAC;AAEpE,MAAM,wBAAwB,GAAG,CAAC,EACvC,aAAa,EACb,SAAS,EACT,GAAG,EACH,SAAS,EACT,KAAK,GAGN,EAAE,EAAE;IACH,IAAI,cAAc,GAAW,aAAa,CAAC;IAC3C,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAC1C,MAAM,YAAY,GAAG,OAAO,CAAC;YAC3B,aAAa,EAAE,cAAc;YAC7B,SAAS;YACT,GAAG;YACH,KAAK;SACN,CAAC,CAAC;QACH,IAAI,YAAY,EAAE;YAChB,cAAc,GAAG,QAAQ,CAAC;gBACxB,aAAa,EAAE,cAAc;gBAC7B,SAAS;gBACT,GAAG;gBACH,KAAK;aACN,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;IACH,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AA3BW,QAAA,wBAAwB,4BA2BnC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dimension, Query } from '../types/cube-types';
|
|
2
|
+
export interface DimensionModifier {
|
|
3
|
+
sqlExpression: string;
|
|
4
|
+
dimension: Dimension;
|
|
5
|
+
key: string;
|
|
6
|
+
query: Query;
|
|
7
|
+
}
|
|
8
|
+
export type Modifier = {
|
|
9
|
+
name: string;
|
|
10
|
+
matcher: (modifier: DimensionModifier) => boolean;
|
|
11
|
+
modifier: (modifier: DimensionModifier) => string;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../meerkat-core/src/get-wrapped-base-query-with-projections/types.ts"],"names":[],"mappings":""}
|
package/src/index.d.ts
CHANGED
|
@@ -2,16 +2,21 @@ export * from './ast-builder/ast-builder';
|
|
|
2
2
|
export * from './ast-deserializer/ast-deserializer';
|
|
3
3
|
export * from './ast-serializer/ast-serializer';
|
|
4
4
|
export * from './ast-validator';
|
|
5
|
+
export * from './constants/exports';
|
|
5
6
|
export { detectApplyContextParamsToBaseSQL } from './context-params/context-params-ast';
|
|
6
7
|
export * from './cube-measure-transformer/cube-measure-transformer';
|
|
7
8
|
export * from './cube-to-duckdb/cube-filter-to-duckdb';
|
|
8
9
|
export { applyFilterParamsToBaseSQL, detectAllFilterParamsFromSQL, getFilterParamsAST, } from './filter-params/filter-params-ast';
|
|
9
10
|
export { getFilterParamsSQL } from './get-filter-params-sql/get-filter-params-sql';
|
|
10
11
|
export { getFinalBaseSQL } from './get-final-base-sql/get-final-base-sql';
|
|
11
|
-
export
|
|
12
|
+
export * from './get-wrapped-base-query-with-projections';
|
|
12
13
|
export * from './joins/joins';
|
|
13
14
|
export * from './member-formatters';
|
|
15
|
+
export * from './resolution/generators';
|
|
14
16
|
export * from './resolution/resolution';
|
|
17
|
+
export * from './resolution/steps/aggregation-step';
|
|
18
|
+
export * from './resolution/steps/resolution-step';
|
|
19
|
+
export * from './resolution/steps/unnest-step';
|
|
15
20
|
export * from './resolution/types';
|
|
16
21
|
export { FilterType } from './types/cube-types';
|
|
17
22
|
export * from './types/cube-types/index';
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.meerkatPlaceholderReplacer = exports.BASE_TABLE_NAME = exports.
|
|
3
|
+
exports.meerkatPlaceholderReplacer = exports.BASE_TABLE_NAME = exports.getFinalBaseSQL = exports.getFilterParamsSQL = exports.getFilterParamsAST = exports.detectAllFilterParamsFromSQL = exports.applyFilterParamsToBaseSQL = exports.detectApplyContextParamsToBaseSQL = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./ast-builder/ast-builder"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./ast-deserializer/ast-deserializer"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./ast-serializer/ast-serializer"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./ast-validator"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./constants/exports"), exports);
|
|
9
10
|
var context_params_ast_1 = require("./context-params/context-params-ast");
|
|
10
11
|
Object.defineProperty(exports, "detectApplyContextParamsToBaseSQL", { enumerable: true, get: function () { return context_params_ast_1.detectApplyContextParamsToBaseSQL; } });
|
|
11
12
|
tslib_1.__exportStar(require("./cube-measure-transformer/cube-measure-transformer"), exports);
|
|
@@ -18,11 +19,14 @@ var get_filter_params_sql_1 = require("./get-filter-params-sql/get-filter-params
|
|
|
18
19
|
Object.defineProperty(exports, "getFilterParamsSQL", { enumerable: true, get: function () { return get_filter_params_sql_1.getFilterParamsSQL; } });
|
|
19
20
|
var get_final_base_sql_1 = require("./get-final-base-sql/get-final-base-sql");
|
|
20
21
|
Object.defineProperty(exports, "getFinalBaseSQL", { enumerable: true, get: function () { return get_final_base_sql_1.getFinalBaseSQL; } });
|
|
21
|
-
|
|
22
|
-
Object.defineProperty(exports, "getWrappedBaseQueryWithProjections", { enumerable: true, get: function () { return get_wrapped_base_query_with_projections_1.getWrappedBaseQueryWithProjections; } });
|
|
22
|
+
tslib_1.__exportStar(require("./get-wrapped-base-query-with-projections"), exports);
|
|
23
23
|
tslib_1.__exportStar(require("./joins/joins"), exports);
|
|
24
24
|
tslib_1.__exportStar(require("./member-formatters"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./resolution/generators"), exports);
|
|
25
26
|
tslib_1.__exportStar(require("./resolution/resolution"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./resolution/steps/aggregation-step"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./resolution/steps/resolution-step"), exports);
|
|
29
|
+
tslib_1.__exportStar(require("./resolution/steps/unnest-step"), exports);
|
|
26
30
|
tslib_1.__exportStar(require("./resolution/types"), exports);
|
|
27
31
|
tslib_1.__exportStar(require("./types/cube-types/index"), exports);
|
|
28
32
|
tslib_1.__exportStar(require("./types/duckdb-serialization-types/index"), exports);
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../meerkat-core/src/index.ts"],"names":[],"mappings":";;;;AAAA,oEAA0C;AAC1C,8EAAoD;AACpD,0EAAgD;AAChD,0DAAgC;AAChC,0EAAwF;AAA/E,uIAAA,iCAAiC,OAAA;AAC1C,8FAAoE;AACpE,iFAAuD;AACvD,uEAI2C;AAHzC,+HAAA,0BAA0B,OAAA;AAC1B,iIAAA,4BAA4B,OAAA;AAC5B,uHAAA,kBAAkB,OAAA;AAEpB,uFAAmF;AAA1E,2HAAA,kBAAkB,OAAA;AAC3B,8EAA0E;AAAjE,qHAAA,eAAe,OAAA;AACxB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../meerkat-core/src/index.ts"],"names":[],"mappings":";;;;AAAA,oEAA0C;AAC1C,8EAAoD;AACpD,0EAAgD;AAChD,0DAAgC;AAChC,8DAAoC;AACpC,0EAAwF;AAA/E,uIAAA,iCAAiC,OAAA;AAC1C,8FAAoE;AACpE,iFAAuD;AACvD,uEAI2C;AAHzC,+HAAA,0BAA0B,OAAA;AAC1B,iIAAA,4BAA4B,OAAA;AAC5B,uHAAA,kBAAkB,OAAA;AAEpB,uFAAmF;AAA1E,2HAAA,kBAAkB,OAAA;AAC3B,8EAA0E;AAAjE,qHAAA,eAAe,OAAA;AACxB,oFAA0D;AAC1D,wDAA8B;AAC9B,8DAAoC;AACpC,kEAAwC;AACxC,kEAAwC;AACxC,8EAAoD;AACpD,6EAAmD;AACnD,yEAA+C;AAC/C,6DAAmC;AAEnC,mEAAyC;AACzC,mFAAyD;AACzD,wDAA8B;AAC9B,6CAAmD;AAA1C,2GAAA,eAAe,OAAA;AACxB,uEAA6C;AAC7C,4EAAkD;AAClD,qEAA2C;AAC3C,qFAAkF;AAAzE,0IAAA,0BAA0B,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../meerkat-core/src/member-formatters/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,GAAG,CAAC;AAC5B,QAAA,wBAAwB,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../meerkat-core/src/member-formatters/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,GAAG,CAAC;AAC5B,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAC7C,sEAAsE;AACtE,qDAAqD;AACxC,QAAA,sBAAsB,GAAG,KAAK,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { COLUMN_NAME_DELIMITER } from './constants';
|
|
1
|
+
export { COLUMN_NAME_DELIMITER, MEERKAT_OUTPUT_DELIMITER } from './constants';
|
|
2
2
|
export { constructAlias, getAliasFromSchema } from './get-alias';
|
|
3
3
|
export { getNamespacedKey } from './get-namespaced-key';
|
|
4
4
|
export { memberKeyToSafeKey } from './member-key-to-safe-key';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.splitIntoDataSourceAndFields = exports.memberKeyToSafeKey = exports.getNamespacedKey = exports.getAliasFromSchema = exports.constructAlias = exports.COLUMN_NAME_DELIMITER = void 0;
|
|
3
|
+
exports.splitIntoDataSourceAndFields = exports.memberKeyToSafeKey = exports.getNamespacedKey = exports.getAliasFromSchema = exports.constructAlias = exports.MEERKAT_OUTPUT_DELIMITER = exports.COLUMN_NAME_DELIMITER = void 0;
|
|
4
4
|
var constants_1 = require("./constants");
|
|
5
5
|
Object.defineProperty(exports, "COLUMN_NAME_DELIMITER", { enumerable: true, get: function () { return constants_1.COLUMN_NAME_DELIMITER; } });
|
|
6
|
+
Object.defineProperty(exports, "MEERKAT_OUTPUT_DELIMITER", { enumerable: true, get: function () { return constants_1.MEERKAT_OUTPUT_DELIMITER; } });
|
|
6
7
|
var get_alias_1 = require("./get-alias");
|
|
7
8
|
Object.defineProperty(exports, "constructAlias", { enumerable: true, get: function () { return get_alias_1.constructAlias; } });
|
|
8
9
|
Object.defineProperty(exports, "getAliasFromSchema", { enumerable: true, get: function () { return get_alias_1.getAliasFromSchema; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../meerkat-core/src/member-formatters/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../meerkat-core/src/member-formatters/index.ts"],"names":[],"mappings":";;;AAAA,yCAA8E;AAArE,kHAAA,qBAAqB,OAAA;AAAE,qHAAA,wBAAwB,OAAA;AACxD,yCAAiE;AAAxD,2GAAA,cAAc,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AAC3C,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,mEAA8D;AAArD,4HAAA,kBAAkB,OAAA;AAC3B,yFAAmF;AAA1E,iJAAA,4BAA4B,OAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { JoinPath } from '../../types/cube-types/query';
|
|
2
|
+
import { TableSchema } from '../../types/cube-types/table';
|
|
3
|
+
import { ResolutionConfig } from '../types';
|
|
4
|
+
export declare const generateResolutionJoinPaths: (baseDataSourceName: string, resolutionConfig: ResolutionConfig, baseTableSchemas: TableSchema[]) => JoinPath[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateResolutionJoinPaths = void 0;
|
|
4
|
+
const member_formatters_1 = require("../../member-formatters");
|
|
5
|
+
const find_in_table_schema_1 = require("../../utils/find-in-table-schema");
|
|
6
|
+
const generateResolutionJoinPaths = (baseDataSourceName, resolutionConfig, baseTableSchemas) => {
|
|
7
|
+
return resolutionConfig.columnConfigs.map((config) => {
|
|
8
|
+
var _a;
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
left: baseDataSourceName,
|
|
12
|
+
right: (0, member_formatters_1.memberKeyToSafeKey)(config.name),
|
|
13
|
+
on: (0, member_formatters_1.constructAlias)({
|
|
14
|
+
name: config.name,
|
|
15
|
+
alias: (_a = (0, find_in_table_schema_1.findInSchemas)(config.name, baseTableSchemas)) === null || _a === void 0 ? void 0 : _a.alias,
|
|
16
|
+
aliasContext: { isAstIdentifier: false },
|
|
17
|
+
}),
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.generateResolutionJoinPaths = generateResolutionJoinPaths;
|
|
23
|
+
//# sourceMappingURL=generate-resolution-join-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-resolution-join-paths.js","sourceRoot":"","sources":["../../../../../meerkat-core/src/resolution/generators/generate-resolution-join-paths.ts"],"names":[],"mappings":";;;AAAA,+DAA6E;AAG7E,2EAAiE;AAG1D,MAAM,2BAA2B,GAAG,CACzC,kBAA0B,EAC1B,gBAAkC,EAClC,gBAA+B,EACnB,EAAE;IACd,OAAO,gBAAgB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;;QAAC,OAAA;YACpD;gBACE,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,IAAA,sCAAkB,EAAC,MAAM,CAAC,IAAI,CAAC;gBACtC,EAAE,EAAE,IAAA,kCAAc,EAAC;oBACjB,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,KAAK,EAAE,MAAA,IAAA,oCAAa,EAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,0CAAE,KAAK;oBAC1D,YAAY,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE;iBACzC,CAAC;aACH;SACF,CAAA;KAAA,CAAC,CAAC;AACL,CAAC,CAAC;AAhBW,QAAA,2BAA2B,+BAgBtC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateResolutionSchemas = void 0;
|
|
4
|
+
const member_formatters_1 = require("../../member-formatters");
|
|
5
|
+
const find_in_table_schema_1 = require("../../utils/find-in-table-schema");
|
|
6
|
+
const generateResolutionSchemas = (config, baseTableSchemas) => {
|
|
7
|
+
const resolutionSchemas = [];
|
|
8
|
+
config.columnConfigs.forEach((colConfig) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const tableSchema = config.tableSchemas.find((ts) => ts.name === colConfig.source);
|
|
11
|
+
if (!tableSchema) {
|
|
12
|
+
throw new Error(`Table schema not found for ${colConfig.source}`);
|
|
13
|
+
}
|
|
14
|
+
const baseName = (0, member_formatters_1.memberKeyToSafeKey)(colConfig.name);
|
|
15
|
+
const baseAlias = (0, member_formatters_1.constructAlias)({
|
|
16
|
+
name: colConfig.name,
|
|
17
|
+
alias: (_a = (0, find_in_table_schema_1.findInSchemas)(colConfig.name, baseTableSchemas)) === null || _a === void 0 ? void 0 : _a.alias,
|
|
18
|
+
aliasContext: { isTableSchemaAlias: true },
|
|
19
|
+
});
|
|
20
|
+
// For each column that needs to be resolved, create a copy of the relevant table schema.
|
|
21
|
+
// We use the name of the column in the base query as the table schema name
|
|
22
|
+
// to avoid conflicts.
|
|
23
|
+
const resolutionSchema = {
|
|
24
|
+
name: baseName,
|
|
25
|
+
sql: tableSchema.sql,
|
|
26
|
+
measures: [],
|
|
27
|
+
dimensions: colConfig.resolutionColumns.map((col) => {
|
|
28
|
+
const dimension = (0, find_in_table_schema_1.findInDimensionSchemas)((0, member_formatters_1.getNamespacedKey)(colConfig.source, col), config.tableSchemas);
|
|
29
|
+
if (!dimension) {
|
|
30
|
+
throw new Error(`Dimension not found: ${col}`);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
// Need to create a new name due to limitations with how
|
|
34
|
+
// CubeToSql handles duplicate dimension names between different sources.
|
|
35
|
+
name: (0, member_formatters_1.memberKeyToSafeKey)((0, member_formatters_1.getNamespacedKey)(colConfig.name, col)),
|
|
36
|
+
sql: `${baseName}.${col}`,
|
|
37
|
+
type: dimension.type,
|
|
38
|
+
alias: `${baseAlias} - ${(0, member_formatters_1.constructAlias)({
|
|
39
|
+
name: col,
|
|
40
|
+
alias: dimension.alias,
|
|
41
|
+
aliasContext: { isTableSchemaAlias: true },
|
|
42
|
+
})}`,
|
|
43
|
+
};
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
resolutionSchemas.push(resolutionSchema);
|
|
47
|
+
});
|
|
48
|
+
return resolutionSchemas;
|
|
49
|
+
};
|
|
50
|
+
exports.generateResolutionSchemas = generateResolutionSchemas;
|
|
51
|
+
//# sourceMappingURL=generate-resolution-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-resolution-schemas.js","sourceRoot":"","sources":["../../../../../meerkat-core/src/resolution/generators/generate-resolution-schemas.ts"],"names":[],"mappings":";;;AAAA,+DAIiC;AAEjC,2EAG0C;AAGnC,MAAM,yBAAyB,GAAG,CACvC,MAAwB,EACxB,gBAA+B,EAC/B,EAAE;IACF,MAAM,iBAAiB,GAAkB,EAAE,CAAC;IAC5C,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;;QACzC,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAC1C,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,MAAM,CACrC,CAAC;QACF,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;SACnE;QAED,MAAM,QAAQ,GAAG,IAAA,sCAAkB,EAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,SAAS,GAAG,IAAA,kCAAc,EAAC;YAC/B,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,KAAK,EAAE,MAAA,IAAA,oCAAa,EAAC,SAAS,CAAC,IAAI,EAAE,gBAAgB,CAAC,0CAAE,KAAK;YAC7D,YAAY,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE;SAC3C,CAAC,CAAC;QAEH,yFAAyF;QACzF,2EAA2E;QAC3E,sBAAsB;QACtB,MAAM,gBAAgB,GAAgB;YACpC,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,WAAW,CAAC,GAAG;YACpB,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;gBAClD,MAAM,SAAS,GAAG,IAAA,6CAAsB,EACtC,IAAA,oCAAgB,EAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,EACvC,MAAM,CAAC,YAAY,CACpB,CAAC;gBACF,IAAI,CAAC,SAAS,EAAE;oBACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAC;iBAChD;gBACD,OAAO;oBACL,wDAAwD;oBACxD,yEAAyE;oBACzE,IAAI,EAAE,IAAA,sCAAkB,EAAC,IAAA,oCAAgB,EAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;oBAC/D,GAAG,EAAE,GAAG,QAAQ,IAAI,GAAG,EAAE;oBACzB,IAAI,EAAE,SAAS,CAAC,IAAI;oBACpB,KAAK,EAAE,GAAG,SAAS,MAAM,IAAA,kCAAc,EAAC;wBACtC,IAAI,EAAE,GAAG;wBACT,KAAK,EAAE,SAAS,CAAC,KAAK;wBACtB,YAAY,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE;qBAC3C,CAAC,EAAE;iBACL,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;QAEF,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAtDW,QAAA,yBAAyB,6BAsDpC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateResolvedDimensions = void 0;
|
|
4
|
+
const member_formatters_1 = require("../../member-formatters");
|
|
5
|
+
const generateResolvedDimensions = (baseDataSourceName, query, config, columnProjections) => {
|
|
6
|
+
// If column projections are provided, use those.
|
|
7
|
+
// Otherwise, use all measures and dimensions from the original query.
|
|
8
|
+
const aggregatedDimensions = columnProjections
|
|
9
|
+
? columnProjections
|
|
10
|
+
: [...query.measures, ...(query.dimensions || [])];
|
|
11
|
+
const resolvedDimensions = aggregatedDimensions.flatMap((dimension) => {
|
|
12
|
+
const columnConfig = config.columnConfigs.find((c) => c.name === dimension);
|
|
13
|
+
if (!columnConfig) {
|
|
14
|
+
return [
|
|
15
|
+
(0, member_formatters_1.getNamespacedKey)(baseDataSourceName, (0, member_formatters_1.memberKeyToSafeKey)(dimension)),
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return columnConfig.resolutionColumns.map((col) => (0, member_formatters_1.getNamespacedKey)((0, member_formatters_1.memberKeyToSafeKey)(dimension), (0, member_formatters_1.memberKeyToSafeKey)((0, member_formatters_1.getNamespacedKey)(columnConfig.name, col))));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return resolvedDimensions;
|
|
23
|
+
};
|
|
24
|
+
exports.generateResolvedDimensions = generateResolvedDimensions;
|
|
25
|
+
//# sourceMappingURL=generate-resolved-dimensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-resolved-dimensions.js","sourceRoot":"","sources":["../../../../../meerkat-core/src/resolution/generators/generate-resolved-dimensions.ts"],"names":[],"mappings":";;;AAAA,+DAA+E;AAIxE,MAAM,0BAA0B,GAAG,CACxC,kBAA0B,EAC1B,KAAY,EACZ,MAAwB,EACxB,iBAA4B,EAClB,EAAE;IACZ,iDAAiD;IACjD,sEAAsE;IACtE,MAAM,oBAAoB,GAAG,iBAAiB;QAC5C,CAAC,CAAC,iBAAiB;QACnB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC;IAErD,MAAM,kBAAkB,GAAa,oBAAoB,CAAC,OAAO,CAC/D,CAAC,SAAS,EAAE,EAAE;QACZ,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,CAC5C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAC5B,CAAC;QAEF,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;gBACL,IAAA,oCAAgB,EAAC,kBAAkB,EAAE,IAAA,sCAAkB,EAAC,SAAS,CAAC,CAAC;aACpE,CAAC;SACH;aAAM;YACL,OAAO,YAAY,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAChD,IAAA,oCAAgB,EACd,IAAA,sCAAkB,EAAC,SAAS,CAAC,EAC7B,IAAA,sCAAkB,EAAC,IAAA,oCAAgB,EAAC,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAC7D,CACF,CAAC;SACH;IACH,CAAC,CACF,CAAC;IACF,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC;AAjCW,QAAA,0BAA0B,8BAiCrC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates row_number() OVER (ORDER BY ...) SQL based on query order.
|
|
3
|
+
* This is used to preserve the original query ordering through resolution operations.
|
|
4
|
+
*
|
|
5
|
+
* @param query - The query object that may contain an order clause
|
|
6
|
+
* @param dimensions - The dimensions array from the base table schema
|
|
7
|
+
* @param baseTableName - The base table name to use in column references
|
|
8
|
+
* @returns SQL expression for row_number() OVER (ORDER BY ...)
|
|
9
|
+
*/
|
|
10
|
+
export declare const generateRowNumberSql: (query: {
|
|
11
|
+
order?: Record<string, string>;
|
|
12
|
+
}, dimensions: {
|
|
13
|
+
name: string;
|
|
14
|
+
alias?: string;
|
|
15
|
+
}[], baseTableName: string) => string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateRowNumberSql = void 0;
|
|
4
|
+
const member_formatters_1 = require("../../member-formatters");
|
|
5
|
+
/**
|
|
6
|
+
* Generates row_number() OVER (ORDER BY ...) SQL based on query order.
|
|
7
|
+
* This is used to preserve the original query ordering through resolution operations.
|
|
8
|
+
*
|
|
9
|
+
* @param query - The query object that may contain an order clause
|
|
10
|
+
* @param dimensions - The dimensions array from the base table schema
|
|
11
|
+
* @param baseTableName - The base table name to use in column references
|
|
12
|
+
* @returns SQL expression for row_number() OVER (ORDER BY ...)
|
|
13
|
+
*/
|
|
14
|
+
const generateRowNumberSql = (query, dimensions, baseTableName) => {
|
|
15
|
+
let rowNumberSql = 'row_number() OVER (';
|
|
16
|
+
if (query.order && Object.keys(query.order).length > 0) {
|
|
17
|
+
const orderClauses = Object.entries(query.order).map(([member, direction]) => {
|
|
18
|
+
// Find the actual column name/alias in the base table dimensions
|
|
19
|
+
const safeMember = (0, member_formatters_1.memberKeyToSafeKey)(member);
|
|
20
|
+
const dimension = dimensions.find((d) => d.name === safeMember || d.alias === safeMember);
|
|
21
|
+
const columnName = dimension
|
|
22
|
+
? dimension.alias || dimension.name
|
|
23
|
+
: safeMember;
|
|
24
|
+
return generateOrderClause(baseTableName, columnName, direction);
|
|
25
|
+
});
|
|
26
|
+
rowNumberSql += `ORDER BY ${orderClauses.join(', ')}`;
|
|
27
|
+
}
|
|
28
|
+
rowNumberSql += ')';
|
|
29
|
+
return rowNumberSql;
|
|
30
|
+
};
|
|
31
|
+
exports.generateRowNumberSql = generateRowNumberSql;
|
|
32
|
+
const generateOrderClause = (baseTableName, columnName, direction) => {
|
|
33
|
+
return `${baseTableName}."${columnName}" ${direction.toUpperCase()}`;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=generate-row-number-sql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-row-number-sql.js","sourceRoot":"","sources":["../../../../../meerkat-core/src/resolution/generators/generate-row-number-sql.ts"],"names":[],"mappings":";;;AAAA,+DAA6D;AAE7D;;;;;;;;GAQG;AACI,MAAM,oBAAoB,GAAG,CAClC,KAAyC,EACzC,UAA8C,EAC9C,aAAqB,EACb,EAAE;IACV,IAAI,YAAY,GAAG,qBAAqB,CAAC;IACzC,IAAI,KAAK,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;QACtD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAClD,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE;YACtB,iEAAiE;YACjE,MAAM,UAAU,GAAG,IAAA,sCAAkB,EAAC,MAAM,CAAC,CAAC;YAC9C,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAC/B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,CAAC,KAAK,KAAK,UAAU,CACvD,CAAC;YACF,MAAM,UAAU,GAAG,SAAS;gBAC1B,CAAC,CAAC,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,IAAI;gBACnC,CAAC,CAAC,UAAU,CAAC;YACf,OAAO,mBAAmB,CAAC,aAAa,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QACnE,CAAC,CACF,CAAC;QACF,YAAY,IAAI,YAAY,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACvD;IACD,YAAY,IAAI,GAAG,CAAC;IACpB,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAxBW,QAAA,oBAAoB,wBAwB/B;AAEF,MAAM,mBAAmB,GAAG,CAC1B,aAAqB,EACrB,UAAkB,EAClB,SAAiB,EACjB,EAAE;IACF,OAAO,GAAG,aAAa,KAAK,UAAU,KAAK,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;AACvE,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./generate-resolution-join-paths"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./generate-resolution-schemas"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./generate-resolved-dimensions"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./generate-row-number-sql"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../meerkat-core/src/resolution/generators/index.ts"],"names":[],"mappings":";;;AAAA,2EAAiD;AACjD,wEAA8C;AAC9C,yEAA+C;AAC/C,oEAA0C"}
|