Skip to content

Internal error when negating strings #9060

@alamb

Description

@alamb

Describe the bug

Negating an string results in an internal error

To Reproduce

select -'100';
Internal error: Can't create negative physical expr for (- 'Literal { value: Utf8("100") }'), the type of child expr is Utf8, not signed numeric.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

However, if the explicit cast is added things work great:

select -'100'::int;
+-----------------+
| (- Utf8("100")) |
+-----------------+
| -100            |

Expected behavior

The query should probably an error that says something like negate only supports numeric types

Related PR: #8982 can be applied here too

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    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