Update polars to 0.27.2 (#8154)

Mostly to get rid of https://github.com/pola-rs/polars/pull/6098/files

This currently breaks nushell's table formatting:

```
nu ❯  open-df forcing.arrow | first
could not mmap compressed IPC file, defaulting to normal read╭───┬──────────┬────┬────────┬──────────┬───────┬──────────┬──────┬──────────┬─────╮
│ # │   time   │ id │ demand │ drainage │ E_pot │ infiltra │  P   │ priority │ ... │
│   │          │    │        │          │       │ tion     │      │          │     │
├───┼──────────┼────┼────────┼──────────┼───────┼──────────┼──────┼──────────┼─────┤
│ 0 │ 4 years  │  1 │   0.00 │     0.02 │  0.00 │     0.00 │ 0.00 │     4.00 │ ... │
│   │ ago      │    │        │          │       │          │      │          │     │
╰───┴──────────┴────┴────────┴──────────┴───────┴──────────┴──────┴──────────┴─────╯
```

@visr
This commit is contained in:
Hofer-Julian
2023-02-22 00:32:28 +01:00
committed by GitHub
parent 95ec2fcce7
commit 101ed629a4
9 changed files with 120 additions and 45 deletions

View File

@ -141,7 +141,7 @@ features = [
"to_dummies",
]
optional = true
version = "0.26.1"
version = "0.27.2"
[target.'cfg(windows)'.dependencies.windows]
features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_System_SystemServices"]

View File

@ -116,7 +116,7 @@ fn command(
let df = NuDataFrame::try_from_pipeline(input, call.head)?;
df.as_ref()
.to_dummies()
.to_dummies(None)
.map_err(|e| {
ShellError::GenericError(
"Error calculating dummies".into(),

View File

@ -145,6 +145,7 @@ fn from_parquet(
rechunk: false,
row_count: None,
low_memory: false,
cloud_options: None,
};
let df: NuLazyFrame = LazyFrame::scan_parquet(file, args)

View File

@ -30,7 +30,7 @@ impl SQLContext {
// Determine involved dataframe
// Implicit join require some more work in query parsers, Explicit join are preferred for now.
let tbl = select_stmt.from.get(0).ok_or_else(|| {
PolarsError::NotFound(ErrString::from("No table found in select statement"))
PolarsError::ComputeError(ErrString::from("No table found in select statement"))
})?;
let mut alias_map = HashMap::new();
let tbl_name = match &tbl.relation {
@ -39,7 +39,9 @@ impl SQLContext {
.0
.get(0)
.ok_or_else(|| {
PolarsError::NotFound(ErrString::from("No table found in select statement"))
PolarsError::ComputeError(ErrString::from(
"No table found in select statement",
))
})?
.value
.to_string();
@ -181,7 +183,7 @@ impl SQLContext {
} else {
let ast = ast
.get(0)
.ok_or_else(|| PolarsError::NotFound(ErrString::from("No statement found")))?;
.ok_or_else(|| PolarsError::ComputeError(ErrString::from("No statement found")))?;
Ok(match ast {
Statement::Query(query) => {
let rs = match &*query.body {

View File

@ -5,7 +5,7 @@ use nu_protocol::{
engine::{Command, EngineState, Stack},
Category, Example, PipelineData, ShellError, Signature, Span, Type, Value,
};
use polars::prelude::{IntoSeries, NewChunkedArray, UInt32Chunked};
use polars::prelude::{ArgAgg, IntoSeries, NewChunkedArray, UInt32Chunked};
#[derive(Clone)]
pub struct ArgMax;

View File

@ -5,7 +5,7 @@ use nu_protocol::{
engine::{Command, EngineState, Stack},
Category, Example, PipelineData, ShellError, Signature, Span, Type, Value,
};
use polars::prelude::{IntoSeries, NewChunkedArray, UInt32Chunked};
use polars::prelude::{ArgAgg, IntoSeries, NewChunkedArray, UInt32Chunked};
#[derive(Clone)]
pub struct ArgMin;

View File

@ -110,9 +110,16 @@ fn command(
})?;
let res = if not_exact {
casted.as_datetime_not_exact(Some(format.as_str()), TimeUnit::Milliseconds)
casted.as_datetime_not_exact(Some(format.as_str()), TimeUnit::Milliseconds, None)
} else {
casted.as_datetime(Some(format.as_str()), TimeUnit::Milliseconds, false, false)
casted.as_datetime(
Some(format.as_str()),
TimeUnit::Milliseconds,
false,
false,
true,
None,
)
};
let mut res = res

View File

@ -95,6 +95,7 @@ fn command(
let sort_options = SortOptions {
descending: call.has_flag("reverse"),
nulls_last: call.has_flag("nulls-last"),
multithreaded: true,
};
let mut res = df.as_series(call.head)?.argsort(sort_options).into_series();