df-script 1.4.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/LICENSE +21 -0
- package/README.md +269 -0
- package/dist/api.d.ts +39 -0
- package/dist/api.js +18 -0
- package/dist/bundle.min.js +1 -0
- package/dist/columnExpressions/ColumnExpr.d.ts +368 -0
- package/dist/columnExpressions/ColumnExpr.js +23 -0
- package/dist/columnExpressions/ExprBase.d.ts +24 -0
- package/dist/columnExpressions/ExprBase.js +133 -0
- package/dist/columnExpressions/constants.d.ts +2 -0
- package/dist/columnExpressions/constants.js +5 -0
- package/dist/columnExpressions/functions/all.d.ts +5 -0
- package/dist/columnExpressions/functions/all.js +11 -0
- package/dist/columnExpressions/functions/coalesce.d.ts +3 -0
- package/dist/columnExpressions/functions/coalesce.js +40 -0
- package/dist/columnExpressions/functions/exclude.d.ts +5 -0
- package/dist/columnExpressions/functions/exclude.js +13 -0
- package/dist/columnExpressions/functions/lit.d.ts +5 -0
- package/dist/columnExpressions/functions/lit.js +22 -0
- package/dist/columnExpressions/functions/when.d.ts +24 -0
- package/dist/columnExpressions/functions/when.js +81 -0
- package/dist/columnExpressions/index.d.ts +19 -0
- package/dist/columnExpressions/index.js +81 -0
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +50 -0
- package/dist/columnExpressions/mixins/AggregationExpr.js +172 -0
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +67 -0
- package/dist/columnExpressions/mixins/ArithmeticExpr.js +143 -0
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +60 -0
- package/dist/columnExpressions/mixins/ComparisonExpr.js +389 -0
- package/dist/columnExpressions/mixins/ListExpr.d.ts +63 -0
- package/dist/columnExpressions/mixins/ListExpr.js +248 -0
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +33 -0
- package/dist/columnExpressions/mixins/LogicalExpr.js +54 -0
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +31 -0
- package/dist/columnExpressions/mixins/ManipulationExpr.js +35 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +79 -0
- package/dist/columnExpressions/mixins/StringExpr.js +249 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +69 -0
- package/dist/columnExpressions/mixins/TemporalExpr.js +127 -0
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +50 -0
- package/dist/columnExpressions/mixins/WindowExpr.js +281 -0
- package/dist/columnExpressions/types.d.ts +7 -0
- package/dist/columnExpressions/types.js +2 -0
- package/dist/dataframe/constants.d.ts +1 -0
- package/dist/dataframe/constants.js +4 -0
- package/dist/dataframe/dataframe.d.ts +42 -0
- package/dist/dataframe/dataframe.js +749 -0
- package/dist/dataframe/grouped/grouped.d.ts +15 -0
- package/dist/dataframe/grouped/grouped.js +113 -0
- package/dist/dataframe/index.d.ts +4 -0
- package/dist/dataframe/index.js +20 -0
- package/dist/dataframe/types.d.ts +33 -0
- package/dist/dataframe/types.js +2 -0
- package/dist/dataframe/utils.d.ts +11 -0
- package/dist/dataframe/utils.js +215 -0
- package/dist/datatypes/DataType.d.ts +40 -0
- package/dist/datatypes/DataType.js +47 -0
- package/dist/datatypes/index.d.ts +29 -0
- package/dist/datatypes/index.js +46 -0
- package/dist/datatypes/types/Binary.d.ts +9 -0
- package/dist/datatypes/types/Binary.js +18 -0
- package/dist/datatypes/types/Boolean.d.ts +9 -0
- package/dist/datatypes/types/Boolean.js +19 -0
- package/dist/datatypes/types/Date.d.ts +8 -0
- package/dist/datatypes/types/Date.js +21 -0
- package/dist/datatypes/types/Datetime.d.ts +8 -0
- package/dist/datatypes/types/Datetime.js +17 -0
- package/dist/datatypes/types/Decimal.d.ts +10 -0
- package/dist/datatypes/types/Decimal.js +28 -0
- package/dist/datatypes/types/Duration.d.ts +8 -0
- package/dist/datatypes/types/Duration.js +17 -0
- package/dist/datatypes/types/Float32.d.ts +8 -0
- package/dist/datatypes/types/Float32.js +17 -0
- package/dist/datatypes/types/Float64.d.ts +8 -0
- package/dist/datatypes/types/Float64.js +17 -0
- package/dist/datatypes/types/Int16.d.ts +8 -0
- package/dist/datatypes/types/Int16.js +17 -0
- package/dist/datatypes/types/Int32.d.ts +8 -0
- package/dist/datatypes/types/Int32.js +17 -0
- package/dist/datatypes/types/Int64.d.ts +8 -0
- package/dist/datatypes/types/Int64.js +17 -0
- package/dist/datatypes/types/Int8.d.ts +8 -0
- package/dist/datatypes/types/Int8.js +17 -0
- package/dist/datatypes/types/List.d.ts +10 -0
- package/dist/datatypes/types/List.js +31 -0
- package/dist/datatypes/types/Null.d.ts +9 -0
- package/dist/datatypes/types/Null.js +17 -0
- package/dist/datatypes/types/Object.d.ts +9 -0
- package/dist/datatypes/types/Object.js +17 -0
- package/dist/datatypes/types/Struct.d.ts +14 -0
- package/dist/datatypes/types/Struct.js +39 -0
- package/dist/datatypes/types/Time.d.ts +8 -0
- package/dist/datatypes/types/Time.js +29 -0
- package/dist/datatypes/types/UInt16.d.ts +8 -0
- package/dist/datatypes/types/UInt16.js +17 -0
- package/dist/datatypes/types/UInt32.d.ts +8 -0
- package/dist/datatypes/types/UInt32.js +17 -0
- package/dist/datatypes/types/UInt64.d.ts +8 -0
- package/dist/datatypes/types/UInt64.js +17 -0
- package/dist/datatypes/types/UInt8.d.ts +8 -0
- package/dist/datatypes/types/UInt8.js +17 -0
- package/dist/datatypes/types/Utf8.d.ts +10 -0
- package/dist/datatypes/types/Utf8.js +20 -0
- package/dist/datatypes/types.d.ts +172 -0
- package/dist/datatypes/types.js +286 -0
- package/dist/exceptions/index.d.ts +13 -0
- package/dist/exceptions/index.js +43 -0
- package/dist/exceptions/utils.d.ts +2 -0
- package/dist/exceptions/utils.js +9 -0
- package/dist/functions/concat.d.ts +4 -0
- package/dist/functions/concat.js +248 -0
- package/dist/functions/index.d.ts +1 -0
- package/dist/functions/index.js +17 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +47 -0
- package/dist/types.js +2 -0
- package/dist/utils/boolean.d.ts +1 -0
- package/dist/utils/boolean.js +18 -0
- package/dist/utils/date.d.ts +57 -0
- package/dist/utils/date.js +349 -0
- package/dist/utils/guards.d.ts +14 -0
- package/dist/utils/guards.js +143 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +33 -0
- package/dist/utils/list.d.ts +23 -0
- package/dist/utils/list.js +128 -0
- package/dist/utils/number.d.ts +86 -0
- package/dist/utils/number.js +223 -0
- package/dist/utils/string.d.ts +52 -0
- package/dist/utils/string.js +120 -0
- package/package.json +34 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListExpr = exports.ListExprNamespace = void 0;
|
|
4
|
+
const ExprBase_1 = require("../ExprBase");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const exceptions_1 = require("../../exceptions");
|
|
7
|
+
class ListExprNamespace {
|
|
8
|
+
expr;
|
|
9
|
+
constructor(expr) {
|
|
10
|
+
this.expr = expr;
|
|
11
|
+
}
|
|
12
|
+
_deriveList(fn) {
|
|
13
|
+
return (0, ExprBase_1.derive)(this.expr, (0, ExprBase_1.kleeneUnary)((v) => {
|
|
14
|
+
return (0, utils_1.isArrayOrTypedArray)(v) ? fn(v) : null;
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
all() {
|
|
18
|
+
return this._deriveList((arr) => {
|
|
19
|
+
const list = Array.from(arr);
|
|
20
|
+
for (let i = 0; i < list.length; i++) {
|
|
21
|
+
if (!list[i])
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
any() {
|
|
28
|
+
return this._deriveList((arr) => {
|
|
29
|
+
const list = Array.from(arr);
|
|
30
|
+
for (let i = 0; i < list.length; i++) {
|
|
31
|
+
if (list[i])
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
contains(item) {
|
|
38
|
+
return this._deriveList((arr) => {
|
|
39
|
+
return Array.from(arr).includes(item);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
contains_all(items) {
|
|
43
|
+
return this._deriveList((arr) => {
|
|
44
|
+
const list = Array.from(arr);
|
|
45
|
+
for (let i = 0; i < items.length; i++) {
|
|
46
|
+
if (!list.includes(items[i]))
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
contains_any(items) {
|
|
53
|
+
return this._deriveList((arr) => {
|
|
54
|
+
const list = Array.from(arr);
|
|
55
|
+
for (let i = 0; i < items.length; i++) {
|
|
56
|
+
if (list.includes(items[i]))
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
count_matches(item) {
|
|
63
|
+
return this._deriveList((arr) => {
|
|
64
|
+
const list = Array.from(arr);
|
|
65
|
+
let count = 0;
|
|
66
|
+
for (const val of list) {
|
|
67
|
+
if (val === item) {
|
|
68
|
+
count++;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return count;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
drop_nulls() {
|
|
75
|
+
return this._deriveList((arr) => {
|
|
76
|
+
const list = Array.from(arr);
|
|
77
|
+
const result = [];
|
|
78
|
+
for (let i = 0; i < list.length; i++) {
|
|
79
|
+
if (list[i] != null)
|
|
80
|
+
result.push(list[i]);
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
first(null_on_oob = true) {
|
|
86
|
+
return this.get(0, null_on_oob);
|
|
87
|
+
}
|
|
88
|
+
gather(indices, null_on_oob = true) {
|
|
89
|
+
const idxs = Array.isArray(indices) ? indices : [indices];
|
|
90
|
+
return this._deriveList((arr) => {
|
|
91
|
+
const len = arr.length;
|
|
92
|
+
const res = new Array(idxs.length);
|
|
93
|
+
for (let i = 0; i < idxs.length; i++) {
|
|
94
|
+
const index = idxs[i];
|
|
95
|
+
const val = arr.at(index);
|
|
96
|
+
if (val === undefined && !null_on_oob) {
|
|
97
|
+
throw new exceptions_1.ComputeError(`Index ${index} is out of bounds for list of length ${len}`);
|
|
98
|
+
}
|
|
99
|
+
res[i] = val ?? null;
|
|
100
|
+
}
|
|
101
|
+
return res;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
gather_every(n, offset = 0) {
|
|
105
|
+
if (n <= 0) {
|
|
106
|
+
throw new exceptions_1.ComputeError("Step size n must be positive");
|
|
107
|
+
}
|
|
108
|
+
return this._deriveList((arr) => {
|
|
109
|
+
const len = arr.length;
|
|
110
|
+
const res = [];
|
|
111
|
+
for (let i = offset; i < len; i += n) {
|
|
112
|
+
res.push(arr[i]);
|
|
113
|
+
}
|
|
114
|
+
return res;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
get(index, null_on_oob = true) {
|
|
118
|
+
return this._deriveList((arr) => {
|
|
119
|
+
const val = arr.at(index);
|
|
120
|
+
if (val === undefined && !null_on_oob) {
|
|
121
|
+
throw new exceptions_1.ComputeError(`Index ${index} is out of bounds for list of length ${arr.length}`);
|
|
122
|
+
}
|
|
123
|
+
return val ?? null;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
join(separator, { ignoreNulls = false } = {}) {
|
|
127
|
+
return this._deriveList((arr) => {
|
|
128
|
+
const list = Array.from(arr);
|
|
129
|
+
const strList = [];
|
|
130
|
+
for (let i = 0; i < list.length; i++) {
|
|
131
|
+
const x = list[i];
|
|
132
|
+
if (x != null) {
|
|
133
|
+
strList.push(String(x));
|
|
134
|
+
}
|
|
135
|
+
else if (!ignoreNulls) {
|
|
136
|
+
strList.push("");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return strList.join(separator);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
last(null_on_oob = true) {
|
|
143
|
+
return this.get(-1, null_on_oob);
|
|
144
|
+
}
|
|
145
|
+
len() {
|
|
146
|
+
return this.lengths();
|
|
147
|
+
}
|
|
148
|
+
lengths() {
|
|
149
|
+
return this._deriveList((arr) => arr.length);
|
|
150
|
+
}
|
|
151
|
+
max() {
|
|
152
|
+
return this._deriveList((arr) => (0, utils_1.getListStats)(arr).max);
|
|
153
|
+
}
|
|
154
|
+
mean() {
|
|
155
|
+
return this._deriveList((arr) => {
|
|
156
|
+
const { sum, count } = (0, utils_1.getListStats)(arr);
|
|
157
|
+
return sum !== null && count > 0 ? sum / count : null;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
median() {
|
|
161
|
+
return this._deriveList((arr) => {
|
|
162
|
+
if (!(0, utils_1.isArrayOfType)(arr, "number", { allowNulls: true }))
|
|
163
|
+
return null;
|
|
164
|
+
const len = arr.length;
|
|
165
|
+
const nums = [];
|
|
166
|
+
for (let i = 0; i < len; i++) {
|
|
167
|
+
const val = arr[i];
|
|
168
|
+
if (val != null) {
|
|
169
|
+
nums.push(val);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const numsLen = nums.length;
|
|
173
|
+
if (numsLen === 0)
|
|
174
|
+
return null;
|
|
175
|
+
nums.sort((a, b) => a - b);
|
|
176
|
+
const mid = Math.floor(numsLen / 2);
|
|
177
|
+
return numsLen % 2 !== 0
|
|
178
|
+
? nums[mid]
|
|
179
|
+
: (nums[mid - 1] + nums[mid]) / 2;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
min() {
|
|
183
|
+
return this._deriveList((arr) => (0, utils_1.getListStats)(arr).min);
|
|
184
|
+
}
|
|
185
|
+
mode() {
|
|
186
|
+
return this._deriveList((arr) => {
|
|
187
|
+
const len = arr.length;
|
|
188
|
+
const counts = new Map();
|
|
189
|
+
let maxCount = 0;
|
|
190
|
+
for (let i = 0; i < len; i++) {
|
|
191
|
+
const val = arr[i];
|
|
192
|
+
if (val == null)
|
|
193
|
+
continue;
|
|
194
|
+
const c = (counts.get(val) ?? 0) + 1;
|
|
195
|
+
counts.set(val, c);
|
|
196
|
+
if (c > maxCount)
|
|
197
|
+
maxCount = c;
|
|
198
|
+
}
|
|
199
|
+
if (maxCount === 0)
|
|
200
|
+
return [];
|
|
201
|
+
const modes = [];
|
|
202
|
+
for (const [val, c] of counts.entries()) {
|
|
203
|
+
if (c === maxCount) {
|
|
204
|
+
modes.push(val);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return (0, utils_1.sortList)(modes);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
n_unique() {
|
|
211
|
+
return this._deriveList((arr) => {
|
|
212
|
+
return new Set(Array.from(arr)).size;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
reverse() {
|
|
216
|
+
return this._deriveList((arr) => {
|
|
217
|
+
return Array.from(arr).reverse();
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
slice(offset, length) {
|
|
221
|
+
return this._deriveList((arr) => {
|
|
222
|
+
const list = Array.from(arr);
|
|
223
|
+
const start = offset < 0 ? Math.max(0, list.length + offset) : offset;
|
|
224
|
+
const end = length !== undefined ? start + length : list.length;
|
|
225
|
+
return list.slice(start, end);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
sort(descending = false) {
|
|
229
|
+
return this._deriveList((arr) => (0, utils_1.sortList)(arr, descending));
|
|
230
|
+
}
|
|
231
|
+
sum() {
|
|
232
|
+
return this._deriveList((arr) => (0, utils_1.getListStats)(arr).sum);
|
|
233
|
+
}
|
|
234
|
+
unique() {
|
|
235
|
+
return this._deriveList((arr) => {
|
|
236
|
+
return Array.from(new Set(arr));
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
exports.ListExprNamespace = ListExprNamespace;
|
|
241
|
+
const ListExpr = (Base) => {
|
|
242
|
+
return class extends Base {
|
|
243
|
+
get list() {
|
|
244
|
+
return new ListExprNamespace(this);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
exports.ListExpr = ListExpr;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ExprConstructor } from "../types";
|
|
2
|
+
export declare const LogicalExpr: <TBase extends ExprConstructor>(Base: TBase) => {
|
|
3
|
+
new (...args: any[]): {
|
|
4
|
+
and(other: any): /*elided*/ any;
|
|
5
|
+
not(): /*elided*/ any;
|
|
6
|
+
or(other: any): /*elided*/ any;
|
|
7
|
+
xor(other: any): /*elided*/ any;
|
|
8
|
+
ops: import("../..").OpFn[];
|
|
9
|
+
colName?: string;
|
|
10
|
+
outputName?: string;
|
|
11
|
+
isLiteral?: boolean;
|
|
12
|
+
literalValue?: any;
|
|
13
|
+
aggFn?: import("../..").AggFn<any> | null;
|
|
14
|
+
groupingOpsIndex?: number;
|
|
15
|
+
partitionOpsIndex?: number;
|
|
16
|
+
partitionBy?: (string | import("../..").IExpr)[] | null;
|
|
17
|
+
windowOp?: {
|
|
18
|
+
type: string;
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
} | null;
|
|
21
|
+
isWindow?: boolean;
|
|
22
|
+
alias(name: string): /*elided*/ any;
|
|
23
|
+
cast(dataType: any): /*elided*/ any;
|
|
24
|
+
_resolve(val: any, columns: import("../..").ColumnDict, height: number): import("../..").ColumnData | any;
|
|
25
|
+
evaluate(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
|
|
26
|
+
evaluatePreGrouping(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
|
|
27
|
+
evaluatePostGrouping(aggregatedArray: any[], columns: import("../..").ColumnDict): import("../..").ColumnData;
|
|
28
|
+
evaluatePrePartition(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
|
|
29
|
+
evaluatePostPartition(aggregatedArray: any[], columns: import("../..").ColumnDict): import("../..").ColumnData;
|
|
30
|
+
evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
|
|
31
|
+
debug(label?: string): /*elided*/ any;
|
|
32
|
+
};
|
|
33
|
+
} & TBase;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogicalExpr = void 0;
|
|
4
|
+
const ExprBase_1 = require("../ExprBase");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const LogicalExpr = (Base) => {
|
|
7
|
+
return class extends Base {
|
|
8
|
+
and(other) {
|
|
9
|
+
return (0, ExprBase_1.derive)(this, (vArray, columns) => {
|
|
10
|
+
const height = vArray.length;
|
|
11
|
+
const otherVal = this._resolve(other, columns, height);
|
|
12
|
+
const isOtherArray = (0, utils_1.isArrayOrTypedArray)(otherVal);
|
|
13
|
+
const result = new Array(height);
|
|
14
|
+
for (let i = 0; i < height; i++) {
|
|
15
|
+
const v = vArray[i];
|
|
16
|
+
const w = isOtherArray ? otherVal[i] : otherVal;
|
|
17
|
+
if (v === false || w === false)
|
|
18
|
+
result[i] = false;
|
|
19
|
+
else if (v == null || w == null)
|
|
20
|
+
result[i] = null;
|
|
21
|
+
else
|
|
22
|
+
result[i] = true;
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
not() {
|
|
28
|
+
return (0, ExprBase_1.derive)(this, (0, ExprBase_1.kleeneUnary)((v) => !v));
|
|
29
|
+
}
|
|
30
|
+
or(other) {
|
|
31
|
+
return (0, ExprBase_1.derive)(this, (vArray, columns) => {
|
|
32
|
+
const height = vArray.length;
|
|
33
|
+
const otherVal = this._resolve(other, columns, height);
|
|
34
|
+
const isOtherArray = (0, utils_1.isArrayOrTypedArray)(otherVal);
|
|
35
|
+
const result = new Array(height);
|
|
36
|
+
for (let i = 0; i < height; i++) {
|
|
37
|
+
const v = vArray[i];
|
|
38
|
+
const w = isOtherArray ? otherVal[i] : otherVal;
|
|
39
|
+
if (v === true || w === true)
|
|
40
|
+
result[i] = true;
|
|
41
|
+
else if (v == null || w == null)
|
|
42
|
+
result[i] = null;
|
|
43
|
+
else
|
|
44
|
+
result[i] = false;
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
xor(other) {
|
|
50
|
+
return (0, ExprBase_1.derive)(this, (0, ExprBase_1.kleeneBinary)(this, other, (v, w) => !!v !== !!w));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
exports.LogicalExpr = LogicalExpr;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ExprConstructor } from "../types";
|
|
2
|
+
export declare const ManipulationExpr: <TBase extends ExprConstructor>(Base: TBase) => {
|
|
3
|
+
new (...args: any[]): {
|
|
4
|
+
fill_null(value: any): /*elided*/ any;
|
|
5
|
+
reverse(): /*elided*/ any;
|
|
6
|
+
ops: import("../..").OpFn[];
|
|
7
|
+
colName?: string;
|
|
8
|
+
outputName?: string;
|
|
9
|
+
isLiteral?: boolean;
|
|
10
|
+
literalValue?: any;
|
|
11
|
+
aggFn?: import("../..").AggFn<any> | null;
|
|
12
|
+
groupingOpsIndex?: number;
|
|
13
|
+
partitionOpsIndex?: number;
|
|
14
|
+
partitionBy?: (string | import("../..").IExpr)[] | null;
|
|
15
|
+
windowOp?: {
|
|
16
|
+
type: string;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
} | null;
|
|
19
|
+
isWindow?: boolean;
|
|
20
|
+
alias(name: string): /*elided*/ any;
|
|
21
|
+
cast(dataType: any): /*elided*/ any;
|
|
22
|
+
_resolve(val: any, columns: import("../..").ColumnDict, height: number): import("../..").ColumnData | any;
|
|
23
|
+
evaluate(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
|
|
24
|
+
evaluatePreGrouping(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
|
|
25
|
+
evaluatePostGrouping(aggregatedArray: any[], columns: import("../..").ColumnDict): import("../..").ColumnData;
|
|
26
|
+
evaluatePrePartition(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
|
|
27
|
+
evaluatePostPartition(aggregatedArray: any[], columns: import("../..").ColumnDict): import("../..").ColumnData;
|
|
28
|
+
evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
|
|
29
|
+
debug(label?: string): /*elided*/ any;
|
|
30
|
+
};
|
|
31
|
+
} & TBase;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManipulationExpr = void 0;
|
|
4
|
+
const ExprBase_1 = require("../ExprBase");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const ManipulationExpr = (Base) => {
|
|
7
|
+
return class extends Base {
|
|
8
|
+
fill_null(value) {
|
|
9
|
+
return (0, ExprBase_1.derive)(this, (vArray, columns) => {
|
|
10
|
+
const height = vArray.length;
|
|
11
|
+
const resolved = this._resolve(value, columns, height);
|
|
12
|
+
const result = new Array(height);
|
|
13
|
+
if ((0, utils_1.isArrayOrTypedArray)(resolved)) {
|
|
14
|
+
for (let i = 0; i < height; i++) {
|
|
15
|
+
const v = vArray[i];
|
|
16
|
+
result[i] = v == null ? resolved[i] : v;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
for (let i = 0; i < height; i++) {
|
|
21
|
+
const v = vArray[i];
|
|
22
|
+
result[i] = v == null ? resolved : v;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
reverse() {
|
|
29
|
+
return (0, ExprBase_1.derive)(this, (vArray) => {
|
|
30
|
+
return vArray.slice().reverse();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.ManipulationExpr = ManipulationExpr;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { IExpr } from "../../types";
|
|
2
|
+
import type { ExprConstructor } from "../types";
|
|
3
|
+
import { StripCharsOptions } from "../../utils";
|
|
4
|
+
export declare class StringExprNamespace {
|
|
5
|
+
expr: any;
|
|
6
|
+
constructor(expr: any);
|
|
7
|
+
_deriveString(fn: (v: string) => any): any;
|
|
8
|
+
concat(other: string | IExpr): any;
|
|
9
|
+
contains(pattern: string | RegExp): any;
|
|
10
|
+
count_matches(pattern: string | RegExp): any;
|
|
11
|
+
decode_uri_component(): any;
|
|
12
|
+
encode_uri_component(): any;
|
|
13
|
+
ends_with(suffix: string): any;
|
|
14
|
+
explode(): any;
|
|
15
|
+
extract(pattern: RegExp, group?: number): any;
|
|
16
|
+
len(): any;
|
|
17
|
+
len_bytes(): any;
|
|
18
|
+
len_chars(): any;
|
|
19
|
+
lower(): any;
|
|
20
|
+
lpad(width: number, fill?: string): any;
|
|
21
|
+
pad_end(width: number, fill?: string): any;
|
|
22
|
+
pad_start(width: number, fill?: string): any;
|
|
23
|
+
replace(pattern: string | RegExp, replacement: string): any;
|
|
24
|
+
replace_all(pattern: string | RegExp, replacement: string): any;
|
|
25
|
+
reverse(): any;
|
|
26
|
+
rpad(width: number, fill?: string): any;
|
|
27
|
+
slice(offset: number, length?: number): any;
|
|
28
|
+
slice_str(offset: number, length?: number): any;
|
|
29
|
+
split(delimiter: string): any;
|
|
30
|
+
starts_with(prefix: string): any;
|
|
31
|
+
strip_chars(characters?: string | RegExp, options?: StripCharsOptions): any;
|
|
32
|
+
strip_chars_end(characters?: string | RegExp, options?: StripCharsOptions): any;
|
|
33
|
+
strip_chars_start(characters?: string | RegExp, options?: StripCharsOptions): any;
|
|
34
|
+
strip_prefix(prefix: string): any;
|
|
35
|
+
strip_suffix(suffix: string): any;
|
|
36
|
+
strptime(format: string, strict?: boolean): any;
|
|
37
|
+
to_date(): any;
|
|
38
|
+
to_datetime(): any;
|
|
39
|
+
to_decimal(precision?: number, scale?: number): any;
|
|
40
|
+
to_integer(): any;
|
|
41
|
+
to_lowercase(): any;
|
|
42
|
+
to_time(): any;
|
|
43
|
+
to_titlecase(): any;
|
|
44
|
+
to_uppercase(): any;
|
|
45
|
+
trim(): any;
|
|
46
|
+
trim_end(): any;
|
|
47
|
+
trim_start(): any;
|
|
48
|
+
upper(): any;
|
|
49
|
+
zfill(width: number): any;
|
|
50
|
+
}
|
|
51
|
+
export declare const StringExpr: <TBase extends ExprConstructor>(Base: TBase) => {
|
|
52
|
+
new (...args: any[]): {
|
|
53
|
+
get str(): StringExprNamespace;
|
|
54
|
+
ops: import("../../types").OpFn[];
|
|
55
|
+
colName?: string;
|
|
56
|
+
outputName?: string;
|
|
57
|
+
isLiteral?: boolean;
|
|
58
|
+
literalValue?: any;
|
|
59
|
+
aggFn?: import("../../types").AggFn<any> | null;
|
|
60
|
+
groupingOpsIndex?: number;
|
|
61
|
+
partitionOpsIndex?: number;
|
|
62
|
+
partitionBy?: (string | IExpr)[] | null;
|
|
63
|
+
windowOp?: {
|
|
64
|
+
type: string;
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
} | null;
|
|
67
|
+
isWindow?: boolean;
|
|
68
|
+
alias(name: string): /*elided*/ any;
|
|
69
|
+
cast(dataType: any): /*elided*/ any;
|
|
70
|
+
_resolve(val: any, columns: import("../../types").ColumnDict, height: number): import("../../types").ColumnData | any;
|
|
71
|
+
evaluate(columns: import("../../types").ColumnDict, height: number): import("../../types").ColumnData;
|
|
72
|
+
evaluatePreGrouping(columns: import("../../types").ColumnDict, height: number): import("../../types").ColumnData;
|
|
73
|
+
evaluatePostGrouping(aggregatedArray: any[], columns: import("../../types").ColumnDict): import("../../types").ColumnData;
|
|
74
|
+
evaluatePrePartition(columns: import("../../types").ColumnDict, height: number): import("../../types").ColumnData;
|
|
75
|
+
evaluatePostPartition(aggregatedArray: any[], columns: import("../../types").ColumnDict): import("../../types").ColumnData;
|
|
76
|
+
evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
|
|
77
|
+
debug(label?: string): /*elided*/ any;
|
|
78
|
+
};
|
|
79
|
+
} & TBase;
|