Skip to content

Commit 70dabf6

Browse files
authored
Upgrading to rs-0.44.2 (#291)
Upgrading to rs-0.44.2
1 parent 18ed59a commit 70dabf6

19 files changed

+355
-229
lines changed

.github/workflows/docs.yaml

Lines changed: 1 addition & 1 deletion
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-09-19
17+
toolchain: nightly-2024-10-28
1818
components: rustfmt, clippy
1919
- name: Install ghp-import
2020
uses: actions/setup-python@v5

.github/workflows/test-js.yaml

Lines changed: 2 additions & 2 deletions
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-09-19
23+
toolchain: nightly-2024-10-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-09-19
49+
toolchain: nightly-2024-10-28
5050
components: rustfmt, clippy
5151
- name: Bun version
5252
uses: oven-sh/setup-bun@v1

Cargo.toml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ crate-type = ["cdylib", "lib"]
1515
[dependencies]
1616
ahash = "0.8.11"
1717
bincode = "1.3.3"
18-
napi = { version = "2.16.9", default-features = false, features = [
18+
napi = { version = "2.16.13", default-features = false, features = [
1919
"napi8",
2020
"serde-json",
2121
] }
22-
napi-derive = { version = "2.16.11", default-features = false }
23-
polars-core = { git = "https://github.com/pola-rs/polars.git", rev = "54218e7e35e3defd4b0801e820c56eea6b91e525", default-features = false }
24-
polars-io = { git = "https://github.com/pola-rs/polars.git", rev = "54218e7e35e3defd4b0801e820c56eea6b91e525", default-features = false }
25-
polars-lazy = { git = "https://github.com/pola-rs/polars.git", rev = "54218e7e35e3defd4b0801e820c56eea6b91e525", default-features = false }
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 }
2626
thiserror = "1"
2727
smartstring = { version = "1" }
2828
serde_json = { version = "1" }
2929
either = "1.13.0"
30-
hashbrown = {version = "=0.14.5", features = ["raw"]}
30+
hashbrown = { version = "0.15.0", features = ["rayon", "serde"] }
3131

3232
[dependencies.polars]
3333
features = [
@@ -86,7 +86,6 @@ features = [
8686
"to_dummies",
8787
"ipc",
8888
"ipc_streaming",
89-
"avro",
9089
"list_eval",
9190
"arg_where",
9291
"timezones",
@@ -163,7 +162,7 @@ features = [
163162
"azure"
164163
]
165164
git = "https://github.com/pola-rs/polars.git"
166-
rev = "54218e7e35e3defd4b0801e820c56eea6b91e525"
165+
rev = "2dce3d3b5c80ae7522a3435f844fac8fed9dc9e8"
167166

168167
[build-dependencies]
169168
napi-build = "2.1.3"

__tests__/expr.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,7 +1647,7 @@ describe("expr.lst", () => {
16471647
test("head", () => {
16481648
const s0 = pl.Series("a", [[3, 5, 6, 7, 8]]);
16491649
let actual = s0.lst.head(1);
1650-
let expected = pl.Series("a", [3]);
1650+
let expected = pl.Series("a", [[3]]);
16511651
expect(actual.seriesEqual(expected));
16521652
actual = s0.lst.head();
16531653
expected = pl.Series("a", [3, 5, 6, 7, 8]);
@@ -1656,7 +1656,7 @@ describe("expr.lst", () => {
16561656
test("tail", () => {
16571657
const s0 = pl.Series("a", [[3, 5, 6, 7, 8]]);
16581658
let actual = s0.lst.tail(1);
1659-
let expected = pl.Series("a", [8]);
1659+
let expected = pl.Series("a", [[8]]);
16601660
expect(actual.seriesEqual(expected));
16611661
actual = s0.lst.tail();
16621662
expected = pl.Series("a", [3, 5, 6, 7, 8]);

__tests__/io.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -404,20 +404,20 @@ describe("avro", () => {
404404
const actual = pl.readAvro(buf);
405405
expect(actual).toFrameEqual(expected);
406406
});
407-
test("read", () => {
408-
const df = pl.readAvro(avropath);
409-
expect(df.shape).toEqual({ height: 27, width: 4 });
407+
test("read:avro", () => {
408+
const df = pl.readAvro(avropath, { nRows: 4 });
409+
expect(df.shape).toEqual({ height: 4, width: 4 });
410410
});
411-
test("read:buffer", () => {
411+
test("read:avro:buffer", () => {
412412
const buff = fs.readFileSync(avropath);
413-
const df = pl.readAvro(buff);
414-
expect(df.shape).toEqual({ height: 27, width: 4 });
413+
const df = pl.readAvro(buff, { nRows: 4 });
414+
expect(df.shape).toEqual({ height: 4, width: 4 });
415415
});
416416

417-
test("read:compressed", () => {
418-
const csvDF = pl.readCSV(csvpath);
417+
test("read:avro:compressed", () => {
418+
const csvDF = pl.readCSV(csvpath, { nRows: 4 });
419419
csvDF.writeAvro(avropath, { compression: "snappy" });
420-
const df = pl.readAvro(avropath);
420+
const df = pl.readAvro(avropath, { nRows: 4 });
421421
expect(df).toFrameEqual(csvDF);
422422
});
423423

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
33
"linter": {
44
"enabled": true,
55
"rules": {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@
5454
"precommit": "yarn lint && yarn test"
5555
},
5656
"devDependencies": {
57-
"@biomejs/biome": "=1.9.3",
57+
"@biomejs/biome": "=1.9.4",
5858
"@napi-rs/cli": "^2.18.4",
5959
"@types/chance": "^1.1.6",
60-
"@types/jest": "^29.5.13",
61-
"@types/node": "^22.7.5",
60+
"@types/jest": "^29.5.14",
61+
"@types/node": "^22.8.6",
6262
"chance": "^1.1.12",
6363
"jest": "^29.7.0",
6464
"source-map-support": "^0.5.21",

polars/io.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export interface ReadCsvOptions {
2222
encoding: "utf8" | "utf8-lossy";
2323
numThreads: number;
2424
dtypes: Record<string, DataType>;
25-
sampleSize: number;
2625
lowMemory: boolean;
2726
commentChar: string;
2827
quoteChar: string;
@@ -44,7 +43,6 @@ const readCsvDefaultOptions: Partial<ReadCsvOptions> = {
4443
ignoreErrors: true,
4544
chunkSize: 10000,
4645
skipRows: 0,
47-
sampleSize: 1024,
4846
sep: ",",
4947
rechunk: false,
5048
encoding: "utf8",

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2024-09-19
1+
nightly-2024-10-28

src/conversion.rs

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use polars::frame::NullStrategy;
66
use polars::prelude::*;
77
use polars_core::series::ops::NullBehavior;
88
use polars_io::RowIndex;
9-
use std::any::Any;
109
use std::collections::HashMap;
1110

1211
#[derive(Debug)]
@@ -107,9 +106,7 @@ impl ToNapiValue for Wrap<&Series> {
107106
impl<'a> ToNapiValue for Wrap<AnyValue<'a>> {
108107
unsafe fn to_napi_value(env: sys::napi_env, val: Self) -> Result<sys::napi_value> {
109108
match val.0 {
110-
AnyValue::Null => {
111-
napi::bindgen_prelude::Null::to_napi_value(env, napi::bindgen_prelude::Null)
112-
}
109+
AnyValue::Null => napi::bindgen_prelude::Null::to_napi_value(env, napi::bindgen_prelude::Null),
113110
AnyValue::Boolean(b) => bool::to_napi_value(env, b),
114111
AnyValue::Int8(n) => i32::to_napi_value(env, n as i32),
115112
AnyValue::Int16(n) => i32::to_napi_value(env, n as i32),
@@ -156,15 +153,16 @@ impl<'a> ToNapiValue for Wrap<AnyValue<'a>> {
156153
AnyValue::List(ser) => Wrap::<&Series>::to_napi_value(env, Wrap(&ser)),
157154
ref av @ AnyValue::Struct(_, _, flds) => struct_dict(env, av._iter_struct_av(), flds),
158155
AnyValue::Array(ser, _) => Wrap::<&Series>::to_napi_value(env, Wrap(&ser)),
159-
AnyValue::Enum(_, _, _) => todo!(),
160-
AnyValue::Object(_) => todo!(),
161-
AnyValue::ObjectOwned(_) => todo!(),
162-
AnyValue::StructOwned(_) => todo!(),
163-
AnyValue::Binary(_) => todo!(),
164-
AnyValue::BinaryOwned(_) => todo!(),
165-
AnyValue::Decimal(_, _) => {
166-
Err(napi::Error::from_reason("Decimal is not a supported type in javascript, please convert to string or number before collecting to js"))
167-
}
156+
AnyValue::Enum(_, _, _) => Err(napi::Error::from_reason("Enum is not a supported, please convert to string or number before collecting to js")),
157+
AnyValue::Object(_) => Err(napi::Error::from_reason("Object is not a supported, please convert to string or number before collecting to js")),
158+
AnyValue::ObjectOwned(_) => Err(napi::Error::from_reason("ObjectOwned is not a supported, please convert to string or number before collecting to js")),
159+
AnyValue::StructOwned(_) => Err(napi::Error::from_reason("StructOwned is not a supported, please convert to string or number before collecting to js")),
160+
AnyValue::Binary(_) => Err(napi::Error::from_reason("Binary is not a supported, please convert to string or number before collecting to js")),
161+
AnyValue::BinaryOwned(_) => Err(napi::Error::from_reason("BinaryOwned is not a supported, please convert to string or number before collecting to js")),
162+
AnyValue::Decimal(_, _) => Err(napi::Error::from_reason("Decimal is not a supported type in javascript, please convert to string or number before collecting to js")),
163+
AnyValue::CategoricalOwned(_,_,_) => Err(napi::Error::from_reason("CategoricalOwned is not a supported, please convert to string or number before collecting to js")),
164+
AnyValue::DatetimeOwned(_,_,_) => Err(napi::Error::from_reason("DatetimeOwned is not a supported, please convert to string or number before collecting to js")),
165+
AnyValue::EnumOwned(_,_,_) => Err(napi::Error::from_reason("EnumOwned is not a supported, please convert to string or number before collecting to js")),
168166
}
169167
}
170168
}
@@ -293,25 +291,25 @@ impl FromNapiValue for Wrap<JsExpr> {
293291
}
294292
}
295293

296-
impl TypeName for Wrap<QuantileInterpolOptions> {
294+
impl TypeName for Wrap<QuantileMethod> {
297295
fn type_name() -> &'static str {
298-
"QuantileInterpolOptions"
296+
"QuantileMethod"
299297
}
300298

301299
fn value_type() -> ValueType {
302300
ValueType::Object
303301
}
304302
}
305303

306-
impl FromNapiValue for Wrap<QuantileInterpolOptions> {
304+
impl FromNapiValue for Wrap<QuantileMethod> {
307305
unsafe fn from_napi_value(env: sys::napi_env, napi_val: sys::napi_value) -> JsResult<Self> {
308306
let interpolation = String::from_napi_value(env, napi_val)?;
309307
let interpol = match interpolation.as_ref() {
310-
"nearest" => QuantileInterpolOptions::Nearest,
311-
"lower" => QuantileInterpolOptions::Lower,
312-
"higher" => QuantileInterpolOptions::Higher,
313-
"midpoint" => QuantileInterpolOptions::Midpoint,
314-
"linear" => QuantileInterpolOptions::Linear,
308+
"nearest" => QuantileMethod::Nearest,
309+
"lower" => QuantileMethod::Lower,
310+
"higher" => QuantileMethod::Higher,
311+
"midpoint" => QuantileMethod::Midpoint,
312+
"linear" => QuantileMethod::Linear,
315313
_ => return Err(napi::Error::from_reason("not supported".to_owned())),
316314
};
317315
Ok(Wrap(interpol))
@@ -524,9 +522,9 @@ impl From<JsRollingOptions> for RollingOptionsFixedWindow {
524522
weights: o.weights,
525523
min_periods: o.min_periods as usize,
526524
center: o.center,
527-
fn_params: Some(Arc::new(RollingVarParams {
525+
fn_params: Some(RollingFnParams::Var(RollingVarParams {
528526
ddof: o.ddof.unwrap_or(1),
529-
}) as Arc<dyn Any + Send + Sync>),
527+
})),
530528
..Default::default()
531529
}
532530
}
@@ -800,7 +798,9 @@ impl FromNapiValue for Wrap<SortOptions> {
800798
unsafe fn from_napi_value(env: sys::napi_env, napi_val: sys::napi_value) -> napi::Result<Self> {
801799
let obj = Object::from_napi_value(env, napi_val)?;
802800
let descending = obj.get::<_, bool>("descending")?.unwrap();
803-
let nulls_last = obj.get::<_, bool>("nulls_last")?.map_or(obj.get::<_, bool>("nullsLast")?.unwrap_or(false), |n| n);
801+
let nulls_last = obj
802+
.get::<_, bool>("nulls_last")?
803+
.map_or(obj.get::<_, bool>("nullsLast")?.unwrap_or(false), |n| n);
804804
let multithreaded = obj.get::<_, bool>("multithreaded")?.unwrap();
805805
let maintain_order: bool = obj.get::<_, bool>("maintain_order")?.unwrap();
806806
let options = SortOptions {
@@ -1007,9 +1007,14 @@ impl FromNapiValue for Wrap<NullValues> {
10071007
if let Ok(s) = String::from_napi_value(env, napi_val) {
10081008
Ok(Wrap(NullValues::AllColumnsSingle(s.into())))
10091009
} else if let Ok(s) = Vec::<String>::from_napi_value(env, napi_val) {
1010-
Ok(Wrap(NullValues::AllColumns(s.into_iter().map(PlSmallStr::from_string).collect())))
1010+
Ok(Wrap(NullValues::AllColumns(
1011+
s.into_iter().map(PlSmallStr::from_string).collect(),
1012+
)))
10111013
} else if let Ok(s) = HashMap::<String, String>::from_napi_value(env, napi_val) {
1012-
let null_values = s.into_iter().map(|a| (PlSmallStr::from_string(a.0), PlSmallStr::from_string(a.1))).collect::<Vec<(PlSmallStr, PlSmallStr)>>();
1014+
let null_values = s
1015+
.into_iter()
1016+
.map(|a| (PlSmallStr::from_string(a.0), PlSmallStr::from_string(a.1)))
1017+
.collect::<Vec<(PlSmallStr, PlSmallStr)>>();
10131018
Ok(Wrap(NullValues::Named(null_values)))
10141019
} else {
10151020
Err(
@@ -1024,9 +1029,14 @@ impl ToNapiValue for Wrap<NullValues> {
10241029
unsafe fn to_napi_value(env: sys::napi_env, val: Self) -> napi::Result<sys::napi_value> {
10251030
match val.0 {
10261031
NullValues::AllColumnsSingle(s) => String::to_napi_value(env, s.to_string()),
1027-
NullValues::AllColumns(arr) => Vec::<String>::to_napi_value(env, arr.iter().map(|x| x.to_string()).collect()),
1032+
NullValues::AllColumns(arr) => {
1033+
Vec::<String>::to_napi_value(env, arr.iter().map(|x| x.to_string()).collect())
1034+
}
10281035
NullValues::Named(obj) => {
1029-
let o: HashMap<String, String> = obj.into_iter().map(|s| (s.0.to_string(), s.1.to_string())).collect::<HashMap<String, String>>();
1036+
let o: HashMap<String, String> = obj
1037+
.into_iter()
1038+
.map(|s| (s.0.to_string(), s.1.to_string()))
1039+
.collect::<HashMap<String, String>>();
10301040
HashMap::<String, String>::to_napi_value(env, o)
10311041
}
10321042
}
@@ -1057,7 +1067,7 @@ impl FromJsUnknown for AnyValue<'_> {
10571067
let d: JsDate = unsafe { val.cast() };
10581068
let d = d.value_of()?;
10591069
let d = d as i64;
1060-
Ok(AnyValue::Datetime(d, TimeUnit::Milliseconds, &None))
1070+
Ok(AnyValue::Datetime(d, TimeUnit::Milliseconds, None))
10611071
} else {
10621072
Err(JsPolarsErr::Other("Unsupported Data type".to_owned()).into())
10631073
}
@@ -1236,7 +1246,10 @@ where
12361246
I: IntoIterator<Item = S>,
12371247
S: AsRef<str>,
12381248
{
1239-
container.into_iter().map(|s| PlSmallStr::from_str(s.as_ref())).collect()
1249+
container
1250+
.into_iter()
1251+
.map(|s| PlSmallStr::from_str(s.as_ref()))
1252+
.collect()
12401253
}
12411254

12421255
pub(crate) fn strings_to_selector<I, S>(container: I) -> Vec<Selector>

0 commit comments

Comments
 (0)