Skip to content

Commit 6bfbc56

Browse files
committedOct 15, 2021
list fast-explode should be off when add null to list
1 parent 0599f60 commit 6bfbc56

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed
 

‎.github_changelog_generator

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
since-tag=py-polars-v0.8.18
1+
since-tag=py-polars-v0.10.1
22
future-release=v0.10.1
33
base=py-polars/CHANGELOG.md
44
output=AUTO_CHANGELOG.md

‎polars/polars-core/src/chunked_array/builder/mod.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,6 @@ where
420420
unsafe { values.extend_trusted_len_unchecked(iter) };
421421
self.builder.try_push_valid().unwrap();
422422
}
423-
424-
pub fn append_null(&mut self) {
425-
self.builder.push_null();
426-
}
427423
}
428424

429425
impl<T> ListBuilderTrait for ListPrimitiveChunkedBuilder<T>
@@ -436,14 +432,13 @@ where
436432
Some(s) => {
437433
self.append_series(s);
438434
}
439-
None => {
440-
self.builder.push_null();
441-
}
435+
None => self.append_null(),
442436
}
443437
}
444438

445439
#[inline]
446440
fn append_null(&mut self) {
441+
self.fast_explode = false;
447442
self.builder.push_null();
448443
}
449444

@@ -519,13 +514,14 @@ impl ListBuilderTrait for ListUtf8ChunkedBuilder {
519514
match opt_s {
520515
Some(s) => self.append_series(s),
521516
None => {
522-
self.builder.push_null();
517+
self.append_null();
523518
}
524519
}
525520
}
526521

527522
#[inline]
528523
fn append_null(&mut self) {
524+
self.fast_explode = false;
529525
self.builder.push_null();
530526
}
531527

@@ -583,13 +579,14 @@ impl ListBuilderTrait for ListBooleanChunkedBuilder {
583579
match opt_s {
584580
Some(s) => self.append_series(s),
585581
None => {
586-
self.builder.push_null();
582+
self.append_null();
587583
}
588584
}
589585
}
590586

591587
#[inline]
592588
fn append_null(&mut self) {
589+
self.fast_explode = false;
593590
self.builder.push_null();
594591
}
595592

@@ -684,6 +681,15 @@ mod test {
684681
let out = [&s1, &s2].iter().copied().collect::<ListChunked>();
685682
assert_eq!(out.get(0).unwrap().len(), 6);
686683
assert_eq!(out.get(1).unwrap().len(), 3);
684+
685+
let mut builder = ListPrimitiveChunkedBuilder::<Int32Type>::new("a", 10, 5);
686+
builder.append_series(&s1);
687+
builder.append_null();
688+
689+
let out = builder.finish();
690+
let out = out.explode().unwrap();
691+
assert_eq!(out.len(), 7);
692+
assert_eq!(out.get(6), AnyValue::Null);
687693
}
688694

689695
#[test]

0 commit comments

Comments
 (0)
Please sign in to comment.