Skip to content

Commit

Permalink
Updated Polars to 0.39.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Apr 14, 2024
1 parent 789a803 commit be17aaa
Show file tree
Hide file tree
Showing 22 changed files with 354 additions and 204 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 0.9.1 (unreleased)
## 0.10.0 (unreleased)

- Updated Polars to 0.38.3
- Updated Polars to 0.39.0
- Added support for writing JSON to string
- Added support for writing Parquet to `StringIO`
- Added support for cross joins
Expand Down
111 changes: 78 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions ext/polars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ ahash = "0.8"
chrono = "0.4"
either = "1.8"
magnus = "0.6"
polars-core = "=0.38.3"
polars-parquet = "=0.38.3"
polars-utils = "=0.38.3"
polars-core = "=0.39.0"
polars-parquet = "=0.39.0"
polars-utils = "=0.39.0"
serde_json = "1"
smartstring = "1"

[dependencies.polars]
version = "=0.38.3"
version = "=0.39.0"
features = [
"abs",
"approx_unique",
Expand Down
5 changes: 3 additions & 2 deletions ext/polars/src/conversion/anyvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use magnus::{
class, prelude::*, r_hash::ForEach, Float, Integer, IntoValue, RArray, RHash, RString, Ruby,
TryConvert, Value,
};
use polars::frame::row::any_values_to_dtype;
use polars::prelude::*;
use polars_core::utils::any_values_to_supertype_and_n_dtypes;

use super::{struct_dict, ObjectValue, Wrap};

Expand Down Expand Up @@ -120,7 +120,8 @@ impl<'s> TryConvert for Wrap<AnyValue<'s>> {
avs.push(Wrap::<AnyValue>::try_convert(item?)?.0)
}

let (dtype, _n_types) = any_values_to_dtype(&avs).map_err(RbPolarsErr::from)?;
let (dtype, _n_types) =
any_values_to_supertype_and_n_dtypes(&avs).map_err(RbPolarsErr::from)?;

// push the rest
avs.reserve(list.len());
Expand Down
8 changes: 6 additions & 2 deletions ext/polars/src/expr/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ impl RbExpr {
self.inner.clone().arr().arg_max().into()
}

pub fn arr_get(&self, index: &RbExpr) -> Self {
self.inner.clone().arr().get(index.inner.clone()).into()
pub fn arr_get(&self, index: &RbExpr, null_on_oob: bool) -> Self {
self.inner
.clone()
.arr()
.get(index.inner.clone(), null_on_oob)
.into()
}

pub fn arr_join(&self, separator: &RbExpr, ignore_nulls: bool) -> Self {
Expand Down
25 changes: 22 additions & 3 deletions ext/polars/src/expr/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl RbExpr {
pub fn sort_with(&self, descending: bool, nulls_last: bool) -> Self {
self.clone()
.inner
.sort_with(SortOptions {
.sort(SortOptions {
descending,
nulls_last,
multithreaded: true,
Expand Down Expand Up @@ -323,9 +323,28 @@ impl RbExpr {
self.clone().inner.gather(idx.inner.clone()).into()
}

pub fn sort_by(&self, by: RArray, reverse: Vec<bool>) -> RbResult<Self> {
pub fn sort_by(
&self,
by: RArray,
descending: Vec<bool>,
nulls_last: bool,
multithreaded: bool,
maintain_order: bool,
) -> RbResult<Self> {
let by = rb_exprs_to_exprs(by)?;
Ok(self.clone().inner.sort_by(by, reverse).into())
Ok(self
.clone()
.inner
.sort_by(
by,
SortMultipleOptions {
descending,
nulls_last,
multithreaded,
maintain_order,
},
)
.into())
}

pub fn backward_fill(&self, limit: FillNullLimit) -> Self {
Expand Down
Loading

0 comments on commit be17aaa

Please sign in to comment.