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.
- package/README.md +83 -34
- package/dist/api.d.ts +16 -8
- package/dist/api.js +11 -3
- package/dist/columnExpressions/ColumnExpr.d.ts +26 -364
- package/dist/columnExpressions/ColumnExpr.js +199 -3
- package/dist/columnExpressions/ExprBase.d.ts +8 -11
- package/dist/columnExpressions/ExprBase.js +20 -61
- package/dist/columnExpressions/constants.d.ts +2 -0
- package/dist/columnExpressions/constants.js +3 -1
- package/dist/columnExpressions/functions/coalesce.js +8 -4
- package/dist/columnExpressions/functions/element.d.ts +5 -0
- package/dist/columnExpressions/functions/element.js +11 -0
- package/dist/columnExpressions/functions/implode.d.ts +3 -0
- package/dist/columnExpressions/functions/implode.js +7 -0
- package/dist/columnExpressions/functions/lit.d.ts +3 -1
- package/dist/columnExpressions/functions/lit.js +8 -13
- package/dist/columnExpressions/functions/repeat.d.ts +47 -0
- package/dist/columnExpressions/functions/repeat.js +131 -0
- package/dist/columnExpressions/functions/seq_range.d.ts +31 -0
- package/dist/columnExpressions/functions/seq_range.js +91 -0
- package/dist/columnExpressions/functions/when.js +8 -4
- package/dist/columnExpressions/index.d.ts +5 -2
- package/dist/columnExpressions/index.js +5 -48
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +25 -50
- package/dist/columnExpressions/mixins/AggregationExpr.js +69 -165
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +41 -66
- package/dist/columnExpressions/mixins/ArithmeticExpr.js +126 -138
- package/dist/columnExpressions/mixins/BooleanExpr.d.ts +40 -0
- package/dist/columnExpressions/mixins/BooleanExpr.js +67 -0
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +31 -60
- package/dist/columnExpressions/mixins/ComparisonExpr.js +231 -370
- package/dist/columnExpressions/mixins/ListExpr.d.ts +15 -39
- package/dist/columnExpressions/mixins/ListExpr.js +124 -148
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +7 -33
- package/dist/columnExpressions/mixins/LogicalExpr.js +48 -49
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +6 -31
- package/dist/columnExpressions/mixins/ManipulationExpr.js +61 -25
- package/dist/columnExpressions/mixins/NumericExpr.d.ts +92 -0
- package/dist/columnExpressions/mixins/NumericExpr.js +259 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +5 -30
- package/dist/columnExpressions/mixins/StringExpr.js +37 -49
- package/dist/columnExpressions/mixins/StructExpr.d.ts +16 -0
- package/dist/columnExpressions/mixins/StructExpr.js +139 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +4 -30
- package/dist/columnExpressions/mixins/TemporalExpr.js +28 -29
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +27 -49
- package/dist/columnExpressions/mixins/WindowExpr.js +144 -274
- package/dist/columnExpressions/utils.d.ts +4 -0
- package/dist/columnExpressions/utils.js +45 -0
- package/dist/dataframe/constants.d.ts +3 -0
- package/dist/dataframe/constants.js +4 -1
- package/dist/dataframe/dataframe.d.ts +27 -10
- package/dist/dataframe/dataframe.js +461 -220
- package/dist/dataframe/grouped/grouped.d.ts +2 -3
- package/dist/dataframe/grouped/grouped.js +17 -16
- package/dist/dataframe/types.d.ts +65 -1
- package/dist/dataframe/utils.d.ts +11 -3
- package/dist/dataframe/utils.js +101 -9
- package/dist/datatypes/DataType.d.ts +2 -1
- package/dist/datatypes/DataType.js +29 -0
- package/dist/datatypes/index.d.ts +2 -2
- package/dist/datatypes/types.d.ts +37 -36
- package/dist/datatypes/types.js +15 -11
- package/dist/exceptions/index.d.ts +2 -0
- package/dist/exceptions/index.js +4 -1
- package/dist/exceptions/utils.d.ts +1 -0
- package/dist/exceptions/utils.js +19 -0
- package/dist/functions/concat.d.ts +1 -2
- package/dist/functions/concat.js +24 -12
- package/dist/functions/index.d.ts +3 -1
- package/dist/functions/index.js +7 -15
- package/dist/functions/read_csv.d.ts +8 -0
- package/dist/functions/read_csv.js +53 -0
- package/dist/functions/read_json.d.ts +10 -0
- package/dist/functions/read_json.js +21 -0
- package/dist/functions/transpose.d.ts +7 -0
- package/dist/functions/transpose.js +84 -0
- package/dist/index.js +6 -1
- package/dist/types.d.ts +31 -5
- package/dist/utils/csv.d.ts +77 -0
- package/dist/utils/csv.js +313 -0
- package/dist/utils/date.js +5 -6
- package/dist/utils/guards.d.ts +0 -2
- package/dist/utils/guards.js +0 -31
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/json.d.ts +120 -2
- package/dist/utils/json.js +204 -20
- package/dist/utils/list.d.ts +173 -1
- package/dist/utils/list.js +255 -22
- package/dist/utils/number.d.ts +61 -28
- package/dist/utils/number.js +248 -70
- package/dist/utils/string.d.ts +5 -0
- package/dist/utils/string.js +89 -0
- package/package.json +5 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExprBase } from "../ExprBase";
|
|
2
|
+
import { StepSliceListOptions } from "../../utils";
|
|
3
|
+
import type { UniqueListStatsOptions, JoinListOptions, ExplodeOptions, IExpr } from "../../types";
|
|
2
4
|
export declare class ListExprNamespace {
|
|
3
5
|
expr: any;
|
|
4
6
|
constructor(expr: any);
|
|
@@ -6,17 +8,16 @@ export declare class ListExprNamespace {
|
|
|
6
8
|
all(): any;
|
|
7
9
|
any(): any;
|
|
8
10
|
contains(item: any): any;
|
|
9
|
-
contains_all(items: any
|
|
10
|
-
contains_any(items: any
|
|
11
|
+
contains_all(items: ArrayLike<any>): any;
|
|
12
|
+
contains_any(items: ArrayLike<any>): any;
|
|
11
13
|
count_matches(item: any): any;
|
|
12
14
|
drop_nulls(): any;
|
|
15
|
+
explode({ empty_as_null, keep_nulls }?: ExplodeOptions): any;
|
|
13
16
|
first(null_on_oob?: boolean): any;
|
|
14
|
-
gather(indices: number | number
|
|
15
|
-
gather_every(
|
|
17
|
+
gather(indices: number | ArrayLike<number>, null_on_oob?: boolean): any;
|
|
18
|
+
gather_every(options?: StepSliceListOptions): any;
|
|
16
19
|
get(index: number, null_on_oob?: boolean): any;
|
|
17
|
-
join(separator
|
|
18
|
-
ignoreNulls?: boolean;
|
|
19
|
-
}): any;
|
|
20
|
+
join(separator?: string, options?: JoinListOptions): any;
|
|
20
21
|
last(null_on_oob?: boolean): any;
|
|
21
22
|
len(): any;
|
|
22
23
|
lengths(): any;
|
|
@@ -25,39 +26,14 @@ export declare class ListExprNamespace {
|
|
|
25
26
|
median(): any;
|
|
26
27
|
min(): any;
|
|
27
28
|
mode(): any;
|
|
28
|
-
n_unique(): any;
|
|
29
|
+
n_unique(options?: UniqueListStatsOptions): any;
|
|
29
30
|
reverse(): any;
|
|
30
31
|
slice(offset: number, length?: number): any;
|
|
31
32
|
sort(descending?: boolean): any;
|
|
32
33
|
sum(): any;
|
|
33
|
-
unique(): any;
|
|
34
|
+
unique(options?: UniqueListStatsOptions): any;
|
|
35
|
+
eval(expr: IExpr): any;
|
|
36
|
+
}
|
|
37
|
+
export declare class ListExpr extends ExprBase {
|
|
38
|
+
get list(): ListExprNamespace;
|
|
34
39
|
}
|
|
35
|
-
export declare const ListExpr: <TBase extends ExprConstructor>(Base: TBase) => {
|
|
36
|
-
new (...args: any[]): {
|
|
37
|
-
get list(): ListExprNamespace;
|
|
38
|
-
ops: import("../..").OpFn[];
|
|
39
|
-
colName?: string;
|
|
40
|
-
outputName?: string;
|
|
41
|
-
isLiteral?: boolean;
|
|
42
|
-
literalValue?: any;
|
|
43
|
-
aggFn?: import("../..").AggFn<any> | null;
|
|
44
|
-
groupingOpsIndex?: number;
|
|
45
|
-
partitionOpsIndex?: number;
|
|
46
|
-
partitionBy?: (string | import("../..").IExpr)[] | null;
|
|
47
|
-
windowOp?: {
|
|
48
|
-
type: string;
|
|
49
|
-
[key: string]: any;
|
|
50
|
-
} | null;
|
|
51
|
-
isWindow?: boolean;
|
|
52
|
-
alias(name: string): /*elided*/ any;
|
|
53
|
-
cast(dataType: any): /*elided*/ any;
|
|
54
|
-
_resolve(val: any, columns: import("../..").ColumnDict, height: number): import("../..").ColumnData | any;
|
|
55
|
-
evaluate(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
|
|
56
|
-
evaluatePreGrouping(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
|
|
57
|
-
evaluatePostGrouping(aggregatedArray: any[], columns: import("../..").ColumnDict): import("../..").ColumnData;
|
|
58
|
-
evaluatePrePartition(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
|
|
59
|
-
evaluatePostPartition(aggregatedArray: any[], columns: import("../..").ColumnDict): import("../..").ColumnData;
|
|
60
|
-
evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
|
|
61
|
-
debug(label?: string): /*elided*/ any;
|
|
62
|
-
};
|
|
63
|
-
} & TBase;
|
|
@@ -2,69 +2,41 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ListExpr = exports.ListExprNamespace = void 0;
|
|
4
4
|
const ExprBase_1 = require("../ExprBase");
|
|
5
|
-
const utils_1 = require("
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const utils_2 = require("../../utils");
|
|
6
7
|
const exceptions_1 = require("../../exceptions");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
7
9
|
class ListExprNamespace {
|
|
8
10
|
expr;
|
|
9
11
|
constructor(expr) {
|
|
10
12
|
this.expr = expr;
|
|
11
13
|
}
|
|
12
14
|
_deriveList(fn) {
|
|
13
|
-
return (0, ExprBase_1.derive)(this.expr, (0,
|
|
14
|
-
return (0,
|
|
15
|
+
return (0, ExprBase_1.derive)(this.expr, (0, utils_1.kleeneUnary)((v) => {
|
|
16
|
+
return (0, utils_2.isArrayOrTypedArray)(v) ? fn(v) : null;
|
|
15
17
|
}));
|
|
16
18
|
}
|
|
17
19
|
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
|
-
});
|
|
20
|
+
return this._deriveList((arr) => (0, utils_2.isArrayOfType)(arr, (x) => !!x, { mode: "every" }));
|
|
26
21
|
}
|
|
27
22
|
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
|
-
});
|
|
23
|
+
return this._deriveList((arr) => (0, utils_2.isArrayOfType)(arr, (x) => !!x, { mode: "some" }));
|
|
36
24
|
}
|
|
37
25
|
contains(item) {
|
|
38
|
-
return this._deriveList((arr) =>
|
|
39
|
-
return Array.from(arr).includes(item);
|
|
40
|
-
});
|
|
26
|
+
return this._deriveList((arr) => arr.includes(item));
|
|
41
27
|
}
|
|
42
28
|
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
|
-
});
|
|
29
|
+
return this._deriveList((arr) => (0, utils_2.isArrayOfType)(items, (x) => arr.includes(x), { mode: "every" }));
|
|
51
30
|
}
|
|
52
31
|
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
|
-
});
|
|
32
|
+
return this._deriveList((arr) => (0, utils_2.isArrayOfType)(items, (x) => arr.includes(x), { mode: "some" }));
|
|
61
33
|
}
|
|
62
34
|
count_matches(item) {
|
|
63
35
|
return this._deriveList((arr) => {
|
|
64
|
-
const list = Array.from(arr);
|
|
65
36
|
let count = 0;
|
|
66
|
-
|
|
67
|
-
|
|
37
|
+
const len = arr.length;
|
|
38
|
+
for (let i = 0; i < len; i++) {
|
|
39
|
+
if (arr[i] === item) {
|
|
68
40
|
count++;
|
|
69
41
|
}
|
|
70
42
|
}
|
|
@@ -73,24 +45,77 @@ class ListExprNamespace {
|
|
|
73
45
|
}
|
|
74
46
|
drop_nulls() {
|
|
75
47
|
return this._deriveList((arr) => {
|
|
76
|
-
const
|
|
48
|
+
const len = arr.length;
|
|
77
49
|
const result = [];
|
|
78
|
-
for (let i = 0; i <
|
|
79
|
-
if (
|
|
80
|
-
result.push(
|
|
50
|
+
for (let i = 0; i < len; i++) {
|
|
51
|
+
if (arr[i] != null)
|
|
52
|
+
result.push(arr[i]);
|
|
81
53
|
}
|
|
82
54
|
return result;
|
|
83
55
|
});
|
|
84
56
|
}
|
|
57
|
+
explode({ empty_as_null = true, keep_nulls = true } = {}) {
|
|
58
|
+
return (0, ExprBase_1.derive)(this.expr, (vArray) => {
|
|
59
|
+
const height = vArray.length;
|
|
60
|
+
let newHeight = 0;
|
|
61
|
+
for (let i = 0; i < height; i++) {
|
|
62
|
+
const val = vArray[i];
|
|
63
|
+
if ((0, utils_2.isArrayOrTypedArray)(val)) {
|
|
64
|
+
newHeight += val.length || (empty_as_null ? 1 : 0);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (val != null) {
|
|
68
|
+
newHeight += 1;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (keep_nulls) {
|
|
72
|
+
newHeight += 1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const res = new Array(newHeight);
|
|
76
|
+
const rowMap = new Int32Array(newHeight);
|
|
77
|
+
let idx = 0;
|
|
78
|
+
for (let i = 0; i < height; i++) {
|
|
79
|
+
const val = vArray[i];
|
|
80
|
+
if ((0, utils_2.isArrayOrTypedArray)(val)) {
|
|
81
|
+
const len = val.length;
|
|
82
|
+
if (len > 0) {
|
|
83
|
+
for (let j = 0; j < len; j++) {
|
|
84
|
+
rowMap[idx] = i;
|
|
85
|
+
res[idx++] = val[j];
|
|
86
|
+
}
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (empty_as_null) {
|
|
90
|
+
rowMap[idx] = i;
|
|
91
|
+
res[idx++] = null;
|
|
92
|
+
}
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (val != null) {
|
|
96
|
+
rowMap[idx] = i;
|
|
97
|
+
res[idx++] = val;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (keep_nulls) {
|
|
101
|
+
rowMap[idx] = i;
|
|
102
|
+
res[idx++] = null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
res.rowMap = rowMap;
|
|
106
|
+
return res;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
85
109
|
first(null_on_oob = true) {
|
|
86
110
|
return this.get(0, null_on_oob);
|
|
87
111
|
}
|
|
88
112
|
gather(indices, null_on_oob = true) {
|
|
89
|
-
const idxs = Array.isArray(indices) ? indices : [indices];
|
|
90
113
|
return this._deriveList((arr) => {
|
|
91
114
|
const len = arr.length;
|
|
92
|
-
const
|
|
93
|
-
|
|
115
|
+
const idxs = (0, utils_2.isArrayOrTypedArray)(indices) ? indices : [indices];
|
|
116
|
+
const numIndices = idxs.length;
|
|
117
|
+
const res = new Array(numIndices);
|
|
118
|
+
for (let i = 0; i < numIndices; i++) {
|
|
94
119
|
const index = idxs[i];
|
|
95
120
|
const val = arr.at(index);
|
|
96
121
|
if (val === undefined && !null_on_oob) {
|
|
@@ -101,18 +126,8 @@ class ListExprNamespace {
|
|
|
101
126
|
return res;
|
|
102
127
|
});
|
|
103
128
|
}
|
|
104
|
-
gather_every(
|
|
105
|
-
|
|
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
|
-
});
|
|
129
|
+
gather_every(options = {}) {
|
|
130
|
+
return this._deriveList((arr) => (0, utils_2.stepSliceList)(arr, options));
|
|
116
131
|
}
|
|
117
132
|
get(index, null_on_oob = true) {
|
|
118
133
|
return this._deriveList((arr) => {
|
|
@@ -123,21 +138,8 @@ class ListExprNamespace {
|
|
|
123
138
|
return val ?? null;
|
|
124
139
|
});
|
|
125
140
|
}
|
|
126
|
-
join(separator
|
|
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
|
+
join(separator = ",", options = {}) {
|
|
142
|
+
return this._deriveList((arr) => (0, utils_2.joinList)(arr, separator, options));
|
|
141
143
|
}
|
|
142
144
|
last(null_on_oob = true) {
|
|
143
145
|
return this.get(-1, null_on_oob);
|
|
@@ -149,100 +151,74 @@ class ListExprNamespace {
|
|
|
149
151
|
return this._deriveList((arr) => arr.length);
|
|
150
152
|
}
|
|
151
153
|
max() {
|
|
152
|
-
return this._deriveList((arr) => (0,
|
|
154
|
+
return this._deriveList((arr) => (0, utils_2.getListStats)(arr).max);
|
|
153
155
|
}
|
|
154
156
|
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
|
-
});
|
|
157
|
+
return this._deriveList((arr) => (0, utils_2.getListStats)(arr).mean);
|
|
159
158
|
}
|
|
160
159
|
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
|
-
});
|
|
160
|
+
return this._deriveList((arr) => (0, utils_2.computeMedian)(arr));
|
|
181
161
|
}
|
|
182
162
|
min() {
|
|
183
|
-
return this._deriveList((arr) => (0,
|
|
163
|
+
return this._deriveList((arr) => (0, utils_2.getListStats)(arr).min);
|
|
184
164
|
}
|
|
185
165
|
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
|
-
});
|
|
166
|
+
return this._deriveList((arr) => (0, utils_2.computeMode)(arr));
|
|
209
167
|
}
|
|
210
|
-
n_unique() {
|
|
211
|
-
return this._deriveList((arr) =>
|
|
212
|
-
return new Set(Array.from(arr)).size;
|
|
213
|
-
});
|
|
168
|
+
n_unique(options = {}) {
|
|
169
|
+
return this._deriveList((arr) => (0, utils_2.getUniqueListStats)(arr, options).count);
|
|
214
170
|
}
|
|
215
171
|
reverse() {
|
|
216
|
-
return this._deriveList((arr) =>
|
|
217
|
-
return Array.from(arr).reverse();
|
|
218
|
-
});
|
|
172
|
+
return this._deriveList((arr) => arr.slice().reverse());
|
|
219
173
|
}
|
|
220
174
|
slice(offset, length) {
|
|
221
175
|
return this._deriveList((arr) => {
|
|
222
|
-
const
|
|
223
|
-
const start = offset < 0 ? Math.max(0,
|
|
224
|
-
const end = length !== undefined ? start + length :
|
|
225
|
-
return
|
|
176
|
+
const len = arr.length;
|
|
177
|
+
const start = offset < 0 ? Math.max(0, len + offset) : offset;
|
|
178
|
+
const end = length !== undefined ? start + length : len;
|
|
179
|
+
return arr.slice(start, end);
|
|
226
180
|
});
|
|
227
181
|
}
|
|
228
182
|
sort(descending = false) {
|
|
229
|
-
return this._deriveList((arr) => (0,
|
|
183
|
+
return this._deriveList((arr) => (0, utils_2.sortList)(arr, descending));
|
|
230
184
|
}
|
|
231
185
|
sum() {
|
|
232
|
-
return this._deriveList((arr) => (0,
|
|
233
|
-
}
|
|
234
|
-
unique() {
|
|
235
|
-
return this._deriveList((arr) =>
|
|
236
|
-
|
|
186
|
+
return this._deriveList((arr) => (0, utils_2.getListStats)(arr).sum);
|
|
187
|
+
}
|
|
188
|
+
unique(options = {}) {
|
|
189
|
+
return this._deriveList((arr) => (0, utils_2.getUniqueListStats)(arr, options).values);
|
|
190
|
+
}
|
|
191
|
+
eval(expr) {
|
|
192
|
+
return (0, ExprBase_1.derive)(this.expr, (vArray, columns) => {
|
|
193
|
+
const height = vArray.length;
|
|
194
|
+
const result = new Array(height);
|
|
195
|
+
for (let i = 0; i < height; i++) {
|
|
196
|
+
const val = vArray[i];
|
|
197
|
+
if (!(0, utils_2.isArrayOrTypedArray)(val)) {
|
|
198
|
+
result[i] = null;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const subHeight = val.length;
|
|
202
|
+
const subColumns = { ...columns, [constants_1.ELEMENT_MARKER]: val };
|
|
203
|
+
const isGlobalAgg = expr.aggFn != null && (expr.partitionBy == null || expr.partitionBy.length === 0);
|
|
204
|
+
if (isGlobalAgg) {
|
|
205
|
+
const preOpsIdx = expr.groupingOpsIndex !== undefined ? expr.groupingOpsIndex : expr.ops.length;
|
|
206
|
+
const preVal = expr.evaluatePre(preOpsIdx, subColumns, subHeight);
|
|
207
|
+
const aggVal = expr.aggFn(Array.from(preVal));
|
|
208
|
+
result[i] = expr.evaluatePost(preOpsIdx, [aggVal], subColumns);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
result[i] = (0, utils_1.evaluateExpression)(expr, subColumns, subHeight);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return result;
|
|
237
215
|
});
|
|
238
216
|
}
|
|
239
217
|
}
|
|
240
218
|
exports.ListExprNamespace = ListExprNamespace;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
};
|
|
247
|
-
};
|
|
219
|
+
class ListExpr extends ExprBase_1.ExprBase {
|
|
220
|
+
get list() {
|
|
221
|
+
return new ListExprNamespace(this);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
248
224
|
exports.ListExpr = ListExpr;
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
1
|
+
import { ExprBase } from "../ExprBase";
|
|
2
|
+
export declare class LogicalExpr extends ExprBase {
|
|
3
|
+
and(other: any): this;
|
|
4
|
+
not(): this;
|
|
5
|
+
or(other: any): this;
|
|
6
|
+
xor(other: any): this;
|
|
7
|
+
}
|
|
@@ -2,53 +2,52 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LogicalExpr = void 0;
|
|
4
4
|
const ExprBase_1 = require("../ExprBase");
|
|
5
|
-
const utils_1 = require("
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const utils_2 = require("../../utils");
|
|
7
|
+
class LogicalExpr extends ExprBase_1.ExprBase {
|
|
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_2.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, utils_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_2.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, utils_1.kleeneBinary)(this, other, (v, w) => !!v !== !!w));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
54
53
|
exports.LogicalExpr = LogicalExpr;
|
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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;
|
|
1
|
+
import { ExprBase } from "../ExprBase";
|
|
2
|
+
import type { FillNullOptions } from "../../types";
|
|
3
|
+
export declare class ManipulationExpr extends ExprBase {
|
|
4
|
+
fill_null({ value, strategy, limit }?: FillNullOptions): this;
|
|
5
|
+
reverse(): this;
|
|
6
|
+
}
|