Skip to content

Commit

Permalink
fix(rust, python): empty concat utf8 (#5768)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Dec 10, 2022
1 parent 88317c7 commit 2855a88
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions polars/polars-core/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub fn concat_str(s: &[Series], delimiter: &str) -> PolarsResult<Utf8Chunked> {
"expected multiple series in concat_str function".into(),
));
}
if s[0].is_empty() {
if s.iter().any(|s| s.is_empty()) {
return Ok(Utf8Chunked::full_null(s[0].name(), 0));
}

Expand All @@ -165,7 +165,7 @@ pub fn concat_str(s: &[Series], delimiter: &str) -> PolarsResult<Utf8Chunked> {

if !s.iter().all(|s| s.len() == 1 || s.len() == len) {
return Err(PolarsError::ComputeError(
"all series in concat_str function should have equal length or unit length".into(),
"All series in concat_str function should have equal length or unit length".into(),
));
}
let mut iters = cas
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "pivot")]
pub mod pivot;
#[cfg(feature = "to_dummies")]
use polars_core::export::rayon::prelude::*;
use polars_core::prelude::*;
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions polars/polars-ops/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
mod chunked_array;
mod frame;
#[cfg(feature = "pivot")]
pub mod pivot;
pub use frame::pivot;
mod frame;
pub mod prelude;
mod series;
10 changes: 10 additions & 0 deletions py-polars/tests/unit/test_empty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import polars as pl


def test_empty_str_concat_lit() -> None:
df = pl.DataFrame({"a": [], "b": []}, columns=[("a", pl.Utf8), ("b", pl.Utf8)])
assert df.with_column(pl.lit("asd") + pl.col("a")).schema == {
"a": pl.Utf8,
"b": pl.Utf8,
"literal": pl.Utf8,
}

0 comments on commit 2855a88

Please sign in to comment.