Skip to content

- (negation) with NULL literals does not work: can't be evaluated because the expression's type is Utf8, not signed  #1192

Closed

Description

@alamb

Reproducer:

> select -null;
Internal("(- 'Literal { value: Utf8(NULL) }') can't be evaluated because the expression's type is Utf8, not signed numeric")

The correct output is null

I think the solution will likely be to teach Expr::Negative about type coercion (as is done in BinaryExpr and function calls) once coercion knows about the null type (and that it can be cast to any other type). See #1184 for more details

Activity

  1. changed the title [-]`-` (negation) with NULL literals does not work[/-] [+]`-` (negation) with NULL literals does not work: can't be evaluated because the expression's type is Utf8, not signed [/+] on Oct 28, 2021
  2. WinkerDu commented on Apr 8, 2022

    @WinkerDu
    Contributor

    @alamb plz assign to me, thank you.

  3. xudong963 commented on Apr 9, 2022

    @xudong963
    Member

    I tested select -null; in mysql and postgres: mysql returned null but

    postgres=# select -null;
    ERROR:  operator is not unique: - unknown
    LINE 1: select -null;
                   ^
    HINT:  Could not choose a best candidate operator. You might need to add explicit type casts.

    Do you need this syntax in iox? @alamb

  4. WinkerDu commented on Apr 9, 2022

    @WinkerDu
    Contributor

    I tested select -null; in mysql and postgres: mysql returned null but

    postgres=# select -null;
    ERROR:  operator is not unique: - unknown
    LINE 1: select -null;
                   ^
    HINT:  Could not choose a best candidate operator. You might need to add explicit type casts.

    Do you need this syntax in iox? @alamb

    @xudong963 Thanks for the test! I agree we can discuss more on it.

  5. alamb commented on Apr 10, 2022

    @alamb
    ContributorAuthor

    Do you need this syntax in iox? @alamb

    We do not need this syntax in IOx (and if we do I can always add it at that time)

  6. WinkerDu commented on Apr 16, 2022

    @WinkerDu
    Contributor

    @alamb @xudong963 Maybe we can introduce this syntax, and keep the contract that operators comes out result NULL when accepts NULL.

  7. liukun4515 commented on Apr 17, 2022

    @liukun4515
    Contributor

    @alamb @xudong963 Maybe we can introduce this syntax, and keep the contract that operators comes out result NULL when accepts NULL.

    It's better to make it consistent with PG in SQL dialect.

  8. WinkerDu commented on Apr 17, 2022

    @WinkerDu
    Contributor

    I feel free to close the pr #2249 since more conservative opinions of introducing -NULL SQL dialect
    Thank you @liukun4515 @xudong963

  9. liukun4515 commented on May 26, 2022

    @liukun4515
    Contributor

    I think this issue can be closed.
    @alamb @andygrove

  10. alamb commented on May 26, 2022

    @alamb
    ContributorAuthor

    🤔 I just tried the query again, and it now gives a different error:

    ❯ select -null;
    Internal("(- 'Literal { value: NULL }') can't be evaluated because the expression's type is Null, not signed numeric")

    I think we are getting closer...

  11. alamb commented on May 26, 2022

    @alamb
    ContributorAuthor

    I bet this is a fairly straightforward matter of adding a case in the evaluation kernels

  12. drrtuy commented on Oct 8, 2022

    @drrtuy
    Contributor

    It is indeed an additional condition in expressions/negative.rs. Here is the PR #3771.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions