This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 9fba34d557 Fix: array list values are leaked on nested `unnest`
operators (#10689)
9fba34d557 is described below
commit 9fba34d557bee2ca13b12ef6767c686a456cf958
Author: Duong Cong Toai <[email protected]>
AuthorDate: Tue May 28 15:30:48 2024 +0200
Fix: array list values are leaked on nested `unnest` operators (#10689)
* chore: fix issue + add test
* simplify test case
---
datafusion/physical-plan/src/unnest.rs | 14 ++++----------
datafusion/sqllogictest/test_files/unnest.slt | 9 +++++++++
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/datafusion/physical-plan/src/unnest.rs
b/datafusion/physical-plan/src/unnest.rs
index 0685903cb7..e072b214fd 100644
--- a/datafusion/physical-plan/src/unnest.rs
+++ b/datafusion/physical-plan/src/unnest.rs
@@ -515,16 +515,10 @@ fn unnest_list_arrays(
})
.collect::<Result<Vec<_>>>()?;
- // If there is only one list column to unnest and it doesn't contain any
NULL lists,
- // we can return the values array directly without any copying.
- if typed_arrays.len() == 1 && typed_arrays[0].null_count() == 0 {
- Ok(vec![typed_arrays[0].values().clone()])
- } else {
- typed_arrays
- .iter()
- .map(|list_array| unnest_list_array(*list_array, length_array,
capacity))
- .collect::<Result<_>>()
- }
+ typed_arrays
+ .iter()
+ .map(|list_array| unnest_list_array(*list_array, length_array,
capacity))
+ .collect::<Result<_>>()
}
/// Unnest a list array according the target length array.
diff --git a/datafusion/sqllogictest/test_files/unnest.slt
b/datafusion/sqllogictest/test_files/unnest.slt
index fd8e331ab5..bdd7e6631c 100644
--- a/datafusion/sqllogictest/test_files/unnest.slt
+++ b/datafusion/sqllogictest/test_files/unnest.slt
@@ -449,5 +449,14 @@ select sum(unnest(generate_series(1,10)));
query error DataFusion error: Internal error: unnest on struct can ony be
applied at the root level of select expression
select arrow_typeof(unnest(column5)) from unnest_table;
+
+## unnest from a result of a logical plan with limit and offset
+query I
+select unnest(column1) from (select * from (values([1,2,3]), ([4,5,6])) limit
1 offset 1);
+----
+4
+5
+6
+
statement ok
drop table unnest_table;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]