@platforma-open/milaboratories.software-ptabler.schema 1.12.0 → 1.12.1

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.
Files changed (68) hide show
  1. package/dist/aggregate.d.ts +2 -5
  2. package/dist/aggregate.d.ts.map +1 -0
  3. package/dist/basic_steps.d.ts +30 -35
  4. package/dist/basic_steps.d.ts.map +1 -0
  5. package/dist/common.d.ts +1 -0
  6. package/dist/common.d.ts.map +1 -0
  7. package/dist/concatenate.d.ts +1 -0
  8. package/dist/concatenate.d.ts.map +1 -0
  9. package/dist/expressions/base.d.ts +6 -0
  10. package/dist/expressions/base.d.ts.map +1 -0
  11. package/dist/expressions/basics.d.ts +131 -0
  12. package/dist/expressions/basics.d.ts.map +1 -0
  13. package/dist/expressions/conditional.d.ts +56 -0
  14. package/dist/expressions/conditional.d.ts.map +1 -0
  15. package/dist/expressions/fuzzy.d.ts +45 -0
  16. package/dist/expressions/fuzzy.d.ts.map +1 -0
  17. package/dist/expressions/hash.d.ts +25 -0
  18. package/dist/expressions/hash.d.ts.map +1 -0
  19. package/dist/expressions/index.d.ts +25 -0
  20. package/dist/expressions/index.d.ts.map +1 -0
  21. package/dist/expressions/pframes.d.ts +115 -0
  22. package/dist/expressions/pframes.d.ts.map +1 -0
  23. package/dist/expressions/selectors.d.ts +172 -0
  24. package/dist/expressions/selectors.d.ts.map +1 -0
  25. package/dist/expressions/string.d.ts +158 -0
  26. package/dist/expressions/string.d.ts.map +1 -0
  27. package/dist/expressions/struct.d.ts +37 -0
  28. package/dist/expressions/struct.d.ts.map +1 -0
  29. package/dist/expressions/window.d.ts +52 -0
  30. package/dist/expressions/window.d.ts.map +1 -0
  31. package/dist/index.cjs +3 -0
  32. package/dist/index.cjs.map +1 -0
  33. package/dist/index.d.ts +12 -9
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +1 -1
  36. package/dist/io.d.ts +16 -1
  37. package/dist/io.d.ts.map +1 -0
  38. package/dist/join.d.ts +1 -0
  39. package/dist/join.d.ts.map +1 -0
  40. package/dist/read_frame.d.ts +26 -0
  41. package/dist/read_frame.d.ts.map +1 -0
  42. package/dist/sort.d.ts +4 -9
  43. package/dist/sort.d.ts.map +1 -0
  44. package/dist/write_frame.d.ts +58 -0
  45. package/dist/write_frame.d.ts.map +1 -0
  46. package/package.json +11 -9
  47. package/src/aggregate.ts +0 -16
  48. package/src/basic_steps.ts +32 -37
  49. package/src/expressions/base.ts +5 -0
  50. package/src/expressions/basics.ts +163 -0
  51. package/src/expressions/conditional.ts +59 -0
  52. package/src/expressions/fuzzy.ts +51 -0
  53. package/src/expressions/hash.ts +37 -0
  54. package/src/expressions/index.ts +147 -0
  55. package/src/expressions/pframes.ts +118 -0
  56. package/src/expressions/selectors.ts +203 -0
  57. package/src/expressions/string.ts +168 -0
  58. package/src/expressions/struct.ts +37 -0
  59. package/src/expressions/window.ts +66 -0
  60. package/src/index.ts +35 -5
  61. package/src/io.ts +16 -0
  62. package/src/read_frame.ts +26 -0
  63. package/src/sort.ts +2 -9
  64. package/src/write_frame.ts +66 -0
  65. package/dist/expressions.d.ts +0 -439
  66. package/dist/index.mjs +0 -2
  67. package/dist/index.mjs.map +0 -1
  68. package/src/expressions.ts +0 -549
@@ -1,549 +0,0 @@
1
- import type { DataType } from './common';
2
-
3
- export type Expression =
4
- | ComparisonExpression
5
- | BinaryArithmeticExpression
6
- | UnaryArithmeticExpression
7
- | CastExpression
8
- | BooleanLogicExpression
9
- | NotExpression
10
- | NullCheckExpression
11
- | StringJoinExpression
12
- | HashExpression
13
- | ColumnReferenceExpression
14
- | ConstantValueExpression
15
- | RankExpression
16
- | CumsumExpression
17
- | ExtendedUnaryStringExpression
18
- | StringDistanceExpression
19
- | FuzzyStringFilterExpression
20
- | WhenThenOtherwiseExpression
21
- | SubstringExpression
22
- | StringReplaceExpression
23
- | StringContainsExpression
24
- | StringStartsWithExpression
25
- | StringEndsWithExpression
26
- | StringContainsAnyExpression
27
- | StringCountMatchesExpression
28
- | StringExtractExpression
29
- | MinMaxExpression
30
- | FillNaExpression
31
- | WindowExpression
32
- | StructFieldExpression;
33
-
34
- /** Represents all possible expression types in the system. */
35
- export type ComparisonOperator = 'gt' | 'ge' | 'eq' | 'lt' | 'le' | 'neq';
36
-
37
- /** Defines a comparison operation between two expressions. */
38
- export interface ComparisonExpression {
39
- /** The type of comparison (e.g., 'gt', 'eq'). */
40
- type: ComparisonOperator;
41
- /** The left-hand side expression. */
42
- lhs: Expression;
43
- /** The right-hand side expression. */
44
- rhs: Expression;
45
- }
46
-
47
- /** Defines the supported binary arithmetic operators. */
48
- export type BinaryArithmeticOperator =
49
- | 'plus'
50
- | 'minus'
51
- | 'multiply'
52
- | 'truediv'
53
- | 'floordiv';
54
-
55
- /** Represents a binary arithmetic operation between two expressions. */
56
- export interface BinaryArithmeticExpression {
57
- /** The type of arithmetic operation (e.g., 'plus', 'minus'). */
58
- type: BinaryArithmeticOperator;
59
- /** The left-hand side expression. */
60
- lhs: Expression;
61
- /** The right-hand side expression. */
62
- rhs: Expression;
63
- }
64
-
65
- /** Defines the supported unary arithmetic operators. */
66
- export type UnaryArithmeticOperator =
67
- | 'log10'
68
- | 'log'
69
- | 'log2'
70
- | 'abs'
71
- | 'sqrt'
72
- | 'negate'
73
- | 'floor'
74
- | 'round'
75
- | 'ceil';
76
-
77
- /** Represents a unary arithmetic operation on a single expression. */
78
- export interface UnaryArithmeticExpression {
79
- /** The type of unary operation (e.g., 'log10', 'abs'). */
80
- type: UnaryArithmeticOperator;
81
- /** The expression to operate on. */
82
- value: Expression;
83
- }
84
-
85
- /**
86
- * Represents a type casting operation that converts the result of an expression to a specified data type.
87
- */
88
- export interface CastExpression {
89
- /** The type of operation, always 'cast'. */
90
- type: 'cast';
91
- /** The expression whose result will be cast to the target data type. */
92
- value: Expression;
93
- /** The target data type to cast the expression result to. */
94
- dtype: DataType;
95
- /**
96
- * Whether to use strict casting mode. If true, conversion errors and overflows will throw exceptions.
97
- * If false or undefined, uses non-strict mode where failures result in null values. Defaults to false.
98
- */
99
- strict?: boolean;
100
- }
101
-
102
- /** Defines the supported boolean list operators. */
103
- export type BooleanListOperator = 'and' | 'or';
104
-
105
- /** Represents a boolean logic operation (AND, OR) on a list of expressions. */
106
- export interface BooleanLogicExpression {
107
- /** The type of boolean operation ('and', 'or'). */
108
- type: BooleanListOperator;
109
- /** An array of boolean expressions as operands. */
110
- operands: Expression[]; // Array of boolean expressions
111
- }
112
-
113
- /** Represents a logical NOT operation on a single boolean expression. */
114
- export interface NotExpression {
115
- /** The type of operation, always 'not'. */
116
- type: 'not';
117
- /** The boolean expression to negate. */
118
- value: Expression;
119
- }
120
-
121
- /** Defines the supported null check operators. */
122
- export type NullCheckOperator = 'is_na' | 'is_not_na';
123
-
124
- /** Represents a null check operation (is NA, is not NA) on an expression. */
125
- export interface NullCheckExpression {
126
- /** The type of null check ('is_na', 'is_not_na'). */
127
- type: NullCheckOperator;
128
- /** The expression to check for nullity. */
129
- value: Expression;
130
- }
131
-
132
- /** Represents a string join operation on an array of expressions. */
133
- export interface StringJoinExpression {
134
- /** The type of operation, always 'str_join'. */
135
- type: 'str_join';
136
- /** An array of expressions whose string representations will be joined. */
137
- operands: Expression[];
138
- /** An optional delimiter string to insert between joined elements. */
139
- delimiter?: string;
140
- }
141
-
142
- /** Defines the supported hash types. Includes common cryptographic and non-cryptographic algorithms. */
143
- export type HashType =
144
- | 'sha256' // Cryptographic
145
- | 'sha512' // Cryptographic
146
- | 'md5' // Cryptographic (use with caution due to vulnerabilities)
147
- | 'blake3' // Cryptographic
148
- | 'wyhash' // Non-cryptographic
149
- | 'xxh3'; // Non-cryptographic
150
-
151
- /**
152
- * Defines the encoding for the hash output.
153
- * - 'hex': Standard hexadecimal encoding.
154
- * - 'base64': Standard base64 encoding.
155
- * - 'base64_alphanumeric': Base64 encoding with non-alphanumeric characters (e.g., '+', '/') removed.
156
- * - 'base64_alphanumeric_upper': Base64 encoding with non-alphanumeric characters removed and the result converted to uppercase.
157
- */
158
- export type HashEncoding =
159
- | 'hex'
160
- | 'base64'
161
- | 'base64_alphanumeric'
162
- | 'base64_alphanumeric_upper';
163
-
164
- /** Represents a hashing operation on an expression. */
165
- export interface HashExpression {
166
- /** The specific type of hash algorithm to apply. */
167
- type: 'hash';
168
- /** The type of hash algorithm to apply. */
169
- hashType: HashType;
170
- /** The encoding for the output hash string. */
171
- encoding: HashEncoding;
172
- /** The expression whose value will be hashed. */
173
- value: Expression;
174
- /** Optional. Minimal number of entropy bits required. Affects encoding, truncating the result to the shortest string with the requested entropy. No error if bits exceed what the hash offers. */
175
- bits?: number;
176
- }
177
-
178
- /** Represents a reference to a column by its name. */
179
- export interface ColumnReferenceExpression {
180
- /** The type of operation, always 'col'. */
181
- type: 'col';
182
- /** The name of the column to reference. */
183
- name: string;
184
- }
185
-
186
- /** Represents a constant literal value (string, number, boolean, or null). */
187
- export interface ConstantValueExpression {
188
- /** The type of operation, always 'const'. */
189
- type: 'const';
190
- /** The constant value. */
191
- value: string | number | boolean | null;
192
- }
193
-
194
- /**
195
- * Represents a rank function applied over a dataset partition.
196
- * Calculates the rank of each row within its partition based on the specified ordering.
197
- */
198
- export interface RankExpression {
199
- /** The type of operation, always 'rank'. */
200
- type: 'rank';
201
- /** List of expressions to partition the data by before ranking. The output of these expressions will be used for partitioning. */
202
- partitionBy: Expression[];
203
- /** Defines the ordering expressions within partitions to determine the rank. */
204
- orderBy: Expression[];
205
- /** Whether to sort in descending order. Defaults to false (ascending). */
206
- descending?: boolean;
207
- }
208
-
209
- /**
210
- * Represents a cumulative sum function applied over a dataset partition.
211
- * Calculates the cumulative sum of the 'value' expression within each partition,
212
- * based on the specified ordering. Values are sorted by value and then by
213
- * additional_order_by before summing.
214
- */
215
- export interface CumsumExpression {
216
- /** The type of operation, always 'cumsum'. */
217
- type: 'cumsum';
218
- /** The expression whose values will be cumulatively summed. */
219
- value: Expression;
220
- /** Defines additional ordering within partitions for the cumulative sum calculation, in addition to the ordering of the values themselves. */
221
- additionalOrderBy: Expression[];
222
- /** List of expressions to partition the data by before calculating the cumulative sum. The output of these expressions will be used for partitioning. */
223
- partitionBy: Expression[];
224
- /** Whether to sort in descending order. Defaults to false (ascending). */
225
- descending?: boolean;
226
- }
227
-
228
- /** Defines the supported unary string operators. */
229
- export type UnaryStringOperator = 'to_upper' | 'to_lower';
230
-
231
- /** Represents a unary string operation on a single expression. */
232
- export interface ExtendedUnaryStringExpression {
233
- /** The type of unary string operation (e.g., 'to_upper', 'to_lower', 'str_len'). */
234
- type: UnaryStringOperator | 'str_len';
235
- /** The string expression to operate on. */
236
- value: Expression;
237
- }
238
-
239
- /** Defines the supported string distance metrics. */
240
- export type StringDistanceMetric =
241
- | 'levenshtein'
242
- | 'optimal_string_alignment'
243
- | 'jaro_winkler';
244
-
245
- /**
246
- * Represents a string distance/similarity calculation between two expressions.
247
- * Computes metrics like Levenshtein, Optimal String Alignment, or Jaro-Winkler.
248
- */
249
- export interface StringDistanceExpression {
250
- /** The type of operation, always 'string_distance'. */
251
- type: 'string_distance';
252
- /** The specific distance metric to use. */
253
- metric: StringDistanceMetric;
254
- /** The first string expression. */
255
- string1: Expression;
256
- /** The second string expression to compare against. */
257
- string2: Expression;
258
- /**
259
- * If true, the expression returns a similarity score (typically normalized between 0 and 1).
260
- * If false or undefined, it returns the raw edit distance (e.g., Levenshtein, OSA).
261
- * Jaro-Winkler inherently returns a similarity score; this flag might be ignored or influence its normalization if applicable.
262
- */
263
- returnSimilarity?: boolean;
264
- }
265
-
266
- /** Defines the supported fuzzy string filter distance metrics. */
267
- export type FuzzyFilterDistanceMetric = 'levenshtein' | 'hamming';
268
-
269
- /**
270
- * Represents a fuzzy string filter operation on an expression.
271
- * This operation compares the string value of an expression (`value`)
272
- * against another string or string expression (`pattern`) using a specified
273
- * distance metric (`levenshtein` or `hamming`), returning true if the distance is
274
- * within the specified `bound`.
275
- */
276
- export interface FuzzyStringFilterExpression {
277
- /** The type of operation, always 'fuzzy_string_filter'. */
278
- type: 'fuzzy_string_filter';
279
- /** The distance metric to use for the fuzzy comparison. */
280
- metric: FuzzyFilterDistanceMetric;
281
- /** The expression whose string value will be compared. */
282
- value: Expression;
283
- /** The expression representing the string pattern to compare against. */
284
- pattern: Expression;
285
- /** The maximum allowed distance for a match (inclusive). */
286
- bound: number;
287
- }
288
-
289
- /**
290
- * Represents a single "when" condition and its corresponding "then" result expression.
291
- * Used within the WhenThenOtherwiseExpression.
292
- */
293
- export interface WhenThenClause {
294
- /** The condition expression. Should evaluate to a boolean. */
295
- when: Expression;
296
- /** The result expression if the 'when' condition is true. */
297
- then: Expression;
298
- }
299
-
300
- /**
301
- * Represents a conditional expression that evaluates a series of "when"
302
- * conditions and returns the corresponding "then" expression's value.
303
- * If no "when" condition is met, it returns the value of the "otherwise" expression.
304
- * This mimics Polars' when/then/otherwise functionality.
305
- */
306
- export interface WhenThenOtherwiseExpression {
307
- /** The type of operation, always 'when_then_otherwise'. */
308
- type: 'when_then_otherwise';
309
- /** An array of "when/then" clauses to be evaluated in order. */
310
- conditions: WhenThenClause[];
311
- /** The expression whose value is returned if none of the "when" conditions are met. */
312
- otherwise: Expression;
313
- }
314
-
315
- /**
316
- * Represents a substring extraction operation on an expression.
317
- * Extracts a portion of the string value resulting from the 'value' expression.
318
- * The substring starts at the 'start' index (0-based).
319
- * - If 'length' is provided, it specifies the maximum length of the substring.
320
- * - If 'end' is provided, it specifies the index *before* which the substring ends.
321
- * - If neither 'length' nor 'end' is provided, the substring extends to the end of the string.
322
- * - 'length' and 'end' are mutually exclusive.
323
- * If the requested substring range extends beyond the actual string length,
324
- * the extraction automatically stops at the end of the string.
325
- */
326
- export interface SubstringExpression {
327
- /** The type of operation, always 'substring'. */
328
- type: 'substring';
329
- /** The expression whose string value will be used. */
330
- value: Expression;
331
- /** The starting position (0-indexed). Should evaluate to a number. */
332
- start: Expression;
333
- /** The length of the substring. Mutually exclusive with 'end'. Should evaluate to a number. */
334
- length?: Expression;
335
- /** The end position of the substring (exclusive). Mutually exclusive with 'length'. Should evaluate to a number. */
336
- end?: Expression;
337
- }
338
-
339
- /**
340
- * Represents a string replacement operation.
341
- * Replaces occurrences of a pattern (regex or literal) in a string expression with a replacement string.
342
- * The behavior is aligned with Polars' `replace` and `replace_all` functions.
343
- *
344
- * - If `literal` is true, the `pattern` is treated as a literal string. Otherwise, it's treated as a regular expression.
345
- * - If `replaceAll` is true, all occurrences of the pattern are replaced. Otherwise, only the first occurrence is replaced.
346
- *
347
- * When using regular expressions (i.e., `literal` is false or undefined):
348
- * - Positional capture groups can be referenced in the `replacement` string using `$n` or `${n}` (e.g., `$1` for the first group).
349
- * - Named capture groups can be referenced using `${name}`.
350
- * - To include a literal dollar sign (`$`) in the replacement, it must be escaped as `$$`.
351
- */
352
- export interface StringReplaceExpression {
353
- /** The type of operation, always 'str_replace'. */
354
- type: 'str_replace';
355
- /** The input string expression to operate on. */
356
- value: Expression;
357
- /** The pattern (regex or literal string) to search for. Can be a string literal or an expression evaluating to a string. */
358
- pattern: Expression | string;
359
- /** The replacement string. Can be a string literal or an expression evaluating to a string. Can use $n or ${name} for captured groups if pattern is a regex. */
360
- replacement: Expression | string;
361
- /** If true, replace all occurrences of the pattern. If false or undefined, replace only the first. Defaults to false. */
362
- replaceAll?: boolean;
363
- /** If true, treat the pattern as a literal string. If false or undefined, treat it as a regex. Defaults to false. */
364
- literal?: boolean;
365
- }
366
-
367
- /**
368
- * Represents a string contains operation.
369
- * Checks if the string contains a substring that matches a pattern using regex or literal matching.
370
- * Based on polars.Series.str.contains - supports both regex and literal pattern matching with optional case-insensitive flags.
371
- */
372
- export interface StringContainsExpression {
373
- /** The type of operation, always 'str_contains'. */
374
- type: 'str_contains';
375
- /** The input string expression to search in. */
376
- value: Expression;
377
- /** The pattern to search for. Can be a regex pattern (default) or literal string when literal=true. */
378
- pattern: Expression | string;
379
- /** If true, treat the pattern as a literal string. If false, treat it as a regex pattern. Defaults to false. */
380
- literal?: boolean;
381
- /** If true, raise an error if pattern is invalid regex. If false, return null for invalid patterns. Defaults to true. */
382
- strict?: boolean;
383
- }
384
-
385
- /**
386
- * Represents a string starts_with operation.
387
- * Checks if the string starts with a specified prefix. Always uses literal matching (no regex support).
388
- * Based on polars.Series.str.starts_with - only supports literal prefix matching.
389
- */
390
- export interface StringStartsWithExpression {
391
- /** The type of operation, always 'str_starts_with'. */
392
- type: 'str_starts_with';
393
- /** The input string expression to check. */
394
- value: Expression;
395
- /** The prefix to check for (always treated as literal string, no regex support). */
396
- prefix: Expression | string;
397
- }
398
-
399
- /**
400
- * Represents a string ends_with operation.
401
- * Checks if the string ends with a specified suffix. Always uses literal matching (no regex support).
402
- * Based on polars.Series.str.ends_with - only supports literal suffix matching.
403
- */
404
- export interface StringEndsWithExpression {
405
- /** The type of operation, always 'str_ends_with'. */
406
- type: 'str_ends_with';
407
- /** The input string expression to check. */
408
- value: Expression;
409
- /** The suffix to check for (always treated as literal string, no regex support). */
410
- suffix: Expression | string;
411
- }
412
-
413
- /**
414
- * Represents a string contains_any operation using the Aho-Corasick algorithm.
415
- * Checks if the string contains any of the provided patterns using fast multi-pattern string matching.
416
- * Based on polars.Series.str.contains_any - uses Aho-Corasick algorithm for efficient multi-pattern matching.
417
- */
418
- export interface StringContainsAnyExpression {
419
- /** The type of operation, always 'str_contains_any'. */
420
- type: 'str_contains_any';
421
- /** The input string expression to search in. */
422
- value: Expression;
423
- /** Array of literal string patterns to search for. Only immediate string values are supported, no expressions or regex patterns. */
424
- patterns: string[];
425
- /** Enable ASCII-aware case insensitive matching. When enabled, searching is performed without respect to case for ASCII letters (a-z and A-Z) only. Defaults to false. */
426
- asciiCaseInsensitive?: boolean;
427
- }
428
-
429
- /**
430
- * Represents a string count_matches operation.
431
- * Counts the number of times a pattern occurs in the string using regex or literal matching.
432
- * Based on polars.Series.str.count_matches - supports both regex and literal pattern matching.
433
- */
434
- export interface StringCountMatchesExpression {
435
- /** The type of operation, always 'str_count_matches'. */
436
- type: 'str_count_matches';
437
- /** The input string expression to count matches in. */
438
- value: Expression;
439
- /** The pattern to count occurrences of. Can be a regex pattern (default) or literal string when literal=true. */
440
- pattern: Expression | string;
441
- /** If true, treat the pattern as a literal string. If false, treat it as a regex pattern. Defaults to false. */
442
- literal?: boolean;
443
- }
444
-
445
- /**
446
- * Represents a string extract operation using regex patterns.
447
- * Extracts the first match of a regex pattern from the string, optionally targeting specific capture groups.
448
- * Based on polars.Series.str.extract - only supports regex patterns (no literal mode).
449
- */
450
- export interface StringExtractExpression {
451
- /** The type of operation, always 'str_extract'. */
452
- type: 'str_extract';
453
- /** The input string expression to extract from. */
454
- value: Expression;
455
- /** The regex pattern to extract. Must be a valid regex pattern - no literal string mode is supported. */
456
- pattern: Expression | string;
457
- /** The capture group index to extract. Group 0 is the entire match, group 1 is the first capture group, etc. Defaults to 0. */
458
- groupIndex?: number;
459
- }
460
-
461
- /** Defines the supported min/max operators. */
462
- export type MinMaxOperator = 'min' | 'max';
463
-
464
- /** Represents a min or max operation on a list of expressions. */
465
- export interface MinMaxExpression {
466
- /** The type of operation ('min' or 'max'). */
467
- type: MinMaxOperator;
468
- /** An array of expressions to find the minimum or maximum value from. */
469
- operands: Expression[];
470
- }
471
-
472
- /**
473
- * Represents a fill NA (null) operation.
474
- * If the 'input' expression evaluates to null, the 'fillValue' expression is used.
475
- * Otherwise, the 'input' expression's value is used.
476
- * 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
- */
479
- export interface FillNaExpression {
480
- /** The type of operation, always 'fill_na'. */
481
- type: 'fill_na';
482
- /** The primary expression to evaluate. */
483
- input: Expression;
484
- /** The expression whose value is used if 'input' is null. */
485
- fillValue: Expression;
486
- }
487
-
488
- /**
489
- * Defines standard aggregation functions that can be used in window expressions.
490
- */
491
- export type AggregationType =
492
- | 'sum'
493
- | 'mean'
494
- | 'median'
495
- | 'min'
496
- | 'max'
497
- | 'std'
498
- | 'var'
499
- | 'count'
500
- | 'first'
501
- | 'last'
502
- | 'n_unique';
503
-
504
- /**
505
- * Represents a window function call.
506
- * This allows applying an aggregation function over a specific partition of the data.
507
- */
508
- export interface WindowExpression {
509
- /** The type of operation, always 'aggregate'. Note: This might be confusing, consider 'window_aggregate' or similar if 'aggregate' is heavily used elsewhere for a different step type. */
510
- type: 'aggregate';
511
- /** The aggregation function to apply (e.g., 'sum', 'mean'). */
512
- aggregation: AggregationType;
513
- /** The expression to apply the aggregation function to. */
514
- value: Expression;
515
- /** List of expressions to partition the data by. The aggregation is performed independently within each partition. */
516
- partitionBy: Expression[];
517
- }
518
-
519
- /**
520
- * Represents a struct field access operation.
521
- * This operation retrieves a single field from a struct (nested data structure).
522
- * It corresponds to Polars' struct.field() functionality.
523
- *
524
- * When fields is an array, the operation performs recursive field access,
525
- * where each element in the array represents a level in the nested structure.
526
- */
527
- export interface StructFieldExpression {
528
- /** The type of operation, always 'struct_field'. */
529
- type: 'struct_field';
530
- /** The struct expression to extract fields from. */
531
- struct: Expression;
532
- /**
533
- * The field name(s) to extract from the struct.
534
- * - If a string, extracts a single field from the struct.
535
- * - If an array, performs recursive field access where each element represents a level in the nested structure.
536
- */
537
- fields: string | string[];
538
- /**
539
- * Optional expected data type for the returned value.
540
- * This can be used for type validation or casting of the extracted field.
541
- */
542
- dtype?: DataType;
543
- /**
544
- * Optional default value to return if the field is not found or is null.
545
- * If not provided and the field is missing, the operation returns null.
546
- * Only constant scalar values are supported.
547
- */
548
- default?: string | number | boolean | null;
549
- }