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

Convert Null to Int32(None) for MakeArray at type coercion step #7995

Closed
wants to merge 4 commits into from

Conversation

jayzhan211
Copy link
Contributor

@jayzhan211 jayzhan211 commented Oct 31, 2023

Which issue does this PR close?

Ref #7142.

Rationale for this change

What changes are included in this PR?

Convert null to int32(none) in type coercion, only make_array is supported now.

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added physical-expr Physical Expressions optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt) labels Oct 31, 2023
Signed-off-by: jayzhan211 <[email protected]>
Signed-off-by: jayzhan211 <[email protected]>
@github-actions github-actions bot added logical-expr Logical plan and expressions and removed sqllogictest SQL Logic Tests (.slt) labels Nov 1, 2023
Signed-off-by: jayzhan211 <[email protected]>
@jayzhan211 jayzhan211 changed the title Convert default null to int32::None Convert Null to Int32(None) in array function at type coercion step Nov 1, 2023
@jayzhan211 jayzhan211 changed the title Convert Null to Int32(None) in array function at type coercion step Convert Null to Int32(None) for MakeArray at type coercion step Nov 1, 2023
@jayzhan211 jayzhan211 marked this pull request as ready for review November 1, 2023 12:57
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you for this contribution @jayzhan211 -- I am not quite sure how this contributes to #7142.

I apologize for the delay in reviewing

@@ -579,26 +580,51 @@ fn coerce_arguments_for_fun(
.collect::<Result<Vec<_>>>()?;
}

// Converting `Null` to Int32(None) to avoid handling `Null` in array functions
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems very strange to me that there are three special cases for if *fun == BuiltinScalarFunction::MakeArray { that all do similar things 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like the fact this is special casing NULLs when nothing else in DataFusion needs to do the same, is an indication something is not quite right with this architecture. Is there any way we can remove these special cases?

Copy link
Contributor Author

@jayzhan211 jayzhan211 Nov 11, 2023

Choose a reason for hiding this comment

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

Actually converting null is not only a special case for MakeArray. I think we need to extend this to other Array function too.

For example, array_append(make_array(1,null,3), null);
We not only need conversion in make_array but also conversion in array_append.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants