Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: DataFrame supports unnesting multiple columns #10118

Merged
merged 9 commits into from
Apr 18, 2024

Conversation

jonahgao
Copy link
Member

Which issue does this PR close?

N/A

Rationale for this change

#10044 has enabled SQL to support unnesting multiple columns, this PR adds the same functionality to DataFrame.

What changes are included in this PR?

Are these changes tested?

Yes

Are there any user-facing changes?

Yes
Mark the unnest_column API as deprecated, and add a new API called unnest_columns.

@github-actions github-actions bot added core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Apr 17, 2024
@jonahgao jonahgao marked this pull request as draft April 17, 2024 15:54
@github-actions github-actions bot removed the sqllogictest SQL Logic Tests (.slt) label Apr 17, 2024

/// Test unnesting a non-nullable list.
#[tokio::test]
async fn unnest_non_nullable_list() -> Result<()> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the test suggested by @jayzhan211 in #10044 (comment)

@jonahgao jonahgao marked this pull request as ready for review April 17, 2024 16:09
Copy link
Contributor

@jayzhan211 jayzhan211 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"| 3 | | | a |",
"+------+------------+------------+--------+",
];
assert_batches_sorted_eq!(expected, &results);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the result is deterministic, so we can check without sorting

Then, we can have a more straightforward result

[
    "+------+------------+------------+--------+",
    "| list | large_list | fixed_list | string |",
    "+------+------------+------------+--------+",
    "| 1    |            |            | a      |",
    "| 2    | 1.1        |            | a      |",
    "| 3    |            |            | a      |",
    "|      | 2.2        | 1          | b      |",
    "|      | 3.3        | 2          | b      |",
    "|      | 4.4        |            | b      |",
    "|      |            | 3          | c      |",
    "|      |            | 4          | c      |",
    "|      |            |            | d      |",
    "+------+------------+------------+--------+",
]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the result is deterministic, so we can check without sorting

Updated. Thank you @jayzhan211 . It looks much better now.

"| 3 | | | a |",
"+------+------------+------------+--------+",
];
assert_batches_sorted_eq!(expected, &results);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jayzhan211
Copy link
Contributor

Nice! Thanks @jonahgao

@jayzhan211 jayzhan211 merged commit 79a9923 into apache:main Apr 18, 2024
23 checks passed
@jonahgao jonahgao deleted the dataframe_unnest branch April 18, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants