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: extend unnest to support Struct datatype #10429

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

duongcongtoai
Copy link
Contributor

@duongcongtoai duongcongtoai commented May 8, 2024

Which issue does this PR close?

Closes #10264.

Rationale for this change

What changes are included in this PR?

  • Unnest logical plan is aware of the type of columns to be unnested
  • UnnestExec (physical plan) expands the input batch both vertically and horizontally, depends on the set of columns to be unnested
  • Modify try_process_unnest so it also interested in unnest(struct) expr, and translate this Expr into the projection of multiple columns for each subfield of the current struct in the column. Detailed expected behavior is in this test
  • Add unnest(struct) scehanrios to unnest.slt, and one case where unnest is executed for different columns of type list/struct simultaneously

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions core Core datafusion crate labels May 8, 2024
@duongcongtoai duongcongtoai changed the title feat: extend unnest for struct feat: extend unnest to support Struct datatype May 8, 2024
@github-actions github-actions bot added the optimizer Optimizer rules label May 12, 2024
@duongcongtoai duongcongtoai marked this pull request as ready for review May 19, 2024 20:15
@@ -123,7 +123,8 @@ impl ExprSchemable for Expr {
Ok(field.data_type().clone())
}
DataType::Struct(_) => {
not_impl_err!("unnest() does not support struct yet")
// TODO: this is not correct, because unnest(struct) wll result into multiple data_type
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm still finding a way to solve this TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core datafusion crate logical-expr Logical plan and expressions optimizer Optimizer rules sql sqllogictest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support unnest for struct data type
1 participant