@ohos-ports/nodejs-polars 0.23.4-beta.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 +19 -0
- package/README.md +217 -0
- package/bin/cfg.d.ts +156 -0
- package/bin/cfg.js +52 -0
- package/bin/dataframe.d.ts +2135 -0
- package/bin/dataframe.js +783 -0
- package/bin/datatypes/conversion.d.ts +2 -0
- package/bin/datatypes/conversion.js +2 -0
- package/bin/datatypes/datatype.d.ts +285 -0
- package/bin/datatypes/datatype.js +430 -0
- package/bin/datatypes/field.d.ts +26 -0
- package/bin/datatypes/field.js +36 -0
- package/bin/datatypes/index.d.ts +43 -0
- package/bin/datatypes/index.js +120 -0
- package/bin/error.d.ts +7 -0
- package/bin/error.js +17 -0
- package/bin/functions.d.ts +26 -0
- package/bin/functions.js +208 -0
- package/bin/groupby.d.ts +212 -0
- package/bin/groupby.js +156 -0
- package/bin/html.d.ts +4 -0
- package/bin/html.js +18 -0
- package/bin/index.d.ts +256 -0
- package/bin/index.js +267 -0
- package/bin/internals/construction.d.ts +7 -0
- package/bin/internals/construction.js +256 -0
- package/bin/internals/polars_internal.d.ts +2 -0
- package/bin/internals/polars_internal.js +7 -0
- package/bin/io.d.ts +433 -0
- package/bin/io.js +344 -0
- package/bin/lazy/dataframe.d.ts +785 -0
- package/bin/lazy/dataframe.js +427 -0
- package/bin/lazy/expr/datetime.d.ts +8 -0
- package/bin/lazy/expr/datetime.js +27 -0
- package/bin/lazy/expr/index.d.ts +1152 -0
- package/bin/lazy/expr/index.js +632 -0
- package/bin/lazy/expr/list.d.ts +8 -0
- package/bin/lazy/expr/list.js +115 -0
- package/bin/lazy/expr/string.d.ts +534 -0
- package/bin/lazy/expr/string.js +131 -0
- package/bin/lazy/expr/struct.d.ts +126 -0
- package/bin/lazy/expr/struct.js +26 -0
- package/bin/lazy/functions.d.ts +612 -0
- package/bin/lazy/functions.js +687 -0
- package/bin/lazy/groupby.d.ts +29 -0
- package/bin/lazy/groupby.js +30 -0
- package/bin/lazy/index.d.ts +4 -0
- package/bin/lazy/index.js +20 -0
- package/bin/lazy/whenthen.d.ts +67 -0
- package/bin/lazy/whenthen.js +81 -0
- package/bin/native-polars.d.ts +2 -0
- package/bin/native-polars.js +267 -0
- package/bin/series/datetime.d.ts +8 -0
- package/bin/series/datetime.js +34 -0
- package/bin/series/index.d.ts +1135 -0
- package/bin/series/index.js +700 -0
- package/bin/series/list.d.ts +8 -0
- package/bin/series/list.js +87 -0
- package/bin/series/string.d.ts +300 -0
- package/bin/series/string.js +125 -0
- package/bin/series/struct.d.ts +36 -0
- package/bin/series/struct.js +35 -0
- package/bin/shared_traits.d.ts +1458 -0
- package/bin/shared_traits.js +2 -0
- package/bin/sql.d.ts +244 -0
- package/bin/sql.js +63 -0
- package/bin/types.d.ts +287 -0
- package/bin/types.js +2 -0
- package/bin/utils.d.ts +38 -0
- package/bin/utils.js +69 -0
- package/package.json +45 -0
package/bin/sql.d.ts
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { DataFrame, type LazyDataFrame } from ".";
|
|
2
|
+
declare const INSPECT: unique symbol;
|
|
3
|
+
/**
|
|
4
|
+
* Run SQL queries against DataFrame/LazyFrame data.
|
|
5
|
+
*
|
|
6
|
+
* @experimental This functionality is considered **unstable**, although it is close to being
|
|
7
|
+
* considered stable. It may be changed at any point without it being considered a breaking change.
|
|
8
|
+
*/
|
|
9
|
+
export interface iSQLContext {
|
|
10
|
+
/**
|
|
11
|
+
* Parse the given SQL query and execute it against the registered frame data.
|
|
12
|
+
*
|
|
13
|
+
* @param query - A valid string SQL query.
|
|
14
|
+
* @param eager - Apply the query eagerly, returning `DataFrame` instead of `LazyFrame`.
|
|
15
|
+
* If unset, the value of the init-time parameter "eager_execution" will be
|
|
16
|
+
* used. (Note that the query itself is always executed in lazy-mode; this
|
|
17
|
+
* parameter only impacts the type of the returned frame).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* Declare frame data and register with a SQLContext:
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* const df = pl.DataFrame({
|
|
24
|
+
* data: [
|
|
25
|
+
* ("The Godfather", 1972, 6_000_000, 134_821_952, 9.2),
|
|
26
|
+
* ("The Dark Knight", 2008, 185_000_000, 533_316_061, 9.0),
|
|
27
|
+
* ("Schindler's List", 1993, 22_000_000, 96_067_179, 8.9),
|
|
28
|
+
* ("Pulp Fiction", 1994, 8_000_000, 107_930_000, 8.9),
|
|
29
|
+
* ("The Shawshank Redemption", 1994, 25_000_000, 28_341_469, 9.3),
|
|
30
|
+
* ],
|
|
31
|
+
* schema: ["title", "release_year", "budget", "gross", "imdb_score"],
|
|
32
|
+
* });
|
|
33
|
+
* const ctx = pl.SQLContext({ films: df });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Execute a SQL query against the registered frame data:
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* const result = ctx.execute(`
|
|
40
|
+
* SELECT title, release_year, imdb_score
|
|
41
|
+
* FROM films
|
|
42
|
+
* WHERE release_year > 1990
|
|
43
|
+
* ORDER BY imdb_score DESC
|
|
44
|
+
* `, { eager: true });
|
|
45
|
+
* console.log(result);
|
|
46
|
+
* // shape: (4, 3)
|
|
47
|
+
* // ┌──────────────────────────┬──────────────┬────────────┐
|
|
48
|
+
* // │ title ┆ release_year ┆ imdb_score │
|
|
49
|
+
* // │ --- ┆ --- ┆ --- │
|
|
50
|
+
* // ╞══════════════════════════╪══════════════╪════════════╡
|
|
51
|
+
* // │ The Shawshank Redemption ┆ 1994 ┆ 9.3 │
|
|
52
|
+
* // │ The Dark Knight ┆ 2008 ┆ 9.0 │
|
|
53
|
+
* // │ Schindler's List ┆ 1993 ┆ 8.9 │
|
|
54
|
+
* // │ Pulp Fiction ┆ 1994 ┆ 8.9 │
|
|
55
|
+
* // └──────────────────────────┴──────────────┴────────────┘
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* Execute a GROUP BY query:
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* ctx.execute(`
|
|
62
|
+
* SELECT
|
|
63
|
+
* MAX(release_year / 10) * 10 AS decade,
|
|
64
|
+
* SUM(gross) AS total_gross,
|
|
65
|
+
* COUNT(title) AS n_films,
|
|
66
|
+
* FROM films
|
|
67
|
+
* GROUP BY (release_year / 10) -- decade
|
|
68
|
+
* ORDER BY total_gross DESC
|
|
69
|
+
* `, { eager: true });
|
|
70
|
+
* // shape: (3, 3)
|
|
71
|
+
* // ┌────────┬─────────────┬─────────┐
|
|
72
|
+
* // │ decade ┆ total_gross ┆ n_films │
|
|
73
|
+
* // │ --- ┆ --- ┆ --- │
|
|
74
|
+
* // ╞════════╪═════════════╪═════════╡
|
|
75
|
+
* // │ 2000 ┆ 533316061 ┆ 1 │
|
|
76
|
+
* // │ 1990 ┆ 232338648 ┆ 3 │
|
|
77
|
+
* // │ 1970 ┆ 134821952 ┆ 1 │
|
|
78
|
+
* // └────────┴─────────────┴─────────┘
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
execute(query: string, { eager }: {
|
|
82
|
+
eager: true;
|
|
83
|
+
}): DataFrame;
|
|
84
|
+
execute(query: string, { eager }: {
|
|
85
|
+
eager: false;
|
|
86
|
+
}): LazyDataFrame;
|
|
87
|
+
execute(query: string): LazyDataFrame;
|
|
88
|
+
/**
|
|
89
|
+
* Register a single frame as a table, using the given name.
|
|
90
|
+
*
|
|
91
|
+
* Parameters
|
|
92
|
+
* ----------
|
|
93
|
+
* name : string
|
|
94
|
+
* Name of the table.
|
|
95
|
+
* frame : DataFrame | LazyFrame | null
|
|
96
|
+
* Eager/lazy frame to associate with this table name.
|
|
97
|
+
*
|
|
98
|
+
* See Also
|
|
99
|
+
* --------
|
|
100
|
+
* register_globals
|
|
101
|
+
* register_many
|
|
102
|
+
* unregister
|
|
103
|
+
*
|
|
104
|
+
* Examples
|
|
105
|
+
* --------
|
|
106
|
+
* const df = pl.DataFrame({"hello": ["world"]});
|
|
107
|
+
* const ctx = pl.SQLContext();
|
|
108
|
+
* ctx.register("frame_data", df).execute("SELECT * FROM frame_data").collect();
|
|
109
|
+
* returns: shape: (1, 1)
|
|
110
|
+
* ┌───────┐
|
|
111
|
+
* │ hello │
|
|
112
|
+
* │ --- │
|
|
113
|
+
* │ str │
|
|
114
|
+
* ╞═══════╡
|
|
115
|
+
* │ world │
|
|
116
|
+
* └───────┘
|
|
117
|
+
*/
|
|
118
|
+
register(name: string, frame: DataFrame | LazyDataFrame | null): SQLContext;
|
|
119
|
+
/**
|
|
120
|
+
* Register multiple DataFrames as tables, using the associated names.
|
|
121
|
+
*
|
|
122
|
+
* @param {Object} frames An `{name: df, ...}` mapping.
|
|
123
|
+
*
|
|
124
|
+
* @returns {SQLContext} The SQLContext with registered DataFrames.
|
|
125
|
+
*
|
|
126
|
+
* @see register
|
|
127
|
+
* @see unregister
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* const lf1 = pl.DataFrame({"a": [1, 2, 3], "b": ["m", "n", "o"]});
|
|
131
|
+
* const lf2 = pl.DataFrame({"a": [2, 3, 4], "c": ["p", "q", "r"]});
|
|
132
|
+
*
|
|
133
|
+
* // Register multiple DataFrames at once
|
|
134
|
+
* const ctx = pl.SQLContext().registerMany({"tbl1": lf1, "tbl2": lf2});
|
|
135
|
+
* console.log(ctx.tables());
|
|
136
|
+
* // Output: ['tbl1', 'tbl2']
|
|
137
|
+
*/
|
|
138
|
+
registerMany(frames: Record<string, DataFrame | LazyDataFrame>): SQLContext;
|
|
139
|
+
/**
|
|
140
|
+
* Unregister one or more eager/lazy frames by name.
|
|
141
|
+
*
|
|
142
|
+
* @param names - Names of the tables to unregister.
|
|
143
|
+
*
|
|
144
|
+
* @remarks
|
|
145
|
+
* You can also control table registration lifetime by using `SQLContext` as a
|
|
146
|
+
* context manager; this can often be more useful when such control is wanted.
|
|
147
|
+
*
|
|
148
|
+
* Frames registered in-scope are automatically unregistered on scope-exit. Note
|
|
149
|
+
* that frames registered on construction will persist through subsequent scopes.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* const df0 = pl.DataFrame({"colx": [0, 1, 2]});
|
|
154
|
+
* const df1 = pl.DataFrame({"colx": [1, 2, 3]});
|
|
155
|
+
* const df2 = pl.DataFrame({"colx": [2, 3, 4]});
|
|
156
|
+
*
|
|
157
|
+
* // Register one frame at construction time, and the other two in-scope
|
|
158
|
+
* const ctx = pl.SQLContext({ tbl0: df0 });
|
|
159
|
+
* ctx.register("tbl1", df1);
|
|
160
|
+
* ctx.register("tbl2", df2);
|
|
161
|
+
* console.log(ctx.tables()); // Output: ['tbl0', 'tbl1', 'tbl2']
|
|
162
|
+
*
|
|
163
|
+
* // After scope exit, none of the tables registered in-scope remain
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @see register
|
|
167
|
+
* @see register_globals
|
|
168
|
+
* @see register_many
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* const df0 = pl.DataFrame({"ints": [9, 8, 7, 6, 5]});
|
|
173
|
+
* const lf1 = pl.DataFrame({"text": ["a", "b", "c"]}).lazy();
|
|
174
|
+
* const lf2 = pl.DataFrame({"misc": ["testing1234"]}).lazy();
|
|
175
|
+
*
|
|
176
|
+
* // Register with a SQLContext object
|
|
177
|
+
* const ctx = pl.SQLContext({ test1: df0, test2: lf1, test3: lf2 });
|
|
178
|
+
* console.log(ctx.tables()); // Output: ['test1', 'test2', 'test3']
|
|
179
|
+
*
|
|
180
|
+
* // Unregister one or more of the tables
|
|
181
|
+
* ctx.unregister(["test1", "test3"]);
|
|
182
|
+
* console.log(ctx.tables()); // Output: ['test2']
|
|
183
|
+
* ctx.unregister("test2");
|
|
184
|
+
* console.log(ctx.tables()); // Output: []
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
unregister(names: string | string[]): SQLContext;
|
|
188
|
+
/**
|
|
189
|
+
* Returns a list of the registered table names.
|
|
190
|
+
*
|
|
191
|
+
* @remarks
|
|
192
|
+
* The `tables` method will return the same values as the "SHOW TABLES" SQL statement, but as a list instead of a frame.
|
|
193
|
+
*
|
|
194
|
+
* Executing as SQL:
|
|
195
|
+
* ```ts
|
|
196
|
+
* const frame_data = pl.DataFrame({"hello": ["world"]});
|
|
197
|
+
* const ctx = pl.SQLContext({ hello_world: frame_data });
|
|
198
|
+
* console.log(ctx.execute("SHOW TABLES", { eager: true }));
|
|
199
|
+
* // shape: (1, 1)
|
|
200
|
+
* // ┌─────────────┐
|
|
201
|
+
* // │ name │
|
|
202
|
+
* // │ --- │
|
|
203
|
+
* // │ str │
|
|
204
|
+
* // ╞═════════════╡
|
|
205
|
+
* // │ hello_world │
|
|
206
|
+
* // └─────────────┘
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* Calling the method:
|
|
210
|
+
* ```ts
|
|
211
|
+
* console.log(ctx.tables());
|
|
212
|
+
* // ['hello_world']
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* const df1 = pl.DataFrame({"hello": ["world"]});
|
|
218
|
+
* const df2 = pl.DataFrame({"foo": ["bar", "baz"]});
|
|
219
|
+
* const ctx = pl.SQLContext({ hello_data: df1, foo_bar: df2 });
|
|
220
|
+
* console.log(ctx.tables());
|
|
221
|
+
* // ['foo_bar', 'hello_data']
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* @returns {string[]} An array of the registered table names.
|
|
225
|
+
*/
|
|
226
|
+
tables(): string[];
|
|
227
|
+
}
|
|
228
|
+
export declare class SQLContext implements iSQLContext {
|
|
229
|
+
#private;
|
|
230
|
+
[INSPECT](): string;
|
|
231
|
+
constructor(frames?: Record<string, DataFrame | LazyDataFrame>);
|
|
232
|
+
execute(query: string): LazyDataFrame;
|
|
233
|
+
execute(query: string, { eager }: {
|
|
234
|
+
eager: true;
|
|
235
|
+
}): DataFrame;
|
|
236
|
+
execute(query: string, { eager }: {
|
|
237
|
+
eager: false;
|
|
238
|
+
}): LazyDataFrame;
|
|
239
|
+
register(this: SQLContext, name: string, frame: DataFrame | LazyDataFrame | null): SQLContext;
|
|
240
|
+
registerMany(this: SQLContext, frames: Record<string, DataFrame | LazyDataFrame>): SQLContext;
|
|
241
|
+
unregister(names: string | string[]): SQLContext;
|
|
242
|
+
tables(): string[];
|
|
243
|
+
}
|
|
244
|
+
export {};
|
package/bin/sql.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SQLContext = void 0;
|
|
7
|
+
const _1 = require(".");
|
|
8
|
+
const polars_internal_1 = __importDefault(require("./internals/polars_internal"));
|
|
9
|
+
const INSPECT = Symbol.for("nodejs.util.inspect.custom");
|
|
10
|
+
class SQLContext {
|
|
11
|
+
#ctx; // native SQLContext
|
|
12
|
+
[INSPECT]() {
|
|
13
|
+
return `SQLContext: {${this.#ctx.getTables().join(", ")}}`;
|
|
14
|
+
}
|
|
15
|
+
constructor(frames) {
|
|
16
|
+
this.#ctx = new polars_internal_1.default.SqlContext();
|
|
17
|
+
for (const [name, frame] of Object.entries(frames ?? {})) {
|
|
18
|
+
if (_1.DataFrame.isDataFrame(frame)) {
|
|
19
|
+
this.#ctx.register(name, frame._df.lazy());
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.#ctx.register(name, frame._ldf);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
execute(query, { eager } = { eager: false }) {
|
|
27
|
+
const lf_ = this.#ctx.execute(query);
|
|
28
|
+
const lf = (0, _1._LazyDataFrame)(lf_);
|
|
29
|
+
if (eager) {
|
|
30
|
+
return lf.collectSync();
|
|
31
|
+
}
|
|
32
|
+
return lf;
|
|
33
|
+
}
|
|
34
|
+
register(name, frame) {
|
|
35
|
+
if (frame == null) {
|
|
36
|
+
frame = (0, _1.DataFrame)().lazy();
|
|
37
|
+
}
|
|
38
|
+
else if (_1.DataFrame.isDataFrame(frame)) {
|
|
39
|
+
frame = frame.lazy();
|
|
40
|
+
}
|
|
41
|
+
this.#ctx.register(name, frame._ldf);
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
registerMany(frames) {
|
|
45
|
+
for (const [name, frame] of Object.entries(frames)) {
|
|
46
|
+
this.register(name, frame);
|
|
47
|
+
}
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
unregister(names) {
|
|
51
|
+
if (typeof names === "string") {
|
|
52
|
+
names = [names];
|
|
53
|
+
}
|
|
54
|
+
for (const name of names) {
|
|
55
|
+
this.#ctx.unregister(name);
|
|
56
|
+
}
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
tables() {
|
|
60
|
+
return this.#ctx.getTables();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.SQLContext = SQLContext;
|
package/bin/types.d.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import type { ValueOrArray } from "./utils";
|
|
2
|
+
/**
|
|
3
|
+
* Downsample rules
|
|
4
|
+
*/
|
|
5
|
+
export type DownsampleRule = "month" | "week" | "day" | "hour" | "minute" | "second";
|
|
6
|
+
/**
|
|
7
|
+
* Fill null strategies
|
|
8
|
+
*/
|
|
9
|
+
export type FillNullStrategy = "backward" | "forward" | "mean" | "min" | "max" | "zero" | "one";
|
|
10
|
+
/**
|
|
11
|
+
* Rank methods
|
|
12
|
+
*/
|
|
13
|
+
export type RankMethod = "average" | "min" | "max" | "dense" | "ordinal" | "random";
|
|
14
|
+
/**
|
|
15
|
+
* Round modes
|
|
16
|
+
*/
|
|
17
|
+
export type RoundMode = "halftoeven" | "halfawayfromzero";
|
|
18
|
+
/**
|
|
19
|
+
* Options for {@link concat}
|
|
20
|
+
*/
|
|
21
|
+
export interface ConcatOptions {
|
|
22
|
+
rechunk?: boolean;
|
|
23
|
+
parallel?: boolean;
|
|
24
|
+
how?: "vertical" | "verticalRelaxed" | "horizontal" | "diagonal" | "diagonalRelaxed" | "align" | "alignInner" | "alignFull" | "alignLeft" | "alignRight";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for @see {@link DataFrame.writeCSV}
|
|
28
|
+
* Options for @see {@link LazyDataFrame.sinkCSV}
|
|
29
|
+
* @category Options
|
|
30
|
+
*/
|
|
31
|
+
export interface CsvWriterOptions {
|
|
32
|
+
includeBom?: boolean;
|
|
33
|
+
includeHeader?: boolean;
|
|
34
|
+
separator?: string;
|
|
35
|
+
quoteChar?: string;
|
|
36
|
+
lineTerminator?: string;
|
|
37
|
+
batchSize?: number;
|
|
38
|
+
datetimeFormat?: string;
|
|
39
|
+
dateFormat?: string;
|
|
40
|
+
timeFormat?: string;
|
|
41
|
+
floatPrecision?: number;
|
|
42
|
+
nullValue?: string;
|
|
43
|
+
maintainOrder?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface SinkOptions {
|
|
46
|
+
syncOnClose: any;
|
|
47
|
+
maintainOrder: boolean;
|
|
48
|
+
mkdir: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Options for @see {@link LazyDataFrame.sinkParquet }
|
|
52
|
+
* @category Options
|
|
53
|
+
*/
|
|
54
|
+
export interface SinkParquetOptions {
|
|
55
|
+
compression?: string;
|
|
56
|
+
compressionLevel?: number;
|
|
57
|
+
statistics?: boolean;
|
|
58
|
+
rowGroupSize?: number;
|
|
59
|
+
dataPagesizeLimit?: number;
|
|
60
|
+
maintainOrder?: boolean;
|
|
61
|
+
typeCoercion?: boolean;
|
|
62
|
+
predicatePushdown?: boolean;
|
|
63
|
+
projectionPushdown?: boolean;
|
|
64
|
+
simplifyExpression?: boolean;
|
|
65
|
+
slicePushdown?: boolean;
|
|
66
|
+
noOptimization?: boolean;
|
|
67
|
+
cloudOptions?: Record<string, string>;
|
|
68
|
+
retries?: number;
|
|
69
|
+
sinkOptions?: SinkOptions;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Options for @see {@link LazyDataFrame.sinkNdJson}
|
|
73
|
+
* @category Options
|
|
74
|
+
*/
|
|
75
|
+
export interface SinkJsonOptions {
|
|
76
|
+
cloudOptions?: Record<string, string>;
|
|
77
|
+
retries?: number;
|
|
78
|
+
syncOnClose?: string;
|
|
79
|
+
maintainOrder?: boolean;
|
|
80
|
+
mkdir?: boolean;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Options for @see {@link LazyDataFrame.sinkIpc}
|
|
84
|
+
* @category Options
|
|
85
|
+
*/
|
|
86
|
+
export interface SinkIpcOptions {
|
|
87
|
+
compression?: string;
|
|
88
|
+
compatLevel?: string;
|
|
89
|
+
cloudOptions?: Record<string, string>;
|
|
90
|
+
retries?: number;
|
|
91
|
+
syncOnClose?: string;
|
|
92
|
+
maintainOrder?: boolean;
|
|
93
|
+
mkdir?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Options for {@link DataFrame.writeJSON}
|
|
97
|
+
* @category Options
|
|
98
|
+
*/
|
|
99
|
+
export interface WriteJsonOptions {
|
|
100
|
+
orient?: "row" | "col" | "dataframe";
|
|
101
|
+
multiline?: boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Options for {@link scanJson}
|
|
105
|
+
*/
|
|
106
|
+
export interface JsonScanOptions {
|
|
107
|
+
inferSchemaLength?: number;
|
|
108
|
+
nThreads?: number;
|
|
109
|
+
batchSize?: number;
|
|
110
|
+
lowMemory?: boolean;
|
|
111
|
+
numRows?: number;
|
|
112
|
+
skipRows?: number;
|
|
113
|
+
rowCount?: RowCount;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Options for {@link DataFrame.writeParquet}
|
|
117
|
+
* @category Options
|
|
118
|
+
*/
|
|
119
|
+
export interface WriteParquetOptions {
|
|
120
|
+
compression?: "uncompressed" | "snappy" | "gzip" | "lzo" | "brotli" | "lz4" | "zstd";
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Options for {@link readParquet}
|
|
124
|
+
*/
|
|
125
|
+
export interface ReadParquetOptions {
|
|
126
|
+
columns?: string[] | number[];
|
|
127
|
+
numRows?: number;
|
|
128
|
+
parallel?: "auto" | "columns" | "row_groups" | "none";
|
|
129
|
+
rowCount?: RowCount;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Options for {@link scanParquet}
|
|
133
|
+
*/
|
|
134
|
+
export interface ScanParquetOptions {
|
|
135
|
+
nRows?: number;
|
|
136
|
+
rowIndexName?: string;
|
|
137
|
+
rowIndexOffset?: number;
|
|
138
|
+
cache?: boolean;
|
|
139
|
+
parallel?: "auto" | "columns" | "row_groups" | "none";
|
|
140
|
+
glob?: boolean;
|
|
141
|
+
hivePartitioning?: boolean;
|
|
142
|
+
hiveSchema?: unknown;
|
|
143
|
+
tryParseHiveDates?: boolean;
|
|
144
|
+
rechunk?: boolean;
|
|
145
|
+
lowMemory?: boolean;
|
|
146
|
+
useStatistics?: boolean;
|
|
147
|
+
cloudOptions?: Record<string, string>;
|
|
148
|
+
retries?: number;
|
|
149
|
+
includeFilePaths?: string;
|
|
150
|
+
allowMissingColumns?: boolean;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Add row count as column
|
|
154
|
+
*/
|
|
155
|
+
export interface RowCount {
|
|
156
|
+
/** name of column */
|
|
157
|
+
name: string;
|
|
158
|
+
/** offset */
|
|
159
|
+
offset: number;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Options for {@link DataFrame.writeIPC}
|
|
163
|
+
* @category Options
|
|
164
|
+
*/
|
|
165
|
+
export interface WriteIPCOptions {
|
|
166
|
+
compression?: "uncompressed" | "lz4" | "zstd";
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Options for writing Avro files
|
|
170
|
+
* @category Options
|
|
171
|
+
*/
|
|
172
|
+
export interface WriteAvroOptions {
|
|
173
|
+
compression?: "uncompressed" | "snappy" | "deflate";
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Interpolation types
|
|
177
|
+
*/
|
|
178
|
+
export type InterpolationMethod = "nearest" | "higher" | "lower" | "midpoint" | "linear";
|
|
179
|
+
/**
|
|
180
|
+
* Join types
|
|
181
|
+
*/
|
|
182
|
+
export type JoinType = "left" | "inner" | "full" | "semi" | "anti" | "cross";
|
|
183
|
+
/**
|
|
184
|
+
* options for same named column join @see {@link DataFrame.join}
|
|
185
|
+
*/
|
|
186
|
+
export type SameNameColumnJoinOptions<L extends string = string, R extends string = string> = {
|
|
187
|
+
/** Name(s) of the join columns in both DataFrames. */
|
|
188
|
+
on: ValueOrArray<L & R>;
|
|
189
|
+
/** Join strategy */
|
|
190
|
+
how?: Exclude<JoinType, "cross">;
|
|
191
|
+
/** Suffix to append to columns with a duplicate name. */
|
|
192
|
+
suffix?: string;
|
|
193
|
+
/** Coalescing behavior (merging of join columns). */
|
|
194
|
+
coalesce?: boolean;
|
|
195
|
+
validate?: string;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* options for differently named column join @see {@link DataFrame.join}
|
|
199
|
+
*/
|
|
200
|
+
export type DifferentNameColumnJoinOptions<L extends string = string, R extends string = string> = {
|
|
201
|
+
/** Name(s) of the left join column(s). */
|
|
202
|
+
leftOn: ValueOrArray<L>;
|
|
203
|
+
/** Name(s) of the right join column(s). */
|
|
204
|
+
rightOn: ValueOrArray<R>;
|
|
205
|
+
/** Join strategy */
|
|
206
|
+
how?: Exclude<JoinType, "cross">;
|
|
207
|
+
/** Suffix to append to columns with a duplicate name. */
|
|
208
|
+
suffix?: string;
|
|
209
|
+
/** Coalescing behavior (merging of join columns). */
|
|
210
|
+
coalesce?: boolean;
|
|
211
|
+
validate?: string;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* options for cross join @see {@link DataFrame.join}
|
|
215
|
+
*/
|
|
216
|
+
export type CrossJoinOptions = {
|
|
217
|
+
/** Join strategy */
|
|
218
|
+
how: "cross";
|
|
219
|
+
/** Suffix to append to columns with a duplicate name. */
|
|
220
|
+
suffix?: string;
|
|
221
|
+
/** Coalescing behavior (merging of join columns). */
|
|
222
|
+
coalesce?: boolean;
|
|
223
|
+
validate?: string;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* options for join operations @see {@link DataFrame.join}
|
|
227
|
+
*/
|
|
228
|
+
export type JoinOptions<L extends string = string, R extends string = string> = SameNameColumnJoinOptions<L, R> | DifferentNameColumnJoinOptions<L, R> | CrossJoinOptions;
|
|
229
|
+
type LazyJoinBase = {
|
|
230
|
+
/** Allow the physical plan to optionally evaluate the computation of both DataFrames up to the join in parallel. */
|
|
231
|
+
allowParallel?: boolean;
|
|
232
|
+
/** Force the physical plan to evaluate the computation of both DataFrames up to the join in parallel. */
|
|
233
|
+
forceParallel?: boolean;
|
|
234
|
+
};
|
|
235
|
+
export type LazySameNameColumnJoinOptions<L extends string = string, R extends string = string> = SameNameColumnJoinOptions<L, R> & LazyJoinBase;
|
|
236
|
+
export type LazyDifferentNameColumnJoinOptions<L extends string = string, R extends string = string> = DifferentNameColumnJoinOptions<L, R> & LazyJoinBase;
|
|
237
|
+
export type LazyCrossJoinOptions = CrossJoinOptions & LazyJoinBase;
|
|
238
|
+
/**
|
|
239
|
+
* options for lazy join operations @see {@link LazyDataFrame.join}
|
|
240
|
+
*/
|
|
241
|
+
export type LazyJoinOptions<L extends string = string, R extends string = string> = LazySameNameColumnJoinOptions<L, R> | LazyDifferentNameColumnJoinOptions<L, R> | LazyCrossJoinOptions;
|
|
242
|
+
/**
|
|
243
|
+
* options for lazy operations @see {@link LazyDataFrame.collect}
|
|
244
|
+
*/
|
|
245
|
+
export type LazyOptions = {
|
|
246
|
+
typeCoercion?: boolean;
|
|
247
|
+
predicatePushdown?: boolean;
|
|
248
|
+
projectionPushdown?: boolean;
|
|
249
|
+
simplifyExpression?: boolean;
|
|
250
|
+
slicePushdown?: boolean;
|
|
251
|
+
noOptimization?: boolean;
|
|
252
|
+
commSubplanElim?: boolean;
|
|
253
|
+
commSubexprElim?: boolean;
|
|
254
|
+
streaming?: boolean;
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* options for rolling window operations
|
|
258
|
+
* @category Options
|
|
259
|
+
*/
|
|
260
|
+
export interface RollingOptions {
|
|
261
|
+
windowSize: number;
|
|
262
|
+
weights?: Array<number>;
|
|
263
|
+
minPeriods?: number;
|
|
264
|
+
center?: boolean;
|
|
265
|
+
ddof?: number;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* options for rolling quantile operations
|
|
269
|
+
* @category Options
|
|
270
|
+
*/
|
|
271
|
+
export interface RollingQuantileOptions extends RollingOptions {
|
|
272
|
+
quantile: number;
|
|
273
|
+
interpolation?: InterpolationMethod;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* options for rolling mean operations
|
|
277
|
+
* @category Options
|
|
278
|
+
*/
|
|
279
|
+
export interface RollingSkewOptions {
|
|
280
|
+
windowSize: number;
|
|
281
|
+
bias?: boolean;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* ClosedWindow types
|
|
285
|
+
*/
|
|
286
|
+
export type ClosedWindow = "None" | "Both" | "Left" | "Right";
|
|
287
|
+
export {};
|
package/bin/types.js
ADDED
package/bin/utils.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DataFrame } from "./dataframe";
|
|
2
|
+
import { LazyDataFrame } from "./lazy/dataframe";
|
|
3
|
+
import { Expr } from "./lazy/expr";
|
|
4
|
+
import { Series } from "./series";
|
|
5
|
+
/** @ignore */
|
|
6
|
+
export type ValueOrArray<T> = T | Array<ValueOrArray<T>>;
|
|
7
|
+
/** @ignore */
|
|
8
|
+
export type ColumnSelection = ValueOrArray<string>;
|
|
9
|
+
/** @ignore */
|
|
10
|
+
export type ExpressionSelection = ValueOrArray<Expr>;
|
|
11
|
+
/** @ignore */
|
|
12
|
+
export type ColumnsOrExpr = ColumnSelection | ExpressionSelection;
|
|
13
|
+
/** @ignore */
|
|
14
|
+
export type ExprOrString = Expr | string;
|
|
15
|
+
/**
|
|
16
|
+
* @typeParam StartBy - The strategy to determine the start of the first window by.
|
|
17
|
+
*/
|
|
18
|
+
export type StartBy = "window" | "datapoint" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday";
|
|
19
|
+
/** @ignore */
|
|
20
|
+
export declare function columnOrColumns(columns: ColumnSelection | string | Array<string> | undefined): Array<string> | undefined;
|
|
21
|
+
/** @ignore */
|
|
22
|
+
export declare function columnOrColumnsStrict(...columns: string[] | ValueOrArray<string>[]): Array<string>;
|
|
23
|
+
/** @ignore */
|
|
24
|
+
export declare function selectionToExprList(columns: any[], stringToLit?: any): any[];
|
|
25
|
+
/** @ignore */
|
|
26
|
+
export declare function isPath(s: string, expectedExtensions?: string[]): boolean;
|
|
27
|
+
export declare const range: (start: number, end: number) => number[];
|
|
28
|
+
export declare const isDataFrameArray: (ty: any) => ty is DataFrame[];
|
|
29
|
+
export declare const isLazyDataFrameArray: (ty: any) => ty is LazyDataFrame[];
|
|
30
|
+
export declare const isSeriesArray: <_T>(ty: any) => ty is Series[];
|
|
31
|
+
export declare const isExprArray: (ty: any) => ty is Expr[];
|
|
32
|
+
export declare const isIterator: <T>(ty: any) => ty is Iterable<T>;
|
|
33
|
+
export declare const regexToString: (r: string | RegExp) => string;
|
|
34
|
+
export declare const commonValue: (...arr: string[][]) => string[];
|
|
35
|
+
export declare const INSPECT_SYMBOL: unique symbol;
|
|
36
|
+
export type Simplify<T> = {
|
|
37
|
+
[K in keyof T]: T[K];
|
|
38
|
+
} & {};
|