alamb commented on code in PR #7168:
URL: https://github.com/apache/arrow-datafusion/pull/7168#discussion_r1280690763
##########
datafusion/core/src/dataframe.rs:
##########
@@ -151,20 +151,38 @@ impl DataFrame {
/// Expand each list element of a column to multiple rows.
///
+ /// Seee also:
+ ///
+ /// 1. [`UnnestOptions`] documentation for the behavior of `unnest`
+ /// 2. [`Self::unnest_column_with_options`]
+ ///
/// ```
/// # use datafusion::prelude::*;
/// # use datafusion::error::Result;
/// # #[tokio::main]
/// # async fn main() -> Result<()> {
/// let ctx = SessionContext::new();
/// let df = ctx.read_csv("tests/data/example.csv",
CsvReadOptions::new()).await?;
- /// let df = df.unnest_column("a")?;
+ /// let df = df.unnest_column_wtith_optons("a")?;
/// # Ok(())
/// # }
/// ```
pub fn unnest_column(self, column: &str) -> Result<DataFrame> {
+ self.unnest_column_with_options(column, UnnestOptions::new())
+ }
+
+ /// Expand each list element of a column to multiple rows, with
+ /// behavior controlled by [`UnnestOptions`].
+ ///
+ /// Please see the documentation on [`UnnestOptions`] for more
+ /// details about the meaning of unnest.
+ pub fn unnest_column_with_options(
Review Comment:
Here is the key -- add a `_with_options` variant and link to documentation
##########
datafusion/core/tests/dataframe/mod.rs:
##########
@@ -1044,6 +1044,82 @@ async fn unnest_columns() -> Result<()> {
Ok(())
}
+#[tokio::test]
+async fn unnest_column_preserve_nulls_not_supported() -> Result<()> {
+ // Unnest, preserving nulls not yet supported
+ let options = UnnestOptions::new().with_preserve_nulls(true);
+
+ let results = table_with_lists_and_nulls()
+ .await?
+ .clone()
+ .unnest_column_with_options("list", options)?
+ .collect()
+ .await;
+
+ assert_eq!(
+ results.unwrap_err().to_string(),
+ "This feature is not implemented: Unest with preserve_nulls=true"
Review Comment:
preserve_nulls is not yet supported, but here is a space for it
--
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]