Skip to content

The returned type of abs is error. #1335

@liukun4515

Description

@liukun4515

Describe the bug

In the pg database, the abs support varchar data type

But the result in the datafusion is

❯ select abs('123');
Plan("Coercion from [Utf8] to the signature Uniform(1, [Float64, Float32]) failed.")
❯

In other size, the returned type of abs is the input type.

If the input type is int, the returned type must be the int.

If the result data is out of range, PG will throw error message.

postgres=# SELECT abs(-2147483648);
ERROR:  integer out of range
postgres=#

but in the datafusion, it convert the -2147483648 to INT64

❯ SELECT abs(-2147483648);
+-------------------------+
| abs(Int64(-2147483648)) |
+-------------------------+
| 2147483648              |
+-------------------------+

To Reproduce
execute the sql

❯ select abs('123');
Plan("Coercion from [Utf8] to the signature Uniform(1, [Float64, Float32]) failed.")
❯

Expected behavior

postgres=# select abs('123');
 abs
-----
 123
(1 row)

the result of type is always double

Additional context

Metadata

Metadata

Assignees

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