Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to rs-0.44.2 #291

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install latest Rust nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2024-09-19
toolchain: nightly-2024-10-28
components: rustfmt, clippy
- name: Install ghp-import
uses: actions/setup-python@v5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install latest Rust nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2024-09-19
toolchain: nightly-2024-10-28
components: rustfmt, clippy
- name: Check yarn version
run: yarn --version
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Install latest Rust nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2024-09-19
toolchain: nightly-2024-10-28
components: rustfmt, clippy
- name: Bun version
uses: oven-sh/setup-bun@v1
Expand Down
15 changes: 7 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ crate-type = ["cdylib", "lib"]
[dependencies]
ahash = "0.8.11"
bincode = "1.3.3"
napi = { version = "2.16.9", default-features = false, features = [
napi = { version = "2.16.13", default-features = false, features = [
"napi8",
"serde-json",
] }
napi-derive = { version = "2.16.11", default-features = false }
polars-core = { git = "https://github.com/pola-rs/polars.git", rev = "54218e7e35e3defd4b0801e820c56eea6b91e525", default-features = false }
polars-io = { git = "https://github.com/pola-rs/polars.git", rev = "54218e7e35e3defd4b0801e820c56eea6b91e525", default-features = false }
polars-lazy = { git = "https://github.com/pola-rs/polars.git", rev = "54218e7e35e3defd4b0801e820c56eea6b91e525", default-features = false }
napi-derive = { version = "2.16.12", default-features = false }
polars-core = { git = "https://github.com/pola-rs/polars.git", rev = "2dce3d3b5c80ae7522a3435f844fac8fed9dc9e8", default-features = false }
polars-io = { git = "https://github.com/pola-rs/polars.git", rev = "2dce3d3b5c80ae7522a3435f844fac8fed9dc9e8", default-features = false }
polars-lazy = { git = "https://github.com/pola-rs/polars.git", rev = "2dce3d3b5c80ae7522a3435f844fac8fed9dc9e8", default-features = false }
thiserror = "1"
smartstring = { version = "1" }
serde_json = { version = "1" }
either = "1.13.0"
hashbrown = {version = "=0.14.5", features = ["raw"]}
hashbrown = { version = "0.15.0", features = ["rayon", "serde"] }

[dependencies.polars]
features = [
Expand Down Expand Up @@ -86,7 +86,6 @@ features = [
"to_dummies",
"ipc",
"ipc_streaming",
"avro",
"list_eval",
"arg_where",
"timezones",
Expand Down Expand Up @@ -163,7 +162,7 @@ features = [
"azure"
]
git = "https://github.com/pola-rs/polars.git"
rev = "54218e7e35e3defd4b0801e820c56eea6b91e525"
rev = "2dce3d3b5c80ae7522a3435f844fac8fed9dc9e8"

[build-dependencies]
napi-build = "2.1.3"
Expand Down
4 changes: 2 additions & 2 deletions __tests__/expr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ describe("expr.lst", () => {
test("head", () => {
const s0 = pl.Series("a", [[3, 5, 6, 7, 8]]);
let actual = s0.lst.head(1);
let expected = pl.Series("a", [3]);
let expected = pl.Series("a", [[3]]);
expect(actual.seriesEqual(expected));
actual = s0.lst.head();
expected = pl.Series("a", [3, 5, 6, 7, 8]);
Expand All @@ -1656,7 +1656,7 @@ describe("expr.lst", () => {
test("tail", () => {
const s0 = pl.Series("a", [[3, 5, 6, 7, 8]]);
let actual = s0.lst.tail(1);
let expected = pl.Series("a", [8]);
let expected = pl.Series("a", [[8]]);
expect(actual.seriesEqual(expected));
actual = s0.lst.tail();
expected = pl.Series("a", [3, 5, 6, 7, 8]);
Expand Down
18 changes: 9 additions & 9 deletions __tests__/io.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,20 +404,20 @@ describe("avro", () => {
const actual = pl.readAvro(buf);
expect(actual).toFrameEqual(expected);
});
test("read", () => {
const df = pl.readAvro(avropath);
expect(df.shape).toEqual({ height: 27, width: 4 });
test("read:avro", () => {
const df = pl.readAvro(avropath, { nRows: 4 });
expect(df.shape).toEqual({ height: 4, width: 4 });
});
test("read:buffer", () => {
test("read:avro:buffer", () => {
const buff = fs.readFileSync(avropath);
const df = pl.readAvro(buff);
expect(df.shape).toEqual({ height: 27, width: 4 });
const df = pl.readAvro(buff, { nRows: 4 });
expect(df.shape).toEqual({ height: 4, width: 4 });
});

test("read:compressed", () => {
const csvDF = pl.readCSV(csvpath);
test("read:avro:compressed", () => {
const csvDF = pl.readCSV(csvpath, { nRows: 4 });
csvDF.writeAvro(avropath, { compression: "snappy" });
const df = pl.readAvro(avropath);
const df = pl.readAvro(avropath, { nRows: 4 });
expect(df).toFrameEqual(csvDF);
});

Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"linter": {
"enabled": true,
"rules": {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
"precommit": "yarn lint && yarn test"
},
"devDependencies": {
"@biomejs/biome": "=1.9.3",
"@biomejs/biome": "=1.9.4",
"@napi-rs/cli": "^2.18.4",
"@types/chance": "^1.1.6",
"@types/jest": "^29.5.13",
"@types/node": "^22.7.5",
"@types/jest": "^29.5.14",
"@types/node": "^22.8.6",
"chance": "^1.1.12",
"jest": "^29.7.0",
"source-map-support": "^0.5.21",
Expand Down
2 changes: 0 additions & 2 deletions polars/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export interface ReadCsvOptions {
encoding: "utf8" | "utf8-lossy";
numThreads: number;
dtypes: Record<string, DataType>;
sampleSize: number;
lowMemory: boolean;
commentChar: string;
quoteChar: string;
Expand All @@ -44,7 +43,6 @@ const readCsvDefaultOptions: Partial<ReadCsvOptions> = {
ignoreErrors: true,
chunkSize: 10000,
skipRows: 0,
sampleSize: 1024,
sep: ",",
rechunk: false,
encoding: "utf8",
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2024-09-19
nightly-2024-10-28
53 changes: 35 additions & 18 deletions src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use polars::frame::NullStrategy;
use polars::prelude::*;
use polars_core::series::ops::NullBehavior;
use polars_io::RowIndex;
use std::any::Any;
use std::collections::HashMap;

#[derive(Debug)]
Expand Down Expand Up @@ -165,6 +164,9 @@ impl<'a> ToNapiValue for Wrap<AnyValue<'a>> {
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"))
}
AnyValue::CategoricalOwned(_,_,_) => todo!(),
AnyValue::DatetimeOwned(_,_,_) => todo!(),
AnyValue::EnumOwned(_,_,_) => todo!(),
}
}
}
Expand Down Expand Up @@ -293,25 +295,25 @@ impl FromNapiValue for Wrap<JsExpr> {
}
}

impl TypeName for Wrap<QuantileInterpolOptions> {
impl TypeName for Wrap<QuantileMethod> {
fn type_name() -> &'static str {
"QuantileInterpolOptions"
"QuantileMethod"
}

fn value_type() -> ValueType {
ValueType::Object
}
}

impl FromNapiValue for Wrap<QuantileInterpolOptions> {
impl FromNapiValue for Wrap<QuantileMethod> {
unsafe fn from_napi_value(env: sys::napi_env, napi_val: sys::napi_value) -> JsResult<Self> {
let interpolation = String::from_napi_value(env, napi_val)?;
let interpol = match interpolation.as_ref() {
"nearest" => QuantileInterpolOptions::Nearest,
"lower" => QuantileInterpolOptions::Lower,
"higher" => QuantileInterpolOptions::Higher,
"midpoint" => QuantileInterpolOptions::Midpoint,
"linear" => QuantileInterpolOptions::Linear,
"nearest" => QuantileMethod::Nearest,
"lower" => QuantileMethod::Lower,
"higher" => QuantileMethod::Higher,
"midpoint" => QuantileMethod::Midpoint,
"linear" => QuantileMethod::Linear,
_ => return Err(napi::Error::from_reason("not supported".to_owned())),
};
Ok(Wrap(interpol))
Expand Down Expand Up @@ -524,9 +526,9 @@ impl From<JsRollingOptions> for RollingOptionsFixedWindow {
weights: o.weights,
min_periods: o.min_periods as usize,
center: o.center,
fn_params: Some(Arc::new(RollingVarParams {
fn_params: Some(RollingFnParams::Var(RollingVarParams {
ddof: o.ddof.unwrap_or(1),
}) as Arc<dyn Any + Send + Sync>),
})),
..Default::default()
}
}
Expand Down Expand Up @@ -800,7 +802,9 @@ impl FromNapiValue for Wrap<SortOptions> {
unsafe fn from_napi_value(env: sys::napi_env, napi_val: sys::napi_value) -> napi::Result<Self> {
let obj = Object::from_napi_value(env, napi_val)?;
let descending = obj.get::<_, bool>("descending")?.unwrap();
let nulls_last = obj.get::<_, bool>("nulls_last")?.map_or(obj.get::<_, bool>("nullsLast")?.unwrap_or(false), |n| n);
let nulls_last = obj
.get::<_, bool>("nulls_last")?
.map_or(obj.get::<_, bool>("nullsLast")?.unwrap_or(false), |n| n);
let multithreaded = obj.get::<_, bool>("multithreaded")?.unwrap();
let maintain_order: bool = obj.get::<_, bool>("maintain_order")?.unwrap();
let options = SortOptions {
Expand Down Expand Up @@ -1007,9 +1011,14 @@ impl FromNapiValue for Wrap<NullValues> {
if let Ok(s) = String::from_napi_value(env, napi_val) {
Ok(Wrap(NullValues::AllColumnsSingle(s.into())))
} else if let Ok(s) = Vec::<String>::from_napi_value(env, napi_val) {
Ok(Wrap(NullValues::AllColumns(s.into_iter().map(PlSmallStr::from_string).collect())))
Ok(Wrap(NullValues::AllColumns(
s.into_iter().map(PlSmallStr::from_string).collect(),
)))
} else if let Ok(s) = HashMap::<String, String>::from_napi_value(env, napi_val) {
let null_values = s.into_iter().map(|a| (PlSmallStr::from_string(a.0), PlSmallStr::from_string(a.1))).collect::<Vec<(PlSmallStr, PlSmallStr)>>();
let null_values = s
.into_iter()
.map(|a| (PlSmallStr::from_string(a.0), PlSmallStr::from_string(a.1)))
.collect::<Vec<(PlSmallStr, PlSmallStr)>>();
Ok(Wrap(NullValues::Named(null_values)))
} else {
Err(
Expand All @@ -1024,9 +1033,14 @@ impl ToNapiValue for Wrap<NullValues> {
unsafe fn to_napi_value(env: sys::napi_env, val: Self) -> napi::Result<sys::napi_value> {
match val.0 {
NullValues::AllColumnsSingle(s) => String::to_napi_value(env, s.to_string()),
NullValues::AllColumns(arr) => Vec::<String>::to_napi_value(env, arr.iter().map(|x| x.to_string()).collect()),
NullValues::AllColumns(arr) => {
Vec::<String>::to_napi_value(env, arr.iter().map(|x| x.to_string()).collect())
}
NullValues::Named(obj) => {
let o: HashMap<String, String> = obj.into_iter().map(|s| (s.0.to_string(), s.1.to_string())).collect::<HashMap<String, String>>();
let o: HashMap<String, String> = obj
.into_iter()
.map(|s| (s.0.to_string(), s.1.to_string()))
.collect::<HashMap<String, String>>();
HashMap::<String, String>::to_napi_value(env, o)
}
}
Expand Down Expand Up @@ -1057,7 +1071,7 @@ impl FromJsUnknown for AnyValue<'_> {
let d: JsDate = unsafe { val.cast() };
let d = d.value_of()?;
let d = d as i64;
Ok(AnyValue::Datetime(d, TimeUnit::Milliseconds, &None))
Ok(AnyValue::Datetime(d, TimeUnit::Milliseconds, None))
} else {
Err(JsPolarsErr::Other("Unsupported Data type".to_owned()).into())
}
Expand Down Expand Up @@ -1236,7 +1250,10 @@ where
I: IntoIterator<Item = S>,
S: AsRef<str>,
{
container.into_iter().map(|s| PlSmallStr::from_str(s.as_ref())).collect()
container
.into_iter()
.map(|s| PlSmallStr::from_str(s.as_ref()))
.collect()
}

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