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

fix array_append with null array #8333

Closed
wants to merge 2 commits into from

Conversation

Veeupup
Copy link
Contributor

@Veeupup Veeupup commented Nov 27, 2023

Which issue does this PR close?

fix todo in array.slt, now we can do array_append correctly with null.

select array_append(make_array(), 4);

and fix fn check_datatypes, this function contains a bug that when input arrays sequences are different:

  • (DataType::Null, DataType::Int64) used to return unexcepted array while(DataType::Int64, DataType::Null) returns Ok(())

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Physical Expressions sqllogictest SQL Logic Tests (.slt) labels Nov 27, 2023
@Veeupup
Copy link
Contributor Author

Veeupup commented Nov 27, 2023

cc @jayzhan211 PTAL, I find this one when porting tests

@Veeupup Veeupup force-pushed the fix_array_append_null branch from afb9a3c to fd94178 Compare November 27, 2023 14:07
Signed-off-by: veeupup <code@tanweime.com>
@Veeupup Veeupup force-pushed the fix_array_append_null branch from fd94178 to 18de0bf Compare November 27, 2023 14:54
@jayzhan211
Copy link
Contributor

jayzhan211 commented Nov 27, 2023

I am fixing null in #8317, so this change may no longer needed if we agree to process it like #8317

@Veeupup
Copy link
Contributor Author

Veeupup commented Nov 27, 2023

I am fixing null in #8317, so this change may no longer needed if we agree to process it like #8317

It would be great if we have a general solution

Signed-off-by: veeupup <code@tanweime.com>
@Veeupup Veeupup force-pushed the fix_array_append_null branch from 5221b69 to b0ccf19 Compare November 29, 2023 13:51
if data_types.contains(&DataType::Null) {
Ok(())
} else {
let types = args.iter().map(|arg| arg.data_type()).collect::<Vec<_>>();
Copy link
Contributor

Choose a reason for hiding this comment

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

seems types variable is not used at all?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, my bad, its it err message.
we may want to avoid code duplication for

           let types = args.iter().map(|arg| arg.data_type()).collect::<Vec<_>>();
            plan_err!("{name} received incompatible types: '{types:?}'.")

Copy link
Contributor

Choose a reason for hiding this comment

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

    match x {
        1 => "ok",
        2 if true => "ok",
        _ => "err"
    };

@jayzhan211
Copy link
Contributor

jayzhan211 commented Nov 29, 2023

I think we should not add more and more type coercion or checking in array_expression.rs. Our goal is to reduce them. Unless there we need to fix regression, otherwise I dont think we should handle this special case in this way. It is better to avoid adding the complexity of check_types or return_type.

@Veeupup
Copy link
Contributor Author

Veeupup commented Nov 30, 2023

I think we should not add more and more type coercion or checking in array_expression.rs. Our goal is to reduce them. Unless there we need to fix regression, otherwise I dont think we should handle this special case in this way. It is better to avoid adding the complexity of check_types or return_type.

Agree with you! I'll close this PR to avoid to make check_types more complicate

@Veeupup Veeupup closed this Nov 30, 2023
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 physical-expr Physical Expressions sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants