@platforma-open/milaboratories.software-ptabler.schema 1.11.0 → 1.11.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.
@@ -1,8 +1,4 @@
1
1
  import { Expression, AggregationType } from './expressions';
2
- /**
3
- * Defines standard aggregation functions that operate on a single expression.
4
- */
5
- export type StandardAggregationType = 'sum' | 'mean' | 'median' | 'min' | 'max' | 'std' | 'var' | 'count' | 'first' | 'last' | 'n_unique';
6
2
  /**
7
3
  * Defines aggregation functions that select a value from one expression based on the min/max of another expression.
8
4
  */
@@ -1,5 +1,5 @@
1
1
  import { DataType } from './common';
2
- export type Expression = ComparisonExpression | BinaryArithmeticExpression | UnaryArithmeticExpression | CastExpression | BooleanLogicExpression | NotExpression | NullCheckExpression | StringJoinExpression | HashExpression | ColumnReferenceExpression | ConstantValueExpression | RankExpression | CumsumExpression | ExtendedUnaryStringExpression | StringDistanceExpression | FuzzyStringFilterExpression | WhenThenOtherwiseExpression | SubstringExpression | StringReplaceExpression | StringContainsExpression | StringStartsWithExpression | StringEndsWithExpression | StringContainsAnyExpression | StringCountMatchesExpression | StringExtractExpression | MinMaxExpression | FillNaExpression | WindowExpression | StructFieldExpression;
2
+ export type Expression = ComparisonExpression | BinaryArithmeticExpression | UnaryArithmeticExpression | CastExpression | BooleanLogicExpression | NotExpression | NullCheckExpression | StringJoinExpression | HashExpression | ColumnReferenceExpression | ConstantValueExpression | RankExpression | CumsumExpression | ExtendedUnaryStringExpression | StringDistanceExpression | FuzzyStringFilterExpression | WhenThenOtherwiseExpression | SubstringExpression | StringReplaceExpression | StringContainsExpression | StringStartsWithExpression | StringEndsWithExpression | StringContainsAnyExpression | StringCountMatchesExpression | StringExtractExpression | MinMaxExpression | FillNullExpression | FillNaNExpression | WindowExpression | StructFieldExpression;
3
3
  /** Represents all possible expression types in the system. */
4
4
  export type ComparisonOperator = 'gt' | 'ge' | 'eq' | 'lt' | 'le' | 'neq';
5
5
  /** Defines a comparison operation between two expressions. */
@@ -374,20 +374,35 @@ export interface MinMaxExpression {
374
374
  operands: Expression[];
375
375
  }
376
376
  /**
377
- * Represents a fill NA (null) operation.
377
+ * Represents a fill null operation.
378
378
  * If the 'input' expression evaluates to null, the 'fillValue' expression is used.
379
379
  * Otherwise, the 'input' expression's value is used.
380
380
  * This is a convenience shortcut for a common pattern often implemented with
381
- * conditional expressions (e.g., when(is_na(input), fillValue).otherwise(input)).
381
+ * conditional expressions (e.g., when(is_null(input), fillValue).otherwise(input)).
382
382
  */
