Skip to content

Commit

Permalink
Upgrading to rs 0.39 (#196)
Browse files Browse the repository at this point in the history
* Upgrading to rs 0.38

* Updating yarn lock
  • Loading branch information
Bidek56 committed Apr 16, 2024
1 parent a6ab81a commit 6c39439
Show file tree
Hide file tree
Showing 18 changed files with 167 additions and 158 deletions.
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-02-23
toolchain: nightly-2024-03-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 @@ -18,7 +18,7 @@ jobs:
- name: Install latest Rust nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2024-02-23
toolchain: nightly-2024-03-28
components: rustfmt, clippy
- run: yarn --version
- name: Install Node Dependencies
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Install latest Rust nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2024-02-23
toolchain: nightly-2024-03-28
components: rustfmt, clippy
- name: Bun version
uses: oven-sh/setup-bun@v1
Expand Down
20 changes: 9 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ repository = "https://github.com/pola-rs/nodejs-polars"
crate-type = ["cdylib", "lib"]

[dependencies]
ahash = "0.8.7"
ahash = "0.8.11"
bincode = "1.3.3"
napi = { version = "2.16.1", default-features = false, features = [
napi = { version = "2.16.2", default-features = false, features = [
"napi8",
"serde-json",
] }
napi-derive = { version = "2.16.1", default-features = false }
polars-core = { git = "https://github.com/pola-rs/polars.git", rev = "3e2cab8de39b2721ce3830c3958b3b0796b32258", default-features = false }
polars-io = { git = "https://github.com/pola-rs/polars.git", rev = "3e2cab8de39b2721ce3830c3958b3b0796b32258", default-features = false }
polars-lazy = { git = "https://github.com/pola-rs/polars.git", rev = "3e2cab8de39b2721ce3830c3958b3b0796b32258", default-features = false }
napi-derive = { version = "2.16.2", default-features = false }
polars-core = { git = "https://github.com/pola-rs/polars.git", rev = "37c630320da0d0d3270d283cdafbf6b8402de069", default-features = false }
polars-io = { git = "https://github.com/pola-rs/polars.git", rev = "37c630320da0d0d3270d283cdafbf6b8402de069", default-features = false }
polars-lazy = { git = "https://github.com/pola-rs/polars.git", rev = "37c630320da0d0d3270d283cdafbf6b8402de069", default-features = false }
thiserror = "1"
smartstring = { version = "1" }
serde_json = { version = "1" }
either = "1.10.0"
either = "1.11.0"

[dependencies.polars]
features = [
Expand Down Expand Up @@ -91,7 +91,6 @@ features = [
"peaks",
"string_pad",
"cov",
"group_by_list",
"sql",
"binary_encoding",
"rolling_window",
Expand Down Expand Up @@ -154,18 +153,17 @@ features = [
"peaks",
"string_pad",
"cov",
"group_by_list",
"http",
"cloud",
"aws",
"gcp",
"azure"
]
git = "https://github.com/pola-rs/polars.git"
rev = "3e2cab8de39b2721ce3830c3958b3b0796b32258"
rev = "37c630320da0d0d3270d283cdafbf6b8402de069"

[build-dependencies]
napi-build = "2.1.2"
napi-build = "2.1.3"

[profile.release]
codegen-units = 1
Expand Down
Binary file removed bun.lockb
Binary file not shown.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@
"precommit": "yarn lint && yarn test"
},
"devDependencies": {
"@biomejs/biome": "^1.6.3",
"@napi-rs/cli": "^2.18.0",
"@biomejs/biome": "^1.6.4",
"@napi-rs/cli": "^2.18.1",
"@types/chance": "^1.1.6",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.30",
"@types/node": "^20.12.7",
"chance": "^1.1.11",
"jest": "^29.7.0",
"source-map-support": "^0.5.21",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typedoc": "^0.25.12",
"typescript": "5.4.3"
"typedoc": "^0.25.13",
"typescript": "5.4.5"
},
"packageManager": "yarn@4.0.2",
"workspaces": [
Expand Down
4 changes: 1 addition & 3 deletions polars/dataframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2337,7 +2337,6 @@ export const _DataFrame = (_df: any): DataFrame => {
if (typeof opts === "number") {
return wrap("slice", opts, length);
}

return wrap("slice", opts.offset, opts.length);
},
sort(arg, descending = false, maintain_order = false) {
Expand All @@ -2350,8 +2349,7 @@ export const _DataFrame = (_df: any): DataFrame => {
.sort(arg, descending, maintain_order)
.collectSync({ noOptimization: true, stringCache: false });
}

return wrap("sort", arg, descending, maintain_order, true, false);
return wrap("sort", arg, descending, true, maintain_order);
},
std() {
return this.lazy().std().collectSync();
Expand Down
1 change: 0 additions & 1 deletion polars/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ interface ScanParquetOptions {
rechunk?: boolean;
lowMemory?: boolean;
useStatistics?: boolean;
hivePartitioning?: boolean;
cloudOptions?: Map<string, string>;
retries?: number;
}
Expand Down
6 changes: 2 additions & 4 deletions polars/lazy/dataframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -962,12 +962,10 @@ export const _LazyDataFrame = (_ldf: any): LazyDataFrame => {
return this.sort(arg.by, arg.descending, arg.maintain_order);
}
if (typeof arg === "string") {
return wrap("sort", arg, descending, maintain_order, true, false);
return wrap("sort", arg, descending, true, maintain_order);
}
descending = [descending].flat(3) as any;
const by = selectionToExprList(arg, false);

return wrap("sortByExprs", by, descending, maintain_order, true);
return wrap("sortByExprs", by, descending, true, maintain_order);
},
std() {
return _LazyDataFrame(_ldf.std());
Expand Down
4 changes: 2 additions & 2 deletions polars/lazy/expr/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export const ExprListFunctions = (_expr: any): ExprList => {
},
get(index: number | Expr) {
if (Expr.isExpr(index)) {
return wrap("listGet", index._expr);
return wrap("listGet", index._expr, true);
}
return wrap("listGet", pli.lit(index));
return wrap("listGet", pli.lit(index), true);
},
head(n = 5) {
return this.slice(0, n);
Expand Down
1 change: 0 additions & 1 deletion polars/series/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,6 @@ export function _Series(_s: any): Series {
},
sort(options?) {
options = { descending: false, nullsLast: false, ...(options ?? {}) };

return wrap("sort", options.descending, options.nullsLast);
},
sub(field) {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2024-02-23
nightly-2024-03-28
2 changes: 1 addition & 1 deletion src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ pub struct WriteCsvOptions {
pub date_format: Option<String>,
pub time_format: Option<String>,
pub float_precision: Option<i64>,
pub null_value: Option<String>
pub null_value: Option<String>,
}

#[napi(object)]
Expand Down
28 changes: 16 additions & 12 deletions src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,19 +773,16 @@ impl JsDataFrame {
by_column: String,
descending: bool,
nulls_last: bool,
multithreaded: bool,
maintain_order: bool,
) -> napi::Result<JsDataFrame> {
let df = self
.df
.sort_with_options(
&by_column,
SortOptions {
descending,
nulls_last,
multithreaded,
maintain_order,
},
.sort(
[&by_column],
SortMultipleOptions::default()
.with_order_descending(descending)
.with_nulls_last(nulls_last)
.with_maintain_order(maintain_order),
)
.map_err(JsPolarsErr::from)?;
Ok(JsDataFrame::new(df))
Expand All @@ -798,7 +795,12 @@ impl JsDataFrame {
maintain_order: bool,
) -> napi::Result<()> {
self.df
.sort_in_place([&by_column], descending, maintain_order)
.sort_in_place(
[&by_column],
SortMultipleOptions::default()
.with_order_descending(descending)
.with_maintain_order(maintain_order),
)
.map_err(JsPolarsErr::from)?;
Ok(())
}
Expand Down Expand Up @@ -1321,8 +1323,10 @@ impl JsDataFrame {
let time_format = options.time_format;
let datetime_format = options.datetime_format;
let float_precision: Option<usize> = options.float_precision.map(|fp| fp as usize);
let null_value = options.null_value.unwrap_or(SerializeOptions::default().null);

let null_value = options
.null_value
.unwrap_or(SerializeOptions::default().null);

match path_or_buffer.get_type()? {
ValueType::String => {
let path: napi::JsString = unsafe { path_or_buffer.cast() };
Expand Down
49 changes: 27 additions & 22 deletions src/lazy/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::dataframe::JsDataFrame;
use crate::prelude::*;
use polars::prelude::{col, lit, ClosedWindow, JoinType};
use polars_io::cloud::CloudOptions;
use polars_io::RowIndex;
use polars_io::{HiveOptions, RowIndex};
use std::collections::HashMap;
use std::num::NonZeroUsize;
use std::path::PathBuf;
Expand Down Expand Up @@ -134,34 +134,37 @@ impl JsLazyFrame {
pub fn sort(
&self,
by_column: String,
reverse: bool,
descending: bool,
nulls_last: bool,
multithreaded: bool,
maintain_order: bool,
) -> JsLazyFrame {
let ldf = self.ldf.clone();
ldf.sort(
&by_column,
SortOptions {
descending: reverse,
nulls_last,
multithreaded,
maintain_order,
},
[&by_column],
SortMultipleOptions::default()
.with_order_descending(descending)
.with_nulls_last(nulls_last)
.with_maintain_order(maintain_order),
)
.into()
}
#[napi(catch_unwind)]
pub fn sort_by_exprs(
&self,
by_column: Vec<&JsExpr>,
reverse: Vec<bool>,
descending: bool,
nulls_last: bool,
maintain_order: bool,
) -> JsLazyFrame {
let ldf = self.ldf.clone();
ldf.sort_by_exprs(by_column.to_exprs(), reverse, nulls_last, maintain_order)
.into()
ldf.sort_by_exprs(
by_column.to_exprs(),
SortMultipleOptions::default()
.with_order_descending(descending)
.with_nulls_last(nulls_last)
.with_maintain_order(maintain_order),
)
.into()
}
#[napi(catch_unwind)]
pub fn cache(&self) -> JsLazyFrame {
Expand Down Expand Up @@ -229,7 +232,7 @@ impl JsLazyFrame {
let closed_window = closed.0;
let ldf = self.ldf.clone();
let by = by.to_exprs();
let lazy_gb = ldf.group_by_rolling(
let lazy_gb = ldf.rolling(
index_column.inner.clone(),
by,
RollingGroupOptions {
Expand Down Expand Up @@ -711,8 +714,7 @@ pub struct ScanParquetOptions {
pub rechunk: Option<bool>,
pub low_memory: Option<bool>,
pub use_statistics: Option<bool>,
pub hive_partitioning: Option<bool>,
pub cloud_options: Option<HashMap::<String, String>>,
pub cloud_options: Option<HashMap<String, String>>,
pub retries: Option<i64>,
}

Expand All @@ -725,14 +727,14 @@ pub fn scan_parquet(path: String, options: ScanParquetOptions) -> napi::Result<J
let rechunk = options.rechunk.unwrap_or(false);
let low_memory = options.low_memory.unwrap_or(false);
let use_statistics = options.use_statistics.unwrap_or(false);

let mut cloud_options: Option<CloudOptions> = if let Some(o) = options.cloud_options {
let co: Vec<(String, String)> = o.into_iter().map(|kv: (String, String)| kv).collect();
Some(CloudOptions::from_untyped_config(&path, co).map_err(JsPolarsErr::from)?)
} else {
None
};

let retries = options.retries.unwrap_or_else(|| 2) as usize;
if retries > 0 {
cloud_options =
Expand All @@ -744,7 +746,6 @@ pub fn scan_parquet(path: String, options: ScanParquetOptions) -> napi::Result<J
});
}

let hive_partitioning: bool = options.hive_partitioning.unwrap_or(false);
let args = ScanArgsParquet {
n_rows,
cache,
Expand All @@ -754,7 +755,11 @@ pub fn scan_parquet(path: String, options: ScanParquetOptions) -> napi::Result<J
low_memory,
cloud_options,
use_statistics,
hive_partitioning,
// TODO: Support Hive partitioning.
hive_options: HiveOptions {
enabled: false,
..Default::default()
},
};
let lf = LazyFrame::scan_parquet(path, args).map_err(JsPolarsErr::from)?;
Ok(lf.into())
Expand All @@ -774,14 +779,14 @@ pub fn scan_ipc(path: String, options: ScanIPCOptions) -> napi::Result<JsLazyFra
let n_rows = options.n_rows.map(|i| i as usize);
let cache = options.cache.unwrap_or(true);
let rechunk = options.rechunk.unwrap_or(false);
let memmap = options.memmap.unwrap_or(true);
let memory_map = options.memmap.unwrap_or(true);
let row_index: Option<RowIndex> = options.row_count.map(|rc| rc.into());
let args = ScanArgsIpc {
n_rows,
cache,
rechunk,
row_index,
memmap,
memory_map,
cloud_options: Default::default(),
};
let lf = LazyFrame::scan_ipc(path, args).map_err(JsPolarsErr::from)?;
Expand Down
Loading

0 comments on commit 6c39439

Please sign in to comment.