@milaboratories/pl-model-common 1.24.1 → 1.24.2
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/drivers/pframe/index.d.ts +1 -0
- package/dist/drivers/pframe/index.d.ts.map +1 -1
- package/dist/drivers/pframe/query/index.d.ts +3 -0
- package/dist/drivers/pframe/query/index.d.ts.map +1 -0
- package/dist/drivers/pframe/query/query_common.d.ts +791 -0
- package/dist/drivers/pframe/query/query_common.d.ts.map +1 -0
- package/dist/drivers/pframe/query/query_data.d.ts +66 -0
- package/dist/drivers/pframe/query/query_data.d.ts.map +1 -0
- package/dist/drivers/pframe/query/query_spec.d.ts +76 -0
- package/dist/drivers/pframe/query/query_spec.d.ts.map +1 -0
- package/dist/drivers/pframe/spec/selectors.cjs.map +1 -1
- package/dist/drivers/pframe/spec/selectors.d.ts +12 -1
- package/dist/drivers/pframe/spec/selectors.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/selectors.js.map +1 -1
- package/dist/drivers/pframe/spec/spec.cjs.map +1 -1
- package/dist/drivers/pframe/spec/spec.d.ts +2 -0
- package/dist/drivers/pframe/spec/spec.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/spec.js.map +1 -1
- package/package.json +3 -3
- package/src/drivers/pframe/index.ts +1 -1
- package/src/drivers/pframe/query/index.ts +2 -0
- package/src/drivers/pframe/query/query_common.ts +821 -0
- package/src/drivers/pframe/query/query_data.ts +110 -0
- package/src/drivers/pframe/query/query_spec.ts +118 -0
- package/src/drivers/pframe/spec/selectors.ts +13 -1
- package/src/drivers/pframe/spec/spec.ts +3 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { PObjectId } from '../../../pool';
|
|
2
|
+
import type {
|
|
3
|
+
ExprAxisRef,
|
|
4
|
+
ExprColumnRef,
|
|
5
|
+
ExprNumericBinary,
|
|
6
|
+
ExprConstant,
|
|
7
|
+
ExprIsIn,
|
|
8
|
+
ExprLogicalUnary,
|
|
9
|
+
ExprLogicalVariadic,
|
|
10
|
+
ExprStringContains,
|
|
11
|
+
ExprStringContainsFuzzy,
|
|
12
|
+
ExprStringEquals,
|
|
13
|
+
ExprStringRegex,
|
|
14
|
+
ExprNumericUnary,
|
|
15
|
+
QueryAxisSelector,
|
|
16
|
+
QueryColumn, QuerySparseToDenseColumn,
|
|
17
|
+
QueryFilter,
|
|
18
|
+
QueryInlineColumn,
|
|
19
|
+
QueryJoinEntry,
|
|
20
|
+
QueryOuterJoin,
|
|
21
|
+
QuerySliceAxes,
|
|
22
|
+
QuerySort,
|
|
23
|
+
QuerySymmetricJoin,
|
|
24
|
+
TypeSpec,
|
|
25
|
+
InferBooleanExpressionUnion,
|
|
26
|
+
} from './query_common';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Column identifier with type specification.
|
|
30
|
+
*
|
|
31
|
+
* Pairs a column ID with its full type specification (axes and column types).
|
|
32
|
+
* Used in data layer to carry type information alongside column references.
|
|
33
|
+
*/
|
|
34
|
+
type ColumnIdAndTypeSpec = {
|
|
35
|
+
/** Unique identifier of the column */
|
|
36
|
+
id: PObjectId;
|
|
37
|
+
/** Type specification defining axes and column types */
|
|
38
|
+
typeSpec: TypeSpec;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Join entry for data layer queries.
|
|
43
|
+
*
|
|
44
|
+
* Extends the base join entry with axes mapping information.
|
|
45
|
+
* The mapping specifies how axes from this entry align with the joined result.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // Join entry with axes mapping [0, 2] means:
|
|
49
|
+
* // - This entry's axis 0 maps to result axis 0
|
|
50
|
+
* // - This entry's axis 1 maps to result axis 2
|
|
51
|
+
* { entry: queryData, axesMapping: [0, 2] }
|
|
52
|
+
*/
|
|
53
|
+
export interface QueryJoinEntryData extends QueryJoinEntry<QueryData> {
|
|
54
|
+
/** Maps this entry's axes to the result axes by index */
|
|
55
|
+
axesMapping: number[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** @see QueryColumn */
|
|
59
|
+
export type QueryColumnData = QueryColumn;
|
|
60
|
+
/** @see QueryInlineColumn */
|
|
61
|
+
export type QueryInlineColumnData = QueryInlineColumn<ColumnIdAndTypeSpec>;
|
|
62
|
+
/** @see QuerySparseToDenseColumn */
|
|
63
|
+
export type QuerySparseToDenseColumnData = QuerySparseToDenseColumn<ColumnIdAndTypeSpec>;
|
|
64
|
+
/** @see QuerySymmetricJoin */
|
|
65
|
+
export type QuerySymmetricJoinData = QuerySymmetricJoin<QueryJoinEntryData>;
|
|
66
|
+
/** @see QueryOuterJoin */
|
|
67
|
+
export type QueryOuterJoinData = QueryOuterJoin<QueryJoinEntryData>;
|
|
68
|
+
/** @see QuerySliceAxes */
|
|
69
|
+
export type QuerySliceAxesData = QuerySliceAxes<QueryData, QueryAxisSelector<number>>;
|
|
70
|
+
/** @see QuerySort */
|
|
71
|
+
export type QuerySortData = QuerySort<QueryData, QueryExpressionData>;
|
|
72
|
+
/** @see QueryFilter */
|
|
73
|
+
export type QueryFilterData = QueryFilter<QueryData, QueryBooleanExpressionData>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Union of all data layer query types.
|
|
77
|
+
*
|
|
78
|
+
* The data layer operates with numeric indices for axes and columns,
|
|
79
|
+
* making it suitable for runtime query execution and optimization.
|
|
80
|
+
*
|
|
81
|
+
* Includes:
|
|
82
|
+
* - Leaf nodes: column, inlineColumn, sparseToDenseColumn
|
|
83
|
+
* - Join operations: innerJoin, fullJoin, outerJoin
|
|
84
|
+
* - Transformations: sliceAxes, sort, filter
|
|
85
|
+
*/
|
|
86
|
+
export type QueryData =
|
|
87
|
+
| QueryColumnData
|
|
88
|
+
| QueryInlineColumnData
|
|
89
|
+
| QuerySparseToDenseColumnData
|
|
90
|
+
| QuerySymmetricJoinData
|
|
91
|
+
| QueryOuterJoinData
|
|
92
|
+
| QuerySliceAxesData
|
|
93
|
+
| QuerySortData
|
|
94
|
+
| QueryFilterData;
|
|
95
|
+
|
|
96
|
+
/** @see ExprAxisRef */
|
|
97
|
+
export type ExprAxisRefData = ExprAxisRef<number>;
|
|
98
|
+
/** @see ExprColumnRef */
|
|
99
|
+
export type ExprColumnRefData = ExprColumnRef<number>;
|
|
100
|
+
|
|
101
|
+
export type QueryExpressionData =
|
|
102
|
+
| ExprColumnRefData | ExprAxisRefData | ExprConstant
|
|
103
|
+
| ExprNumericBinary<QueryExpressionData> | ExprNumericUnary<QueryExpressionData>
|
|
104
|
+
| ExprStringEquals<QueryExpressionData> | ExprStringContains<QueryExpressionData>
|
|
105
|
+
| ExprStringRegex<QueryExpressionData> | ExprStringContainsFuzzy<QueryExpressionData>
|
|
106
|
+
| ExprLogicalUnary<QueryExpressionData> | ExprLogicalVariadic<QueryExpressionData>
|
|
107
|
+
| ExprIsIn<QueryExpressionData, string> | ExprIsIn<QueryExpressionData, number>
|
|
108
|
+
;
|
|
109
|
+
|
|
110
|
+
export type QueryBooleanExpressionData = InferBooleanExpressionUnion<QueryExpressionData>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { PObjectId } from '../../../pool';
|
|
2
|
+
import type {
|
|
3
|
+
ExprAxisRef,
|
|
4
|
+
ExprColumnRef,
|
|
5
|
+
ExprNumericBinary,
|
|
6
|
+
ExprConstant,
|
|
7
|
+
ExprIsIn,
|
|
8
|
+
ExprLogicalUnary,
|
|
9
|
+
ExprLogicalVariadic,
|
|
10
|
+
ExprStringContains,
|
|
11
|
+
ExprStringContainsFuzzy,
|
|
12
|
+
ExprStringEquals,
|
|
13
|
+
ExprStringRegex,
|
|
14
|
+
ExprNumericUnary,
|
|
15
|
+
QueryAxisSelector,
|
|
16
|
+
QueryColumn, QuerySparseToDenseColumn,
|
|
17
|
+
QueryFilter,
|
|
18
|
+
QueryInlineColumn,
|
|
19
|
+
QueryJoinEntry,
|
|
20
|
+
QueryOuterJoin,
|
|
21
|
+
QuerySliceAxes,
|
|
22
|
+
QuerySort,
|
|
23
|
+
QuerySymmetricJoin,
|
|
24
|
+
InferBooleanExpressionUnion,
|
|
25
|
+
} from './query_common';
|
|
26
|
+
import type { Domain, PColumnIdAndSpec, PColumnSpec, SingleAxisSelector } from '../spec';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Column identifier with specification.
|
|
30
|
+
*
|
|
31
|
+
* Pairs a column ID with its full PColumnSpec.
|
|
32
|
+
* Used in spec layer to carry column specification alongside references.
|
|
33
|
+
*/
|
|
34
|
+
type ColumnIdAndSpec = {
|
|
35
|
+
/** Unique identifier of the column */
|
|
36
|
+
id: PObjectId;
|
|
37
|
+
/** Full column specification including axes and value type */
|
|
38
|
+
spec: PColumnSpec;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Join entry for spec layer queries.
|
|
43
|
+
*
|
|
44
|
+
* Extends the base join entry with axis qualifications.
|
|
45
|
+
* Qualifications specify additional domain constraints for each axis,
|
|
46
|
+
* enabling more precise control over how columns are joined.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // Join entry with axis qualifications
|
|
50
|
+
* {
|
|
51
|
+
* entry: querySpec,
|
|
52
|
+
* qualifications: [
|
|
53
|
+
* { axis: { name: 'sample' }, additionalDomains: { ... } }
|
|
54
|
+
* ]
|
|
55
|
+
* }
|
|
56
|
+
*/
|
|
57
|
+
export type QueryJoinEntrySpec = QueryJoinEntry<QuerySpec> & {
|
|
58
|
+
/** Axis qualifications with additional domain constraints */
|
|
59
|
+
qualifications: {
|
|
60
|
+
/** Axis selector identifying which axis to qualify */
|
|
61
|
+
axis: SingleAxisSelector;
|
|
62
|
+
/** Additional domain constraints for this axis */
|
|
63
|
+
additionalDomains: Domain;
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** @see QueryColumn */
|
|
68
|
+
export type QueryColumnSpec = QueryColumn;
|
|
69
|
+
/** @see QueryInlineColumn */
|
|
70
|
+
export type QueryInlineColumnSpec = QueryInlineColumn<ColumnIdAndSpec>;
|
|
71
|
+
/** @see QuerySparseToDenseColumn */
|
|
72
|
+
export type QuerySparseToDenseColumnSpec = QuerySparseToDenseColumn<PColumnIdAndSpec>;
|
|
73
|
+
/** @see QuerySymmetricJoin */
|
|
74
|
+
export type QuerySymmetricJoinSpec = QuerySymmetricJoin<QueryJoinEntrySpec>;
|
|
75
|
+
/** @see QueryOuterJoin */
|
|
76
|
+
export type QueryOuterJoinSpec = QueryOuterJoin<QueryJoinEntrySpec>;
|
|
77
|
+
/** @see QuerySliceAxes */
|
|
78
|
+
export type QuerySliceAxesSpec = QuerySliceAxes<QuerySpec, QueryAxisSelector<SingleAxisSelector>>;
|
|
79
|
+
/** @see QuerySort */
|
|
80
|
+
export type QuerySortSpec = QuerySort<QuerySpec, QueryExpressionSpec>;
|
|
81
|
+
/** @see QueryFilter */
|
|
82
|
+
export type QueryFilterSpec = QueryFilter<QuerySpec, QueryBooleanExpressionSpec>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Union of all spec layer query types.
|
|
86
|
+
*
|
|
87
|
+
* The spec layer operates with named selectors and column IDs,
|
|
88
|
+
* making it suitable for user-facing query construction and validation.
|
|
89
|
+
*
|
|
90
|
+
* Includes:
|
|
91
|
+
* - Leaf nodes: column, inlineColumn, sparseToDenseColumn
|
|
92
|
+
* - Join operations: innerJoin, fullJoin, outerJoin
|
|
93
|
+
* - Transformations: sliceAxes, sort, filter
|
|
94
|
+
*/
|
|
95
|
+
export type QuerySpec =
|
|
96
|
+
| QueryColumnSpec
|
|
97
|
+
| QueryInlineColumnSpec
|
|
98
|
+
| QuerySparseToDenseColumnSpec
|
|
99
|
+
| QuerySymmetricJoinSpec
|
|
100
|
+
| QueryOuterJoinSpec
|
|
101
|
+
| QuerySliceAxesSpec
|
|
102
|
+
| QuerySortSpec
|
|
103
|
+
| QueryFilterSpec;
|
|
104
|
+
|
|
105
|
+
/** @see ExprAxisRef */
|
|
106
|
+
export type ExprAxisRefSpec = ExprAxisRef<SingleAxisSelector>;
|
|
107
|
+
/** @see ExprColumnRef */
|
|
108
|
+
export type ExprColumnRefSpec = ExprColumnRef<PObjectId>;
|
|
109
|
+
|
|
110
|
+
export type QueryExpressionSpec =
|
|
111
|
+
| ExprColumnRefSpec | ExprAxisRefSpec | ExprConstant
|
|
112
|
+
| ExprNumericBinary<QueryExpressionSpec> | ExprNumericUnary<QueryExpressionSpec>
|
|
113
|
+
| ExprStringEquals<QueryExpressionSpec> | ExprStringContains<QueryExpressionSpec>
|
|
114
|
+
| ExprStringRegex<QueryExpressionSpec> | ExprStringContainsFuzzy<QueryExpressionSpec>
|
|
115
|
+
| ExprLogicalUnary<QueryExpressionSpec> | ExprLogicalVariadic<QueryExpressionSpec>
|
|
116
|
+
| ExprIsIn<QueryExpressionSpec, string> | ExprIsIn<QueryExpressionSpec, number>;
|
|
117
|
+
|
|
118
|
+
export type QueryBooleanExpressionSpec = InferBooleanExpressionUnion<QueryExpressionSpec>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isPColumnSpec, type PObjectSpec } from '../../../pool';
|
|
2
|
-
import type { AxisId, PColumnSpec, ValueType } from './spec';
|
|
2
|
+
import type { AxisId, AxisValueType, Domain, PColumnSpec, ValueType } from './spec';
|
|
3
3
|
import { getAxisId } from './spec';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -37,6 +37,18 @@ export interface AxisSelector {
|
|
|
37
37
|
domain?: Record<string, string>;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/** Single axis selector */
|
|
41
|
+
export interface SingleAxisSelector {
|
|
42
|
+
/** Axis name (required) */
|
|
43
|
+
name: string;
|
|
44
|
+
/** Axis type (optional) */
|
|
45
|
+
type?: AxisValueType;
|
|
46
|
+
/** Domain requirements (optional) */
|
|
47
|
+
domain?: Domain;
|
|
48
|
+
/** Parent axes requirements (optional) */
|
|
49
|
+
parentAxes?: SingleAxisSelector[];
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
/**
|
|
41
53
|
* Reference to an axis by its numerical index within the anchor column's axes array
|
|
42
54
|
* Format: [anchorId, axisIndex]
|
|
@@ -20,6 +20,9 @@ export const ValueType = {
|
|
|
20
20
|
Bytes: 'Bytes',
|
|
21
21
|
} as const;
|
|
22
22
|
|
|
23
|
+
export type AxisValueType = Extract<ValueType, 'Int' | 'Long' | 'String'>;
|
|
24
|
+
export type ColumnValueType = ValueType;
|
|
25
|
+
|
|
23
26
|
/** PFrame columns and axes within them may store one of these types. */
|
|
24
27
|
export type ValueType = (typeof ValueType)[keyof typeof ValueType];
|
|
25
28
|
|