Skip to content

Bug: get_valid_types handles TypeSignature::Numeric incorrectly #14059

@niebayes

Description

@niebayes

Describe the bug

The get_valid_types function works correctly when the type signature is TypeSignature::Numeric(n) with n > 1. However, it behaves incorrectly when n = 1.
This is because the function first attempts to coerce data types into a numeric type. Such coercion is only performed when the number of arguments is greater than 1, but it does not check if the single data type is numeric when there's only one argument.

To Reproduce

You can write a simple unit test to reproduce the error:

    #[test]
    fn test_get_valid_types_numeric() -> Result<()> {
        let signature = TypeSignature::Numeric(1);

        // Returns ok while it's expected to return err.
        let got = get_valid_types(&signature, &[DataType::Binary]);
        assert!(got.is_ok());

        Ok(())
    }

Expected behavior

The get_valid_types functions rejects non-numeric arguments when given TypeSignature::Numeric(1).

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions