df-script 1.4.0 → 1.5.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.
Files changed (95) hide show
  1. package/README.md +83 -34
  2. package/dist/api.d.ts +16 -8
  3. package/dist/api.js +11 -3
  4. package/dist/columnExpressions/ColumnExpr.d.ts +26 -364
  5. package/dist/columnExpressions/ColumnExpr.js +199 -3
  6. package/dist/columnExpressions/ExprBase.d.ts +8 -11
  7. package/dist/columnExpressions/ExprBase.js +20 -61
  8. package/dist/columnExpressions/constants.d.ts +2 -0
  9. package/dist/columnExpressions/constants.js +3 -1
  10. package/dist/columnExpressions/functions/coalesce.js +8 -4
  11. package/dist/columnExpressions/functions/element.d.ts +5 -0
  12. package/dist/columnExpressions/functions/element.js +11 -0
  13. package/dist/columnExpressions/functions/implode.d.ts +3 -0
  14. package/dist/columnExpressions/functions/implode.js +7 -0
  15. package/dist/columnExpressions/functions/lit.d.ts +3 -1
  16. package/dist/columnExpressions/functions/lit.js +8 -13
  17. package/dist/columnExpressions/functions/repeat.d.ts +47 -0
  18. package/dist/columnExpressions/functions/repeat.js +131 -0
  19. package/dist/columnExpressions/functions/seq_range.d.ts +31 -0
  20. package/dist/columnExpressions/functions/seq_range.js +91 -0
  21. package/dist/columnExpressions/functions/when.js +8 -4
  22. package/dist/columnExpressions/index.d.ts +5 -2
  23. package/dist/columnExpressions/index.js +5 -48
  24. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +25 -50
  25. package/dist/columnExpressions/mixins/AggregationExpr.js +69 -165
  26. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +41 -66
  27. package/dist/columnExpressions/mixins/ArithmeticExpr.js +126 -138
  28. package/dist/columnExpressions/mixins/BooleanExpr.d.ts +40 -0
  29. package/dist/columnExpressions/mixins/BooleanExpr.js +67 -0
  30. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +31 -60
  31. package/dist/columnExpressions/mixins/ComparisonExpr.js +231 -370
  32. package/dist/columnExpressions/mixins/ListExpr.d.ts +15 -39
  33. package/dist/columnExpressions/mixins/ListExpr.js +124 -148
  34. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +7 -33
  35. package/dist/columnExpressions/mixins/LogicalExpr.js +48 -49
  36. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +6 -31
  37. package/dist/columnExpressions/mixins/ManipulationExpr.js +61 -25
  38. package/dist/columnExpressions/mixins/NumericExpr.d.ts +92 -0
  39. package/dist/columnExpressions/mixins/NumericExpr.js +259 -0
  40. package/dist/columnExpressions/mixins/StringExpr.d.ts +5 -30
  41. package/dist/columnExpressions/mixins/StringExpr.js +37 -49
  42. package/dist/columnExpressions/mixins/StructExpr.d.ts +16 -0
  43. package/dist/columnExpressions/mixins/StructExpr.js +139 -0
  44. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +4 -30
  45. package/dist/columnExpressions/mixins/TemporalExpr.js +28 -29
  46. package/dist/columnExpressions/mixins/WindowExpr.d.ts +27 -49
  47. package/dist/columnExpressions/mixins/WindowExpr.js +144 -274
  48. package/dist/columnExpressions/utils.d.ts +4 -0
  49. package/dist/columnExpressions/utils.js +45 -0
  50. package/dist/dataframe/constants.d.ts +3 -0
  51. package/dist/dataframe/constants.js +4 -1
  52. package/dist/dataframe/dataframe.d.ts +27 -10
  53. package/dist/dataframe/dataframe.js +461 -220
  54. package/dist/dataframe/grouped/grouped.d.ts +2 -3
  55. package/dist/dataframe/grouped/grouped.js +17 -16
  56. package/dist/dataframe/types.d.ts +65 -1
  57. package/dist/dataframe/utils.d.ts +11 -3
  58. package/dist/dataframe/utils.js +101 -9
  59. package/dist/datatypes/DataType.d.ts +2 -1
  60. package/dist/datatypes/DataType.js +29 -0
  61. package/dist/datatypes/index.d.ts +2 -2
  62. package/dist/datatypes/types.d.ts +37 -36
  63. package/dist/datatypes/types.js +15 -11
  64. package/dist/exceptions/index.d.ts +2 -0
  65. package/dist/exceptions/index.js +4 -1
  66. package/dist/exceptions/utils.d.ts +1 -0
  67. package/dist/exceptions/utils.js +19 -0
  68. package/dist/functions/concat.d.ts +1 -2
  69. package/dist/functions/concat.js +24 -12
  70. package/dist/functions/index.d.ts +3 -1
  71. package/dist/functions/index.js +7 -15
  72. package/dist/functions/read_csv.d.ts +8 -0
  73. package/dist/functions/read_csv.js +53 -0
  74. package/dist/functions/read_json.d.ts +10 -0
  75. package/dist/functions/read_json.js +21 -0
  76. package/dist/functions/transpose.d.ts +7 -0
  77. package/dist/functions/transpose.js +84 -0
  78. package/dist/index.js +6 -1
  79. package/dist/types.d.ts +31 -5
  80. package/dist/utils/csv.d.ts +77 -0
  81. package/dist/utils/csv.js +313 -0
  82. package/dist/utils/date.js +5 -6
  83. package/dist/utils/guards.d.ts +0 -2
  84. package/dist/utils/guards.js +0 -31
  85. package/dist/utils/index.d.ts +2 -0
  86. package/dist/utils/index.js +2 -0
  87. package/dist/utils/json.d.ts +120 -2
  88. package/dist/utils/json.js +204 -20
  89. package/dist/utils/list.d.ts +173 -1
  90. package/dist/utils/list.js +255 -22
  91. package/dist/utils/number.d.ts +61 -28
  92. package/dist/utils/number.js +248 -70
  93. package/dist/utils/string.d.ts +5 -0
  94. package/dist/utils/string.js +89 -0
  95. package/package.json +5 -1
