izveigor commented on code in PR #7044:
URL: https://github.com/apache/arrow-datafusion/pull/7044#discussion_r1269897138
##########
datafusion/core/tests/dataframe/mod.rs:
##########
@@ -1114,6 +1114,71 @@ async fn unnest_fixed_list() -> Result<()> {
Ok(())
}
+#[tokio::test]
+async fn unnest_fixed_list_nonull() -> Result<()> {
+ let mut shape_id_builder = UInt32Builder::new();
+ let mut tags_builder = FixedSizeListBuilder::new(StringBuilder::new(), 2);
+
+ for idx in 0..6 {
+ // Append shape id.
+ shape_id_builder.append_value(idx as u32 + 1);
+
+ tags_builder
+ .values()
+ .append_value(format!("tag{}1", idx + 1));
+ tags_builder
+ .values()
+ .append_value(format!("tag{}2", idx + 1));
+ tags_builder.append(true);
+ }
+
+ let batch = RecordBatch::try_from_iter(vec![
+ ("shape_id", Arc::new(shape_id_builder.finish()) as ArrayRef),
+ ("tags", Arc::new(tags_builder.finish()) as ArrayRef),
+ ])?;
+
+ let ctx = SessionContext::new();
+ ctx.register_batch("shapes", batch)?;
+ let df = ctx.table("shapes").await?;
+
+ let results = df.clone().collect().await?;
+ let expected = vec![
+ "+----------+----------------+",
+ "| shape_id | tags |",
+ "+----------+----------------+",
+ "| 1 | [tag11, tag12] |",
+ "| 2 | [tag21, tag22] |",
+ "| 3 | [tag31, tag32] |",
+ "| 4 | [tag41, tag42] |",
+ "| 5 | [tag51, tag52] |",
+ "| 6 | [tag61, tag62] |",
+ "+----------+----------------+",
+ ];
+ assert_batches_sorted_eq!(expected, &results);
+
+ let results = df.unnest_column("tags")?.collect().await?;
+ let expected = vec![
+ "+----------+-------+",
Review Comment:
That's correct test:
```
postgres=# select * from unnest_example2;
c1 | c2
----+---------------
1 | {tag11,tag12}
2 | {tag21,tag22}
3 | {tag31,tag32}
4 | {tag41,tag42}
5 | {tag51,tag52}
6 | {tag61,tag62}
(6 rows)
postgres=# select c1, unnest(c2) from unnest_example2;
c1 | unnest
----+--------
1 | tag11
1 | tag12
2 | tag21
2 | tag22
3 | tag31
3 | tag32
4 | tag41
4 | tag42
5 | tag51
5 | tag52
6 | tag61
6 | tag62
(12 rows)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]