383
- export interface FillNaExpression {
384
- /** The type of operation, always 'fill_na'. */
385
- type: 'fill_na';
383
+ export interface FillNullExpression {
384
+ /** The type of operation, always 'fill_null'. */
385
+ type: 'fill_null';
386
386
  /** The primary expression to evaluate. */
387
387
  input: Expression;
388
388
  /** The expression whose value is used if 'input' is null. */
389
389
  fillValue: Expression;
390
390
  }
391
+ /**
392
+ * Represents a fill NaN operation.
393
+ * If the 'input' expression evaluates to NaN, the 'fillValue' expression is used.
394
+ * Otherwise, the 'input' expression's value is used.
395
+ * This is a convenience shortcut for a common pattern often implemented with
396
+ * conditional expressions (e.g., when(is_nan(input), fillValue).otherwise(input)).
397
+ */
398
+ export interface FillNaNExpression {
399
+ /** The type of operation, always 'fill_nan'. */
400
+ type: 'fill_nan';
401
+ /** The primary expression to evaluate. */
402
+ input: Expression;
403
+ /** The expression whose value is used if 'input' is NaN. */
404
+ fillValue: Expression;
405
+ }
391
406
  /**
392
407
  * Defines standard aggregation functions that can be used in window expressions.
393
408
  */
@@ -409,7 +424,13 @@ export interface WindowExpression {
409
424
  /**
410
425
  * Represents a struct field access operation.
411
426
  * This operation retrieves a single field from a struct (nested data structure).
412
- * It corresponds to Polars' struct.field() functionality.
427
+ *
428
+ * Uses native Polars struct.field() functionality when possible for optimal performance,
429
+ * but falls back to Python UDF (map_elements) when dtype casting or default values
430
+ * are specified, trading performance for robust handling of missing fields and null structs.
431
+ *
432
+ * When fields is an array, the operation performs recursive field access,
433
+ * where each element in the array represents a level in the nested structure.
413
434
  */
414
435
  export interface StructFieldExpression {
415
436
  /** The type of operation, always 'struct_field'. */
@@ -417,8 +438,20 @@ export interface StructFieldExpression {
417
438
  /** The struct expression to extract fields from. */
418
439
  struct: Expression;
419
440
  /**
420
- * The field name to extract from the struct.
421
- * Currently only supports single field extraction due to Polars behavior limitations.
441
+ * The field name(s) to extract from the struct.
442
+ * - If a string, extracts a single field from the struct.
443
+ * - If an array, performs recursive field access where each element represents a level in the nested structure.
444
+ */
445
+ fields: string | string[];
446
+ /**
447
+ * Optional expected data type for the returned value.
448
+ * This can be used for type validation or casting of the extracted field.
449
+ */
450
+ dtype?: DataType;
451
+ /**
452
+ * Optional default value to return if the field is not found or is null.
453
+ * If not provided and the field is missing, the operation returns null.
454
+ * Only constant scalar values are supported.
422
455
  */
423
- fields: string;
456
+ default?: string | number | boolean | null;
424
457
  }
package/dist/sort.d.ts CHANGED
@@ -36,14 +36,8 @@ export interface SortStep {
36
36
  * An array of sort directives defining the columns and their respective sort orders.
37
37
  * The table is sorted by the first directive in the array, then by the second
38
38
  * for any ties, and so on.
39
+ *
40
+ * Note: Sorting is always stable (maintains relative order of equivalent rows).
39
41
  */
40
42
  by: SortDirective[];
41
- /**
42
- * Optional. If true, maintains the stability of the sort. This means that if
43
- * two rows are equivalent according to the sorting criteria, their relative order
44
- * from the input table is preserved in the output.
45
- * Corresponds to `maintain_order=True` in Polars `DataFrame.sort()`.
46
- * Defaults to false.
47
- */
48
- stable?: boolean;
49
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-open/milaboratories.software-ptabler.schema",
3
- "version": "1.11.0",
3
+ "version": "1.11.2",
4
4
  "description": "Type definitions for PTabler",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -18,10 +18,10 @@
18
18
  ],
19
19
  "dependencies": {},
20
20
  "devDependencies": {
21
- "@platforma-sdk/eslint-config": "^1.0.3",
22
- "vite-plugin-dts": "^4.5.4",
23
- "eslint": "^9.27.0",
24
- "typescript": "~5.5.4",
21
+ "@platforma-sdk/eslint-config": "",
22
+ "vite-plugin-dts": "^4.5.3",
23
+ "eslint": "^9.25.1",
24
+ "typescript": "~5.6.3",
25
25
  "vite": "^6.3.5"
26
26
  },
27
27
  "scripts": {
package/src/aggregate.ts CHANGED
@@ -1,21 +1,5 @@
1
1
  import type { Expression, AggregationType } from './expressions';
2
2
 
3
- /**
4
- * Defines standard aggregation functions that operate on a single expression.
5
- */
6
- export type StandardAggregationType =
7
- | 'sum'
8
- | 'mean'
9
- | 'median'
10
- | 'min'
11
- | 'max'
12
- | 'std'
13
- | 'var'
14
- | 'count'
15
- | 'first'
16
- | 'last'
17
- | 'n_unique';
18
-
19
3
  /**
20
4
  * Defines aggregation functions that select a value from one expression based on the min/max of another expression.
21
5
  */
@@ -27,7 +27,8 @@ export type Expression =
27
27
  | StringCountMatchesExpression
28
28
  | StringExtractExpression
29
29
  | MinMaxExpression
30
- | FillNaExpression
30
+ | FillNullExpression
31
+ | FillNaNExpression
31
32
  | WindowExpression
32
33
  | StructFieldExpression;
33
34
 
@@ -470,21 +471,37 @@ export interface MinMaxExpression {
470
471
  }
471
472
 
472
473
  /**
473
- * Represents a fill NA (null) operation.
474
+ * Represents a fill null operation.
474
475
  * If the 'input' expression evaluates to null, the 'fillValue' expression is used.
475
476
  * Otherwise, the 'input' expression's value is used.
476
477
  * This is a convenience shortcut for a common pattern often implemented with
477
- * conditional expressions (e.g., when(is_na(input), fillValue).otherwise(input)).
478
+ * conditional expressions (e.g., when(is_null(input), fillValue).otherwise(input)).
478
479
  */
479
- export interface FillNaExpression {
480
- /** The type of operation, always 'fill_na'. */
481
- type: 'fill_na';
480
+ export interface FillNullExpression {
481
+ /** The type of operation, always 'fill_null'. */
482
+ type: 'fill_null';
482
483
  /** The primary expression to evaluate. */
483
484
  input: Expression;
484
485
  /** The expression whose value is used if 'input' is null. */
485
486
  fillValue: Expression;
486
487
  }
487
488
 
489
+ /**
490
+ * Represents a fill NaN operation.
491
+ * If the 'input' expression evaluates to NaN, the 'fillValue' expression is used.
492
+ * Otherwise, the 'input' expression's value is used.
493
+ * This is a convenience shortcut for a common pattern often implemented with
494
+ * conditional expressions (e.g., when(is_nan(input), fillValue).otherwise(input)).
495
+ */
496
+ export interface FillNaNExpression {
497
+ /** The type of operation, always 'fill_nan'. */
498
+ type: 'fill_nan';
499
+ /** The primary expression to evaluate. */
500
+ input: Expression;
501
+ /** The expression whose value is used if 'input' is NaN. */
502
+ fillValue: Expression;
503
+ }
504
+
488
505
  /**
489
506
  * Defines standard aggregation functions that can be used in window expressions.
490
507
  */
@@ -519,7 +536,13 @@ export interface WindowExpression {
519
536
  /**
520
537
  * Represents a struct field access operation.
521
538
  * This operation retrieves a single field from a struct (nested data structure).
522
- * It corresponds to Polars' struct.field() functionality.
539
+ *
540
+ * Uses native Polars struct.field() functionality when possible for optimal performance,
541
+ * but falls back to Python UDF (map_elements) when dtype casting or default values
542
+ * are specified, trading performance for robust handling of missing fields and null structs.
543
+ *
544
+ * When fields is an array, the operation performs recursive field access,
545
+ * where each element in the array represents a level in the nested structure.
523
546
  */
524
547
  export interface StructFieldExpression {
525
548
  /** The type of operation, always 'struct_field'. */
@@ -527,8 +550,20 @@ export interface StructFieldExpression {
527
550
  /** The struct expression to extract fields from. */
528
551
  struct: Expression;
529
552
  /**
530
- * The field name to extract from the struct.
531
- * Currently only supports single field extraction due to Polars behavior limitations.
553
+ * The field name(s) to extract from the struct.
554
+ * - If a string, extracts a single field from the struct.
555
+ * - If an array, performs recursive field access where each element represents a level in the nested structure.
556
+ */
557
+ fields: string | string[];
558
+ /**
559
+ * Optional expected data type for the returned value.
560
+ * This can be used for type validation or casting of the extracted field.
561
+ */
562
+ dtype?: DataType;
563
+ /**
564
+ * Optional default value to return if the field is not found or is null.
565
+ * If not provided and the field is missing, the operation returns null.
566
+ * Only constant scalar values are supported.
532
567
  */
533
- fields: string;
568
+ default?: string | number | boolean | null;
534
569
  }
package/src/sort.ts CHANGED
@@ -43,15 +43,8 @@ export interface SortStep {
43
43
  * An array of sort directives defining the columns and their respective sort orders.
44
44
  * The table is sorted by the first directive in the array, then by the second
45
45
  * for any ties, and so on.
46
+ *
47
+ * Note: Sorting is always stable (maintains relative order of equivalent rows).
46
48
  */
47
49
  by: SortDirective[];
48
-
49
- /**
50
- * Optional. If true, maintains the stability of the sort. This means that if
51
- * two rows are equivalent according to the sorting criteria, their relative order
52
- * from the input table is preserved in the output.
53
- * Corresponds to `maintain_order=True` in Polars `DataFrame.sort()`.
54
- * Defaults to false.
55
- */
56
- stable?: boolean;
57
50
  }