@@ -1,368 +1,30 @@
1
1
  import { ExprBase } from "./ExprBase";
2
- declare const ColumnExpr_base: {
3
- new (...args: any[]): {
4
- get list(): import("./mixins/ListExpr").ListExprNamespace;
5
- ops: import("..").OpFn[];
6
- colName?: string;
7
- outputName?: string;
8
- isLiteral?: boolean;
9
- literalValue?: any;
10
- aggFn?: import("..").AggFn<any> | null;
11
- groupingOpsIndex?: number;
12
- partitionOpsIndex?: number;
13
- partitionBy?: (string | import("..").IExpr)[] | null;
14
- windowOp?: {
15
- type: string;
16
- [key: string]: any;
17
- } | null;
18
- isWindow?: boolean;
19
- alias(name: string): /*elided*/ any;
20
- cast(dataType: any): /*elided*/ any;
21
- _resolve(val: any, columns: import("..").ColumnDict, height: number): import("..").ColumnData | any;
22
- evaluate(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
23
- evaluatePreGrouping(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
24
- evaluatePostGrouping(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
25
- evaluatePrePartition(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
26
- evaluatePostPartition(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
27
- evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
28
- debug(label?: string): /*elided*/ any;
29
- };
30
- } & {
31
- new (...args: any[]): {
32
- get dt(): import("./mixins/TemporalExpr").DateTimeExprNamespace;
33
- ops: import("..").OpFn[];
34
- colName?: string;
35
- outputName?: string;
36
- isLiteral?: boolean;
37
- literalValue?: any;
38
- aggFn?: import("..").AggFn<any> | null;
39
- groupingOpsIndex?: number;
40
- partitionOpsIndex?: number;
41
- partitionBy?: (string | import("..").IExpr)[] | null;
42
- windowOp?: {
43
- type: string;
44
- [key: string]: any;
45
- } | null;
46
- isWindow?: boolean;
47
- alias(name: string): /*elided*/ any;
48
- cast(dataType: any): /*elided*/ any;
49
- _resolve(val: any, columns: import("..").ColumnDict, height: number): import("..").ColumnData | any;
50
- evaluate(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
51
- evaluatePreGrouping(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
52
- evaluatePostGrouping(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
53
- evaluatePrePartition(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
54
- evaluatePostPartition(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
55
- evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
56
- debug(label?: string): /*elided*/ any;
57
- };
58
- } & {
59
- new (...args: any[]): {
60
- and(other: any): /*elided*/ any;
61
- not(): /*elided*/ any;
62
- or(other: any): /*elided*/ any;
63
- xor(other: any): /*elided*/ any;
64
- ops: import("..").OpFn[];
65
- colName?: string;
66
- outputName?: string;
67
- isLiteral?: boolean;
68
- literalValue?: any;
69
- aggFn?: import("..").AggFn<any> | null;
70
- groupingOpsIndex?: number;
71
- partitionOpsIndex?: number;
72
- partitionBy?: (string | import("..").IExpr)[] | null;
73
- windowOp?: {
74
- type: string;
75
- [key: string]: any;
76
- } | null;
77
- isWindow?: boolean;
78
- alias(name: string): /*elided*/ any;
79
- cast(dataType: any): /*elided*/ any;
80
- _resolve(val: any, columns: import("..").ColumnDict, height: number): import("..").ColumnData | any;
81
- evaluate(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
82
- evaluatePreGrouping(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
83
- evaluatePostGrouping(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
84
- evaluatePrePartition(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
85
- evaluatePostPartition(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
86
- evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
87
- debug(label?: string): /*elided*/ any;
88
- };
89
- } & {
90
- new (...args: any[]): {
91
- get str(): import("./mixins/StringExpr").StringExprNamespace;
92
- ops: import("..").OpFn[];
93
- colName?: string;
94
- outputName?: string;
95
- isLiteral?: boolean;
96
- literalValue?: any;
97
- aggFn?: import("..").AggFn<any> | null;
98
- groupingOpsIndex?: number;
99
- partitionOpsIndex?: number;
100
- partitionBy?: (string | import("..").IExpr)[] | null;
101
- windowOp?: {
102
- type: string;
103
- [key: string]: any;
104
- } | null;
105
- isWindow?: boolean;
106
- alias(name: string): /*elided*/ any;
107
- cast(dataType: any): /*elided*/ any;
108
- _resolve(val: any, columns: import("..").ColumnDict, height: number): import("..").ColumnData | any;
109
- evaluate(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
110
- evaluatePreGrouping(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
111
- evaluatePostGrouping(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
112
- evaluatePrePartition(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
113
- evaluatePostPartition(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
114
- evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
115
- debug(label?: string): /*elided*/ any;
116
- };
117
- } & {
118
- new (...args: any[]): {
119
- partitionBy: (string | import("..").IExpr)[] | null;
120
- _rolling(windowSize: number, aggFn: (vals: any[]) => any): /*elided*/ any;
121
- get isWindow(): boolean;
122
- cum_count(reverse?: boolean): /*elided*/ any;
123
- cum_max(reverse?: boolean): /*elided*/ any;
124
- cum_min(reverse?: boolean): /*elided*/ any;
125
- cum_prod(reverse?: boolean): /*elided*/ any;
126
- cum_sum(reverse?: boolean): /*elided*/ any;
127
- dense_rank(): /*elided*/ any;
128
- lag(offset?: number, defaultVal?: any): /*elided*/ any;
129
- lead(offset?: number, defaultVal?: any): /*elided*/ any;
130
- over(columns: string | import("..").IExpr | (string | import("..").IExpr)[]): /*elided*/ any;
131
- rank(): /*elided*/ any;
132
- rolling_max(windowSize: number): /*elided*/ any;
133
- rolling_mean(windowSize: number): /*elided*/ any;
134
- rolling_median(windowSize: number): /*elided*/ any;
135
- rolling_min(windowSize: number): /*elided*/ any;
136
- rolling_quantile(quantile: number, windowSize: number): /*elided*/ any;
137
- rolling_rank(windowSize: number): /*elided*/ any;
138
- rolling_std(windowSize: number): /*elided*/ any;
139
- rolling_sum(windowSize: number): /*elided*/ any;
140
- row_number(): /*elided*/ any;
141
- ops: import("..").OpFn[];
142
- colName?: string;
143
- outputName?: string;
144
- isLiteral?: boolean;
145
- literalValue?: any;
146
- aggFn?: import("..").AggFn<any> | null;
147
- groupingOpsIndex?: number;
148
- partitionOpsIndex?: number;
149
- windowOp?: {
150
- type: string;
151
- [key: string]: any;
152
- } | null;
153
- alias(name: string): /*elided*/ any;
154
- cast(dataType: any): /*elided*/ any;
155
- _resolve(val: any, columns: import("..").ColumnDict, height: number): import("..").ColumnData | any;
156
- evaluate(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
157
- evaluatePreGrouping(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
158
- evaluatePostGrouping(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
159
- evaluatePrePartition(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
160
- evaluatePostPartition(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
161
- evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
162
- debug(label?: string): /*elided*/ any;
163
- };
164
- } & {
165
- new (...args: any[]): {
166
- aggFn: import("..").AggFn<any> | null;
167
- _deriveAgg(fn: import("..").AggFn<any>): /*elided*/ any;
168
- all(): /*elided*/ any;
169
- all_null(): /*elided*/ any;
170
- any(): /*elided*/ any;
171
- any_null(): /*elided*/ any;
172
- avg(): /*elided*/ any;
173
- count(options?: {
174
- includeNulls?: boolean;
175
- }): /*elided*/ any;
176
- first(): /*elided*/ any;
177
- last(): /*elided*/ any;
178
- max(): /*elided*/ any;
179
- mean(): /*elided*/ any;
180
- median(): /*elided*/ any;
181
- min(): /*elided*/ any;
182
- mode(): /*elided*/ any;
183
- n_unique(): /*elided*/ any;
184
- quantile(q: number): /*elided*/ any;
185
- std(): /*elided*/ any;
186
- sum(): /*elided*/ any;
187
- ops: import("..").OpFn[];
188
- colName?: string;
189
- outputName?: string;
190
- isLiteral?: boolean;
191
- literalValue?: any;
192
- groupingOpsIndex?: number;
193
- partitionOpsIndex?: number;
194
- partitionBy?: (string | import("..").IExpr)[] | null;
195
- windowOp?: {
196
- type: string;
197
- [key: string]: any;
198
- } | null;
199
- isWindow?: boolean;
200
- alias(name: string): /*elided*/ any;
201
- cast(dataType: any): /*elided*/ any;
202
- _resolve(val: any, columns: import("..").ColumnDict, height: number): import("..").ColumnData | any;
203
- evaluate(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
204
- evaluatePreGrouping(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
205
- evaluatePostGrouping(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
206
- evaluatePrePartition(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
207
- evaluatePostPartition(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
208
- evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
209
- debug(label?: string): /*elided*/ any;
210
- };
211
- } & {
212
- new (...args: any[]): {
213
- between(lower: any, upper: any, closed?: "both" | "left" | "right" | "none"): /*elided*/ any;
214
- eq(val: any): /*elided*/ any;
215
- eq_missing(val: any): /*elided*/ any;
216
- ge(val: any): /*elided*/ any;
217
- gt(val: any): /*elided*/ any;
218
- has_nulls(): any;
219
- is_close(other: any, options?: {
220
- abs_tol?: number;
221
- rel_tol?: number;
222
- nans_equal?: boolean;
223
- }): /*elided*/ any;
224
- is_duplicated(): /*elided*/ any;
225
- is_empty(options?: {
226
- ignoreNulls?: boolean;
227
- }): /*elided*/ any;
228
- is_finite(): /*elided*/ any;
229
- is_first_distinct(): /*elided*/ any;
230
- is_in(values: any[] | any): /*elided*/ any;
231
- is_infinite(): /*elided*/ any;
232
- is_last_distinct(): /*elided*/ any;
233
- is_n_distinct(n: number): any;
234
- is_nan(): /*elided*/ any;
235
- is_not_nan(): /*elided*/ any;
236
- is_not_null(): /*elided*/ any;
237
- is_null(): /*elided*/ any;
238
- is_unique(): /*elided*/ any;
239
- le(val: any): /*elided*/ any;
240
- lt(val: any): /*elided*/ any;
241
- ne(val: any): /*elided*/ any;
242
- ne_missing(val: any): /*elided*/ any;
243
- not_in(values: any[] | any): /*elided*/ any;
244
- ops: import("..").OpFn[];
245
- colName?: string;
246
- outputName?: string;
247
- isLiteral?: boolean;
248
- literalValue?: any;
249
- aggFn?: import("..").AggFn<any> | null;
250
- groupingOpsIndex?: number;
251
- partitionOpsIndex?: number;
252
- partitionBy?: (string | import("..").IExpr)[] | null;
253
- windowOp?: {
254
- type: string;
255
- [key: string]: any;
256
- } | null;
257
- isWindow?: boolean;
258
- alias(name: string): /*elided*/ any;
259
- cast(dataType: any): /*elided*/ any;
260
- _resolve(val: any, columns: import("..").ColumnDict, height: number): import("..").ColumnData | any;
261
- evaluate(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
262
- evaluatePreGrouping(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
263
- evaluatePostGrouping(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
264
- evaluatePrePartition(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
265
- evaluatePostPartition(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
266
- evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
267
- debug(label?: string): /*elided*/ any;
268
- };
269
- } & {
270
- new (...args: any[]): {
271
- abs(): /*elided*/ any;
272
- acos(): /*elided*/ any;
273
- acosh(): /*elided*/ any;
274
- add(val: number | import("..").IExpr | null): /*elided*/ any;
275
- asin(): /*elided*/ any;
276
- asinh(): /*elided*/ any;
277
- atan(): /*elided*/ any;
278
- atanh(): /*elided*/ any;
279
- cbrt(): /*elided*/ any;
280
- ceil(): /*elided*/ any;
281
- clip(lower?: number | null, upper?: number | null): /*elided*/ any;
282
- cos(): /*elided*/ any;
283
- cosh(): /*elided*/ any;
284
- degrees(): /*elided*/ any;
285
- div(val: number | import("..").IExpr | null): /*elided*/ any;
286
- exp(): /*elided*/ any;
287
- expm1(): /*elided*/ any;
288
- floor(): /*elided*/ any;
289
- floordiv(val: number | import("..").IExpr | null): /*elided*/ any;
290
- hypot(val: number | import("..").IExpr | null): /*elided*/ any;
291
- log(base?: number): /*elided*/ any;
292
- log1p(): /*elided*/ any;
293
- mod(val: number | import("..").IExpr | null): /*elided*/ any;
294
- mul(val: number | import("..").IExpr | null): /*elided*/ any;
295
- negate(): /*elided*/ any;
296
- pow(val: number | import("..").IExpr | null): /*elided*/ any;
297
- radians(): /*elided*/ any;
298
- rand(seed?: number, { min, max, integer }?: import("./types").RandomOptions): /*elided*/ any;
299
- round(decimals?: number): /*elided*/ any;
300
- sign(): /*elided*/ any;
301
- sin(): /*elided*/ any;
302
- sinh(): /*elided*/ any;
303
- sqrt(): /*elided*/ any;
304
- sub(val: number | import("..").IExpr | null): /*elided*/ any;
305
- tan(): /*elided*/ any;
306
- tanh(): /*elided*/ any;
307
- trunc(): /*elided*/ any;
308
- ops: import("..").OpFn[];
309
- colName?: string;
310
- outputName?: string;
311
- isLiteral?: boolean;
312
- literalValue?: any;
313
- aggFn?: import("..").AggFn<any> | null;
314
- groupingOpsIndex?: number;
315
- partitionOpsIndex?: number;
316
- partitionBy?: (string | import("..").IExpr)[] | null;
317
- windowOp?: {
318
- type: string;
319
- [key: string]: any;
320
- } | null;
321
- isWindow?: boolean;
322
- alias(name: string): /*elided*/ any;
323
- cast(dataType: any): /*elided*/ any;
324
- _resolve(val: any, columns: import("..").ColumnDict, height: number): import("..").ColumnData | any;
325
- evaluate(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
326
- evaluatePreGrouping(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
327
- evaluatePostGrouping(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
328
- evaluatePrePartition(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
329
- evaluatePostPartition(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
330
- evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
331
- debug(label?: string): /*elided*/ any;
332
- };
333
- } & {
334
- new (...args: any[]): {
335
- fill_null(value: any): /*elided*/ any;
336
- reverse(): /*elided*/ any;
337
- ops: import("..").OpFn[];
338
- colName?: string;
339
- outputName?: string;
340
- isLiteral?: boolean;
341
- literalValue?: any;
342
- aggFn?: import("..").AggFn<any> | null;
343
- groupingOpsIndex?: number;
344
- partitionOpsIndex?: number;
345
- partitionBy?: (string | import("..").IExpr)[] | null;
346
- windowOp?: {
347
- type: string;
348
- [key: string]: any;
349
- } | null;
350
- isWindow?: boolean;
351
- alias(name: string): /*elided*/ any;
352
- cast(dataType: any): /*elided*/ any;
353
- _resolve(val: any, columns: import("..").ColumnDict, height: number): import("..").ColumnData | any;
354
- evaluate(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
355
- evaluatePreGrouping(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
356
- evaluatePostGrouping(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
357
- evaluatePrePartition(columns: import("..").ColumnDict, height: number): import("..").ColumnData;
358
- evaluatePostPartition(aggregatedArray: any[], columns: import("..").ColumnDict): import("..").ColumnData;
359
- evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
360
- debug(label?: string): /*elided*/ any;
361
- };
362
- } & typeof ExprBase;
363
- export declare class ColumnExpr<T> extends ColumnExpr_base {
2
+ import { ArithmeticExpr } from "./mixins/ArithmeticExpr";
3
+ import { ComparisonExpr } from "./mixins/ComparisonExpr";
4
+ import { AggregationExpr } from "./mixins/AggregationExpr";
5
+ import { WindowExpr } from "./mixins/WindowExpr";
6
+ import { StringExpr } from "./mixins/StringExpr";
7
+ import { LogicalExpr } from "./mixins/LogicalExpr";
8
+ import { TemporalExpr } from "./mixins/TemporalExpr";
9
+ import { ListExpr } from "./mixins/ListExpr";
10
+ import { StructExpr } from "./mixins/StructExpr";
11
+ import { ManipulationExpr } from "./mixins/ManipulationExpr";
12
+ import { DataType } from "../datatypes";
13
+ import type { IntoExpr, IExpr, DataFrameSchema, ColumnDict } from "../types";
14
+ export declare class ColumnExpr<T> extends ExprBase {
364
15
  colName: string;
16
+ colNames?: string[];
365
17
  excludedCols: string[];
366
- constructor(colName: keyof T | string);
18
+ targetType?: any;
19
+ targetTypes?: any[];
20
+ static isColExpr(v: unknown): v is ColumnExpr<any>;
21
+ static toColExpr(col: IntoExpr | IntoExpr[]): ColumnExpr<any>;
22
+ constructor(colName: keyof T | string | (keyof T | string)[] | DataType | Function | (DataType | Function)[]);
367
23
  }
368
- export {};
24
+ export interface ColumnExpr<T> extends ArithmeticExpr, ComparisonExpr, AggregationExpr, WindowExpr, StringExpr, LogicalExpr, TemporalExpr, ListExpr, StructExpr, ManipulationExpr {
25
+ }
26
+ /**
27
+ * Resolves column selectors, expanding wildcards, datatypes, and arrays of columns/types
28
+ * into concrete ColumnExpr instances.
29
+ */
30
+ export declare function resolveColumnSelectors(exprs: any[], allKeys: string[], keysToExcludeFromAll?: string[], schema?: DataFrameSchema, columns?: ColumnDict): IExpr[];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ColumnExpr = void 0;
4
+ exports.resolveColumnSelectors = resolveColumnSelectors;
4
5
  const ExprBase_1 = require("./ExprBase");
5
6
  const ArithmeticExpr_1 = require("./mixins/ArithmeticExpr");
6
7
  const ComparisonExpr_1 = require("./mixins/ComparisonExpr");
@@ -10,14 +11,209 @@ const StringExpr_1 = require("./mixins/StringExpr");
10
11
  const LogicalExpr_1 = require("./mixins/LogicalExpr");
11
12
  const TemporalExpr_1 = require("./mixins/TemporalExpr");
12
13
  const ListExpr_1 = require("./mixins/ListExpr");
14
+ const StructExpr_1 = require("./mixins/StructExpr");
13
15
  const ManipulationExpr_1 = require("./mixins/ManipulationExpr");
14
- class ColumnExpr extends (0, ListExpr_1.ListExpr)((0, TemporalExpr_1.TemporalExpr)((0, LogicalExpr_1.LogicalExpr)((0, StringExpr_1.StringExpr)((0, WindowExpr_1.WindowExpr)((0, AggregationExpr_1.AggregationExpr)((0, ComparisonExpr_1.ComparisonExpr)((0, ArithmeticExpr_1.ArithmeticExpr)((0, ManipulationExpr_1.ManipulationExpr)(ExprBase_1.ExprBase))))))))) {
16
+ const utils_1 = require("../utils");
17
+ const datatypes_1 = require("../datatypes");
18
+ const constants_1 = require("./constants");
19
+ class ColumnExpr extends ExprBase_1.ExprBase {
15
20
  colName;
21
+ colNames;
16
22
  excludedCols = [];
23
+ targetType;
24
+ targetTypes;
25
+ static isColExpr(v) {
26
+ if (!(0, utils_1.isObj)(v))
27
+ return false;
28
+ try {
29
+ return "evaluate" in v && typeof v.evaluate === "function";
30
+ }
31
+ catch {
32
+ return false;
33
+ }
34
+ }
35
+ static toColExpr(col) {
36
+ if (col == null) {
37
+ throw new Error("Column reference cannot be null or undefined.");
38
+ }
39
+ return ColumnExpr.isColExpr(col) ? col : new ColumnExpr(col);
40
+ }
17
41
  constructor(colName) {
18
42
  super();
19
- this.colName = String(colName);
20
- this.outputName = this.colName;
43
+ if (Array.isArray(colName)) {
44
+ const hasTypes = colName.some(x => x instanceof datatypes_1.DataType || typeof x === "function");
45
+ if (hasTypes) {
46
+ this.targetTypes = colName;
47
+ this.colName = "";
48
+ this.outputName = "";
49
+ }
50
+ else {
51
+ this.colNames = colName.map(String);
52
+ this.colName = "";
53
+ this.outputName = "";
54
+ }
55
+ }
56
+ else if (colName instanceof datatypes_1.DataType || typeof colName === "function") {
57
+ this.targetType = colName;
58
+ this.colName = "";
59
+ this.outputName = "";
60
+ }
61
+ else {
62
+ this.colName = String(colName);
63
+ this.outputName = this.colName;
64
+ }
21
65
  }
22
66
  }
23
67
  exports.ColumnExpr = ColumnExpr;
68
+ function applyMixins(derivedCtor, constructors) {
69
+ for (const baseCtor of constructors) {
70
+ for (const name of Object.getOwnPropertyNames(baseCtor.prototype)) {
71
+ if (name !== 'constructor') {
72
+ Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || Object.create(null));
73
+ }
74
+ }
75
+ }
76
+ }
77
+ applyMixins(ColumnExpr, [
78
+ ArithmeticExpr_1.ArithmeticExpr,
79
+ ComparisonExpr_1.ComparisonExpr,
80
+ AggregationExpr_1.AggregationExpr,
81
+ WindowExpr_1.WindowExpr,
82
+ StringExpr_1.StringExpr,
83
+ LogicalExpr_1.LogicalExpr,
84
+ TemporalExpr_1.TemporalExpr,
85
+ ListExpr_1.ListExpr,
86
+ StructExpr_1.StructExpr,
87
+ ManipulationExpr_1.ManipulationExpr
88
+ ]);
89
+ /**
90
+ * Determines which concrete keys a column selector matches.
91
+ * Returns null if the expression is not a multi-column selector.
92
+ */
93
+ function getTargetKeys(expr, allKeys, excludeSet, schema) {
94
+ if (!(expr instanceof ColumnExpr)) {
95
+ if (expr && typeof expr === "object" && "evaluate" in expr && !expr.colName) {
96
+ const targets = [];
97
+ for (let i = 0; i < allKeys.length; i++) {
98
+ if (!excludeSet.has(allKeys[i])) {
99
+ targets.push(allKeys[i]);
100
+ }
101
+ }
102
+ return targets;
103
+ }
104
+ return null;
105
+ }
106
+ if (expr.colNames && expr.colNames.length > 0) {
107
+ return expr.colNames;
108
+ }
109
+ if (expr.colName === constants_1.ALL_COLUMNS_MARKER) {
110
+ const excluded = new Set(expr.excludedCols);
111
+ const targets = [];
112
+ for (let i = 0; i < allKeys.length; i++) {
113
+ const key = allKeys[i];
114
+ if (!excluded.has(key) && !excludeSet.has(key)) {
115
+ targets.push(key);
116
+ }
117
+ }
118
+ return targets;
119
+ }
120
+ if (expr.targetType || (expr.targetTypes && expr.targetTypes.length > 0)) {
121
+ if (!schema) {
122
+ throw new Error("Cannot resolve DataType column selector without DataFrame schema.");
123
+ }
124
+ const targets = [];
125
+ for (let i = 0; i < allKeys.length; i++) {
126
+ const key = allKeys[i];
127
+ if (excludeSet.has(key)) {
128
+ continue;
129
+ }
130
+ const colType = schema[key];
131
+ if (!colType) {
132
+ continue;
133
+ }
134
+ if (expr.targetType) {
135
+ if (colType.matches(expr.targetType)) {
136
+ targets.push(key);
137
+ }
138
+ }
139
+ else if (expr.targetTypes) {
140
+ for (let k = 0; k < expr.targetTypes.length; k++) {
141
+ if (colType.matches(expr.targetTypes[k])) {
142
+ targets.push(key);
143
+ break;
144
+ }
145
+ }
146
+ }
147
+ }
148
+ return targets;
149
+ }
150
+ return null;
151
+ }
152
+ /**
153
+ * Resolves column selectors, expanding wildcards, datatypes, and arrays of columns/types
154
+ * into concrete ColumnExpr instances.
155
+ */
156
+ function resolveColumnSelectors(exprs, allKeys, keysToExcludeFromAll, schema, columns) {
157
+ const expanded = [];
158
+ const excludeSet = keysToExcludeFromAll ? new Set(keysToExcludeFromAll) : new Set();
159
+ for (let i = 0; i < exprs.length; i++) {
160
+ const expr = exprs[i];
161
+ if (typeof expr === "string") {
162
+ expanded.push(new ColumnExpr(expr));
163
+ continue;
164
+ }
165
+ // Handle struct unnesting expansion
166
+ if (expr && typeof expr === "object" && expr.isUnnest) {
167
+ let fields = [];
168
+ const colName = expr.colName;
169
+ if (schema && colName && schema[colName] && schema[colName].name === "Struct") {
170
+ fields = Object.keys(schema[colName].fields);
171
+ }
172
+ if (fields.length === 0 && columns) {
173
+ const columnsKeys = Object.keys(columns);
174
+ const firstKey = columnsKeys[0];
175
+ const height = firstKey ? columns[firstKey].length : 0;
176
+ const evaluated = expr.baseExpr.evaluate(columns, height);
177
+ const evalLen = evaluated.length;
178
+ for (let idx = 0; idx < evalLen; idx++) {
179
+ const item = evaluated[idx];
180
+ if (item != null && typeof item === "object") {
181
+ fields = Object.keys(item);
182
+ break;
183
+ }
184
+ }
185
+ }
186
+ const fieldsLen = fields.length;
187
+ if (fieldsLen > 0) {
188
+ for (let fIdx = 0; fIdx < fieldsLen; fIdx++) {
189
+ const fieldName = fields[fIdx];
190
+ const fieldExpr = expr.baseExpr.struct.field(fieldName);
191
+ expanded.push(fieldExpr);
192
+ }
193
+ continue;
194
+ }
195
+ }
196
+ const targets = getTargetKeys(expr, allKeys, excludeSet, schema);
197
+ if (targets !== null) {
198
+ for (let j = 0; j < targets.length; j++) {
199
+ const concrete = new ColumnExpr(targets[j]);
200
+ concrete.ops = [...(expr.ops || [])];
201
+ concrete.aggFn = expr.aggFn;
202
+ concrete.partitionOpsIndex = expr.partitionOpsIndex;
203
+ concrete.groupingOpsIndex = expr.groupingOpsIndex;
204
+ concrete.partitionBy = expr.partitionBy;
205
+ if (expr.evaluateWindow) {
206
+ concrete.evaluateWindow = expr.evaluateWindow;
207
+ }
208
+ if (expr.outputName && expr.outputName !== constants_1.ALL_COLUMNS_MARKER) {
209
+ concrete.outputName = expr.outputName;
210
+ }
211
+ expanded.push(concrete);
212
+ }
213
+ }
214
+ else {
215
+ expanded.push(expr);
216
+ }
217
+ }
218
+ return expanded;
219
+ }
@@ -1,24 +1,21 @@
1
- import type { IExpr, OpFn, AggFn, ColumnData, ColumnDict } from "../types";
2
- import type { DataType } from "../datatypes";
3
- export declare const kleeneUnary: (fn: (v: any) => any) => (vArray: ColumnData) => any[];
4
- export declare const kleeneBinary: (expr: IExpr, other: any, fn: (v: any, r: any) => any) => (vArray: ColumnData, columns: ColumnDict) => any[];
1
+ import type { IExpr, OpFn, AggFn, ColumnData, ColumnDict, RegisteredDataType } from "../types";
5
2
  export declare const derive: <T extends IExpr>(instance: T, nextOp?: OpFn) => T;
6
3
  export declare class ExprBase implements IExpr {
7
4
  ops: OpFn[];
8
5
  outputName: string;
6
+ isLiteral?: boolean;
7
+ literalValue?: any;
9
8
  aggFn?: AggFn<any> | null;
10
9
  groupingOpsIndex?: number;
11
10
  partitionOpsIndex?: number;
12
11
  partitionBy: (string | IExpr)[] | null;
12
+ evaluateWindow?: (groupPreValues: any[], partitionIndices: number[], currentIndex: number) => any;
13
13
  _resolve(val: any, columns: ColumnDict, height: number): any;
14
14
  alias(name: string): this;
15
- cast(dataType: DataType): this;
15
+ cast(dataType: RegisteredDataType): this;
16
16
  debug(label?: string): this;
17
+ private _getInitialValue;
17
18
  evaluate(columns: ColumnDict, height: number): ColumnData;
18
- private _evaluatePre;
19
- private _evaluatePost;
20
- evaluatePrePartition(columns: ColumnDict, height: number): ColumnData;
21
- evaluatePostPartition(aggregatedArray: any[], columns: ColumnDict): ColumnData;
22
- evaluatePreGrouping(columns: ColumnDict, height: number): ColumnData;
23
- evaluatePostGrouping(aggregatedArray: any[], columns: ColumnDict): ColumnData;
19
+ evaluatePre(opsIndex: number | undefined, columns: ColumnDict, height: number): ColumnData;
20
+ evaluatePost(opsIndex: number | undefined, aggregatedArray: any[], columns: ColumnDict): ColumnData;
24
21
  }