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: incorrect error message of function_length_check #14056

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

niebayes
Copy link
Contributor

@niebayes niebayes commented Jan 9, 2025

Which issue does this PR close?

No

Rationale for this change

The error message of the function_length_check is incorrect.

What changes are included in this PR?

Place the expected_length and length at where they should be.

Are these changes tested?

Yes, added a simple unit test.

Are there any user-facing changes?

Yes, users will see correct error message when given unexpected number of args.

@github-actions github-actions bot added the logical-expr Logical plan and expressions label Jan 9, 2025
Copy link
Member

@jonahgao jonahgao left a comment

Choose a reason for hiding this comment

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

LGTM👍

@niebayes
Copy link
Contributor Author

niebayes commented Jan 9, 2025

@jonahgao Thanks for reviewing so quickly.

@@ -440,13 +440,13 @@ fn get_valid_types(
fn function_length_check(length: usize, expected_length: usize) -> Result<()> {
if length < 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering if this check really needed? would be that enough just to compare with expected_length?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense to me to remove this check.
However, if it's required to handle the 0 arg case specifically, it's also reasonable to keep this check.

Copy link
Contributor

Choose a reason for hiding this comment

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

hm, I would expect expected_length to be 0 in this case? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this check, 0 arg is handled early in

    if current_types.is_empty() {
        if type_signature.supports_zero_argument() {
            return Ok(vec![]);
        } else if type_signature.used_to_support_zero_arguments() {
            // Special error to help during upgrade: https://github.com/apache/datafusion/issues/13763
            return plan_err!("{} does not support zero arguments. Use TypeSignature::Nullary for zero arguments.", func.name());
        } else {
            return plan_err!("{} does not support zero arguments.", func.name());
        }
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@niebayes niebayes force-pushed the fix/function_length_check branch from 07aa555 to f7064f1 Compare January 10, 2025 08:35
@jonahgao jonahgao merged commit 268df42 into apache:main Jan 10, 2025
25 checks passed
@jonahgao
Copy link
Member

Thanks @niebayes @comphead @jayzhan211

@niebayes niebayes deleted the fix/function_length_check branch January 10, 2025 09:37
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants