Skip to content

Commit 2c0e091

Browse files
authored
Updating to rs-0.45 (pola-rs#301)
Updating to rs-0.45
1 parent 8816b46 commit 2c0e091

21 files changed

+1245
-1537
lines changed

.github/workflows/docs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Install latest Rust nightly
1515
uses: dtolnay/rust-toolchain@stable
1616
with:
17-
toolchain: nightly-2024-10-28
17+
toolchain: nightly-2024-11-28
1818
components: rustfmt, clippy
1919
- name: Install ghp-import
2020
uses: actions/setup-python@v5

.github/workflows/test-js.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install latest Rust nightly
2121
uses: dtolnay/rust-toolchain@stable
2222
with:
23-
toolchain: nightly-2024-10-28
23+
toolchain: nightly-2024-11-28
2424
components: rustfmt, clippy
2525
- name: Check yarn version
2626
run: yarn --version
@@ -46,7 +46,7 @@ jobs:
4646
- name: Install latest Rust nightly
4747
uses: dtolnay/rust-toolchain@stable
4848
with:
49-
toolchain: nightly-2024-10-28
49+
toolchain: nightly-2024-11-28
5050
components: rustfmt, clippy
5151
- name: Bun version
5252
uses: oven-sh/setup-bun@v1

.yarn/releases/yarn-4.5.0.cjs

-925
This file was deleted.

.yarn/releases/yarn-4.5.3.cjs

+934
Large diffs are not rendered by default.

.yarnrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ enableGlobalCache: false
44

55
nodeLinker: node-modules
66

7-
yarnPath: .yarn/releases/yarn-4.5.0.cjs
7+
yarnPath: .yarn/releases/yarn-4.5.3.cjs

Cargo.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ napi = { version = "2.16.13", default-features = false, features = [
1919
"napi8",
2020
"serde-json",
2121
] }
22-
napi-derive = { version = "2.16.12", default-features = false }
23-
polars-core = { git = "https://github.com/pola-rs/polars.git", rev = "2dce3d3b5c80ae7522a3435f844fac8fed9dc9e8", default-features = false }
24-
polars-io = { git = "https://github.com/pola-rs/polars.git", rev = "2dce3d3b5c80ae7522a3435f844fac8fed9dc9e8", default-features = false }
25-
polars-lazy = { git = "https://github.com/pola-rs/polars.git", rev = "2dce3d3b5c80ae7522a3435f844fac8fed9dc9e8", default-features = false }
22+
napi-derive = { version = "2.16.13", default-features = false }
23+
polars-core = { git = "https://github.com/pola-rs/polars.git", rev = "58a38af21dccaf3326514494a1db118601c8c2ca", default-features = false }
24+
polars-io = { git = "https://github.com/pola-rs/polars.git", rev = "58a38af21dccaf3326514494a1db118601c8c2ca", default-features = false }
25+
polars-lazy = { git = "https://github.com/pola-rs/polars.git", rev = "58a38af21dccaf3326514494a1db118601c8c2ca", default-features = false }
2626
thiserror = "1"
2727
smartstring = { version = "1" }
2828
serde_json = { version = "1" }
2929
either = "1.13.0"
30-
hashbrown = { version = "0.15.0", features = ["rayon", "serde"] }
30+
hashbrown = { version = "0.15.2", features = ["rayon", "serde"] }
3131

3232
[dependencies.polars]
3333
features = [
@@ -162,7 +162,7 @@ features = [
162162
"azure"
163163
]
164164
git = "https://github.com/pola-rs/polars.git"
165-
rev = "2dce3d3b5c80ae7522a3435f844fac8fed9dc9e8"
165+
rev = "58a38af21dccaf3326514494a1db118601c8c2ca"
166166

167167
[build-dependencies]
168168
napi-build = "2.1.3"

__tests__/dataframe.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ describe("io", () => {
16801680
expect(actual).toEqual(expected);
16811681
});
16821682
test("writeCSV:string:sep", () => {
1683-
const actual = df.clone().writeCSV({ sep: "X" }).toString();
1683+
const actual = df.clone().writeCSV({ separator: "X" }).toString();
16841684
const expected = "fooXbar\n1X6\n2X2\n9X8\n";
16851685
expect(actual).toEqual(expected);
16861686
});
@@ -1689,14 +1689,14 @@ describe("io", () => {
16891689
bar: ["a,b,c", "d,e,f", "g,h,i"],
16901690
foo: [1, 2, 3],
16911691
});
1692-
const actual = df.writeCSV({ quote: "^" }).toString();
1692+
const actual = df.writeCSV({ quoteChar: "^" }).toString();
16931693
const expected = "bar,foo\n^a,b,c^,1.0\n^d,e,f^,2.0\n^g,h,i^,3.0\n";
16941694
expect(actual).toEqual(expected);
16951695
});
16961696
test("writeCSV:string:header", () => {
16971697
const actual = df
16981698
.clone()
1699-
.writeCSV({ sep: "X", includeHeader: false, lineTerminator: "|" })
1699+
.writeCSV({ separator: "X", includeHeader: false, lineTerminator: "|" })
17001700
.toString();
17011701
const expected = "1X6|2X2|9X8|";
17021702
expect(actual).toEqual(expected);

__tests__/io.test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ describe("read:csv", () => {
5252
csvString.slice(0, 22),
5353
);
5454
});
55+
it("can read from a csv buffer with newline in the header", () => {
56+
const csvBuffer = Buffer.from(
57+
'"name\na","height\nb"\n"John",172.23\n"Anna",1653.34',
58+
);
59+
const df = pl.readCSV(csvBuffer, {
60+
quoteChar: '"',
61+
sep: ",",
62+
hasHeader: false,
63+
skipRows: 1,
64+
});
65+
expect(df.toRecords()).toEqual([
66+
{ column_1: "John", column_2: 172.23 },
67+
{ column_1: "Anna", column_2: 1653.34 },
68+
]);
69+
});
5570
it("can read from a csv buffer", () => {
5671
const csvBuffer = Buffer.from("foo,bar,baz\n1,2,3\n4,5,6\n", "utf-8");
5772
const df = pl.readCSV(csvBuffer);

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@
5858
"@napi-rs/cli": "^2.18.4",
5959
"@types/chance": "^1.1.6",
6060
"@types/jest": "^29.5.14",
61-
"@types/node": "^22.8.6",
61+
"@types/node": "^22.10.1",
6262
"chance": "^1.1.12",
6363
"jest": "^29.7.0",
6464
"source-map-support": "^0.5.21",
6565
"ts-jest": "^29.2.5",
6666
"ts-node": "^10.9.2",
67-
"typedoc": "^0.26.10",
68-
"typescript": "5.6.3"
67+
"typedoc": "^0.27.3",
68+
"typescript": "5.7.2"
6969
},
70-
"packageManager": "[email protected].0",
70+
"packageManager": "[email protected].3",
7171
"workspaces": [
7272
"benches"
7373
]

polars/dataframe.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import { type LazyDataFrame, _LazyDataFrame } from "./lazy/dataframe";
1212
import { Expr } from "./lazy/expr";
1313
import { Series, _Series } from "./series";
1414
import type {
15+
CsvWriterOptions,
1516
FillNullStrategy,
1617
JoinOptions,
1718
WriteAvroOptions,
18-
WriteCsvOptions,
1919
WriteIPCOptions,
2020
WriteParquetOptions,
2121
} from "./types";
@@ -61,8 +61,8 @@ interface WriteMethods {
6161
* @param options.includeBom - Whether to include UTF-8 BOM in the CSV output.
6262
* @param options.lineTerminator - String used to end each row.
6363
* @param options.includeHeader - Whether or not to include header in the CSV output.
64-
* @param options.sep - Separate CSV fields with this symbol. _defaults to `,`
65-
* @param options.quote - Character to use for quoting. Default: \" Note: it will note be used when sep is used
64+
* @param options.separator - Separate CSV fields with this symbol. _defaults to `,`
65+
* @param options.quoteChar - Character to use for quoting. Default: \" Note: it will note be used when sep is used
6666
* @param options.batchSize - Number of rows that will be processed per thread.
6767
* @param options.datetimeFormat - A format string, with the specifiers defined by the
6868
* `chrono <https://docs.rs/chrono/latest/chrono/format/strftime/index.html>`_
@@ -109,8 +109,8 @@ interface WriteMethods {
109109
* @category IO
110110
*/
111111
writeCSV(): Buffer;
112-
writeCSV(options: WriteCsvOptions): Buffer;
113-
writeCSV(dest: string | Writable, options?: WriteCsvOptions): void;
112+
writeCSV(options: CsvWriterOptions): Buffer;
113+
writeCSV(dest: string | Writable, options?: CsvWriterOptions): void;
114114
/**
115115
* Write Dataframe to JSON string, file, or write stream
116116
* @param destination file or write stream

polars/io.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ export function readAvro(pathOrBody, options = {}) {
503503
@param options.rechunk - In case of reading multiple files via a glob pattern rechunk the final DataFrame into contiguous memory chunks.
504504
@param options.lowMemory - Reduce memory pressure at the expense of performance.
505505
@param options.cache - Cache the result after reading.
506-
@param options.storageOptions - Options that indicate how to connect to a cloud provider.
506+
@param options.cloudOptions - Options that indicate how to connect to a cloud provider.
507507
If the cloud provider is not supported by Polars, the storage options are passed to `fsspec.open()`.
508508
509509
The cloud providers currently supported are AWS, GCP, and Azure.
@@ -513,7 +513,7 @@ export function readAvro(pathOrBody, options = {}) {
513513
* `gcp <https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html>`_
514514
* `azure <https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html>`_
515515
516-
If `storage_options` is not provided, Polars will try to infer the information from environment variables.
516+
If `cloudOptions` is not provided, Polars will try to infer the information from environment variables.
517517
@param retries - Number of retries if accessing a cloud instance fails.
518518
@param includeFilePaths - Include the path of the source file(s) as a column with this name.
519519
*/

polars/lazy/dataframe.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import pli from "../internals/polars_internal";
33
import type { Series } from "../series";
44
import type { Deserialize, GroupByOps, Serialize } from "../shared_traits";
55
import type {
6+
CsvWriterOptions,
67
LazyJoinOptions,
78
LazyOptions,
8-
SinkCsvOptions,
99
SinkParquetOptions,
1010
} from "../types";
1111
import {
@@ -541,7 +541,7 @@ export interface LazyDataFrame extends Serialize, GroupByOps<LazyGroupBy> {
541541
>>> lf.sinkCsv("out.csv")
542542
*/
543543

544-
sinkCSV(path: string, options?: SinkCsvOptions): void;
544+
sinkCSV(path: string, options?: CsvWriterOptions): void;
545545

546546
/***
547547
*
@@ -580,6 +580,18 @@ export interface LazyDataFrame extends Serialize, GroupByOps<LazyGroupBy> {
580580
@param simplifyExpression - Run simplify expressions optimization. Default -> true
581581
@param slicePushdown - Slice pushdown optimization. Default -> true
582582
@param noOptimization - Turn off (certain) optimizations. Default -> false
583+
@param cloudOptions - Options that indicate how to connect to a cloud provider.
584+
If the cloud provider is not supported by Polars, the storage options are passed to `fsspec.open()`.
585+
586+
The cloud providers currently supported are AWS, GCP, and Azure.
587+
See supported keys here:
588+
589+
* `aws <https://docs.rs/object_store/latest/object_store/aws/enum.AmazonS3ConfigKey.html>`_
590+
* `gcp <https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html>`_
591+
* `azure <https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html>`_
592+
593+
If `cloudOptions` is not provided, Polars will try to infer the information from environment variables.
594+
@param retries - Number of retries if accessing a cloud instance fails.
583595
584596
Examples
585597
--------
@@ -1078,7 +1090,7 @@ export const _LazyDataFrame = (_ldf: any): LazyDataFrame => {
10781090
withRowCount(name = "row_nr") {
10791091
return _LazyDataFrame(_ldf.withRowCount(name));
10801092
},
1081-
sinkCSV(path, options: SinkCsvOptions = {}) {
1093+
sinkCSV(path, options: CsvWriterOptions = {}) {
10821094
options.maintainOrder = options.maintainOrder ?? false;
10831095
_ldf.sinkCsv(path, options);
10841096
},

polars/lazy/functions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ export function spearmanRankCorr(a: ExprOrString, b: ExprOrString): Expr {
650650
a = exprToLitOrExpr(a, false);
651651
b = exprToLitOrExpr(b, false);
652652

653-
return _Expr(pli.spearmanRankCorr(a, b, null, false));
653+
return _Expr(pli.spearmanRankCorr(a, b, false));
654654
}
655655

656656
/** Get the last n rows of an Expression. */
@@ -964,7 +964,7 @@ export function sumHorizontal(exprs: ExprOrString | ExprOrString[]): Expr {
964964

965965
exprs = selectionToExprList(exprs);
966966

967-
return _Expr(pli.sumHorizontal(exprs));
967+
return _Expr(pli.sumHorizontal(exprs, true));
968968
}
969969

970970
// // export function collect_all() {}

polars/types.ts

+7-22
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,16 @@ export interface ConcatOptions {
3939
how?: "vertical" | "horizontal" | "diagonal";
4040
}
4141
/**
42-
* Options for {@link DataFrame.writeCSV}
43-
* @category Options
44-
*/
45-
export interface WriteCsvOptions {
46-
includeBom?: boolean;
47-
includeHeader?: boolean;
48-
sep?: string;
49-
quote?: string;
50-
lineTerminator?: string;
51-
batchSize?: number;
52-
datetimeFormat?: string;
53-
dateFormat?: string;
54-
timeFormat?: string;
55-
floatPrecision?: number;
56-
nullValue?: string;
57-
}
58-
/**
42+
* Options for @see {@link DataFrame.writeCSV}
5943
* Options for @see {@link LazyDataFrame.sinkCSV}
6044
* @category Options
6145
*/
62-
export interface SinkCsvOptions {
63-
includeHeader?: boolean;
64-
quote?: string;
46+
export interface CsvWriterOptions {
6547
includeBom?: boolean;
48+
includeHeader?: boolean;
6649
separator?: string;
67-
lineTerminator?: string;
6850
quoteChar?: string;
51+
lineTerminator?: string;
6952
batchSize?: number;
7053
datetimeFormat?: string;
7154
dateFormat?: string;
@@ -91,6 +74,8 @@ export interface SinkParquetOptions {
9174
simplifyExpression?: boolean;
9275
slicePushdown?: boolean;
9376
noOptimization?: boolean;
77+
cloudOptions?: Map<string, string>;
78+
retries?: number;
9479
}
9580
/**
9681
* Options for {@link DataFrame.writeJSON}
@@ -153,7 +138,7 @@ export interface ScanParquetOptions {
153138
rechunk?: boolean;
154139
lowMemory?: boolean;
155140
useStatistics?: boolean;
156-
cloudOptions?: unknown;
141+
cloudOptions?: Map<string, string>;
157142
retries?: number;
158143
includeFilePaths?: string;
159144
allowMissingColumns?: boolean;

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2024-10-28
1+
nightly-2024-11-28

0 commit comments

Comments
 (0)