@milaboratories/pl-model-common 1.41.2 → 1.43.0
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/index.d.ts +4 -4
- package/dist/drivers/ls.d.ts +1 -1
- package/dist/drivers/pframe/driver.d.ts +2 -2
- package/dist/drivers/pframe/index.d.ts +4 -4
- package/dist/drivers/pframe/pframe.d.ts +1 -1
- package/dist/drivers/pframe/query/index.d.ts +2 -2
- package/dist/drivers/pframe/query/query_common.d.ts +229 -22
- package/dist/drivers/pframe/query/query_common.d.ts.map +1 -1
- package/dist/drivers/pframe/query/query_data.d.ts +9 -7
- package/dist/drivers/pframe/query/query_data.d.ts.map +1 -1
- package/dist/drivers/pframe/query/query_spec.d.ts +9 -7
- package/dist/drivers/pframe/query/query_spec.d.ts.map +1 -1
- package/dist/drivers/pframe/query/utils.cjs +12 -3
- package/dist/drivers/pframe/query/utils.cjs.map +1 -1
- package/dist/drivers/pframe/query/utils.d.ts.map +1 -1
- package/dist/drivers/pframe/query/utils.js +12 -3
- package/dist/drivers/pframe/query/utils.js.map +1 -1
- package/dist/drivers/pframe/spec_driver.d.ts +11 -1
- package/dist/drivers/pframe/spec_driver.d.ts.map +1 -1
- package/dist/drivers/pframe/table_calculate.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/services/service_declarations.cjs +4 -2
- package/dist/services/service_declarations.cjs.map +1 -1
- package/dist/services/service_declarations.js +4 -2
- package/dist/services/service_declarations.js.map +1 -1
- package/package.json +4 -4
- package/src/drivers/pframe/query/query_common.ts +256 -27
- package/src/drivers/pframe/query/query_data.ts +33 -12
- package/src/drivers/pframe/query/query_spec.ts +29 -11
- package/src/drivers/pframe/query/utils.test.ts +24 -8
- package/src/drivers/pframe/query/utils.ts +21 -3
- package/src/drivers/pframe/spec_driver.ts +12 -1
- package/src/services/service_declarations.ts +2 -0
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
SpecQueryJoinEntry,
|
|
8
8
|
} from "./query_spec";
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const BOOLEAN_TYPES = new Set<SpecQueryBooleanExpression["type"]>([
|
|
11
11
|
"numericComparison",
|
|
12
12
|
"stringEquals",
|
|
13
13
|
"stringContains",
|
|
@@ -18,10 +18,11 @@ const booleanTypesSet = new Set<SpecQueryBooleanExpression["type"]>([
|
|
|
18
18
|
"and",
|
|
19
19
|
"or",
|
|
20
20
|
"isIn",
|
|
21
|
+
// "isInPolygon", -- disabled until the Rust executor wires it up
|
|
21
22
|
]);
|
|
22
23
|
|
|
23
24
|
export function isBooleanExpression(expr: SpecQueryExpression): expr is SpecQueryBooleanExpression {
|
|
24
|
-
return
|
|
25
|
+
return BOOLEAN_TYPES.has(
|
|
25
26
|
// @ts-expect-error -- TypeScript doesn't understand the discriminated union here, but we do at runtime
|
|
26
27
|
expr.type,
|
|
27
28
|
);
|
|
@@ -88,6 +89,7 @@ export function traverseQuerySpec<C1, C2>(
|
|
|
88
89
|
case "filter":
|
|
89
90
|
case "sort":
|
|
90
91
|
case "sliceAxes":
|
|
92
|
+
case "transformColumns":
|
|
91
93
|
result = { ...query, input: traverseQuerySpec(query.input, visitor) };
|
|
92
94
|
break;
|
|
93
95
|
default:
|
|
@@ -123,7 +125,14 @@ export function sortSpecQuery(query: SpecQuery): SpecQuery {
|
|
|
123
125
|
node: (node) => {
|
|
124
126
|
switch (node.type) {
|
|
125
127
|
case "sparseToDenseColumn":
|
|
126
|
-
return {
|
|
128
|
+
return {
|
|
129
|
+
...node,
|
|
130
|
+
// toSorted preserves array length but the type system widens
|
|
131
|
+
// the non-empty tuple back to a plain array, so re-narrow.
|
|
132
|
+
axes: node.axes.toSorted((a, b) =>
|
|
133
|
+
canonicalizeJson(a).localeCompare(canonicalizeJson(b)),
|
|
134
|
+
) as typeof node.axes,
|
|
135
|
+
};
|
|
127
136
|
case "innerJoin":
|
|
128
137
|
case "fullJoin": {
|
|
129
138
|
const sorted = [...node.entries].sort(cmpQueryJoinEntrySpec);
|
|
@@ -236,6 +245,15 @@ function cmpQuerySpec(lhs: SpecQuery, rhs: SpecQuery): number {
|
|
|
236
245
|
return cmpQuerySpec(lhs.input, (rhs as typeof lhs).input);
|
|
237
246
|
case "filter":
|
|
238
247
|
return cmpQuerySpec(lhs.input, (rhs as typeof lhs).input);
|
|
248
|
+
case "transformColumns": {
|
|
249
|
+
const rhsTc = rhs as typeof lhs;
|
|
250
|
+
const cmp = cmpQuerySpec(lhs.input, rhsTc.input);
|
|
251
|
+
if (cmp !== 0) return cmp;
|
|
252
|
+
const modeCmp = lhs.mode.localeCompare(rhsTc.mode);
|
|
253
|
+
if (modeCmp !== 0) return modeCmp;
|
|
254
|
+
// Column entries are positional; compare by canonical JSON.
|
|
255
|
+
return canonicalizeJson(lhs.columns).localeCompare(canonicalizeJson(rhsTc.columns));
|
|
256
|
+
}
|
|
239
257
|
default:
|
|
240
258
|
assertNever(lhs);
|
|
241
259
|
}
|
|
@@ -14,7 +14,8 @@ import type {
|
|
|
14
14
|
ColumnValueType,
|
|
15
15
|
} from "./spec";
|
|
16
16
|
import type { PTableColumnId, PTableColumnSpec } from "./table_common";
|
|
17
|
-
import {
|
|
17
|
+
import type { PTableRecordFilter } from "./table_calculate";
|
|
18
|
+
import { DataQuery, DataQueryBooleanExpression, SpecQuery, SpecQueryJoinEntry } from "./query";
|
|
18
19
|
|
|
19
20
|
/** Matches a string value either exactly or by regex pattern */
|
|
20
21
|
export type StringMatcher =
|
|
@@ -255,4 +256,14 @@ export interface PFrameSpecDriver {
|
|
|
255
256
|
|
|
256
257
|
/** Find the flat index of a table column matching the given selector. Returns -1 if not found. */
|
|
257
258
|
findTableColumn(tableSpec: PTableColumnSpec[], selector: PTableColumnId): number;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Upgrades selector-based legacy record filters into index-based data-layer
|
|
262
|
+
* boolean expressions, resolved against the provided unified table spec
|
|
263
|
+
* (axes first, then columns).
|
|
264
|
+
*/
|
|
265
|
+
rewriteLegacyFilters(request: {
|
|
266
|
+
tableSpec: PTableColumnSpec[];
|
|
267
|
+
filters: PTableRecordFilter[];
|
|
268
|
+
}): DataQueryBooleanExpression[];
|
|
258
269
|
}
|
|
@@ -43,6 +43,7 @@ export const Services = {
|
|
|
43
43
|
"collapseAxes",
|
|
44
44
|
"findAxis",
|
|
45
45
|
"findTableColumn",
|
|
46
|
+
"rewriteLegacyFilters",
|
|
46
47
|
] as const,
|
|
47
48
|
uiMethods: [
|
|
48
49
|
"createSpecFrame",
|
|
@@ -55,6 +56,7 @@ export const Services = {
|
|
|
55
56
|
"collapseAxes",
|
|
56
57
|
"findAxis",
|
|
57
58
|
"findTableColumn",
|
|
59
|
+
"rewriteLegacyFilters",
|
|
58
60
|
] as const,
|
|
59
61
|
}),
|
|
60
62
|
PFrame: service<PFrameModelDriver, PFrameDriver>()({
|