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

The returned type of abs is error. #1335

Closed
Tracked by #2355
liukun4515 opened this issue Nov 19, 2021 · 3 comments
Closed
Tracked by #2355

The returned type of abs is error. #1335

liukun4515 opened this issue Nov 19, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@liukun4515
Copy link
Contributor

liukun4515 commented Nov 19, 2021

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

@liukun4515 liukun4515 added the bug Something isn't working label Nov 19, 2021
@liukun4515
Copy link
Contributor Author

Please assign this issue to me.

@liukun4515 liukun4515 changed the title Error result type for ABS functions ABS can support the varchar type Nov 24, 2021
@liukun4515 liukun4515 changed the title ABS can support the varchar type ABS can't support the varchar type Nov 24, 2021
@liukun4515 liukun4515 changed the title ABS can't support the varchar type The returned type of abs is error. Nov 26, 2021
@alamb
Copy link
Contributor

alamb commented Jan 28, 2023

https://github.com/apache/arrow-datafusion/pull/5086/files#r1089553803 -- @melgenek noticed that abs(decimal) appears to be resolved as a float rather than decimal

@alamb
Copy link
Contributor

alamb commented Jun 11, 2023

I am going to close this one as I can't figure out what this ticket is tracking

I think the current error message is pretty straightforward:

select abs('123');
Error during planning: No function matches the given name and argument types 'abs(Utf8)'. You might need to add explicit type casts.
	Candidate functions:
	abs(Float64/Float32)

I am not sure what this issue is tracking any more. Is the requested feature to support automatically cocercing strings to some type?

If so I'll open a new specific ticket for that

@alamb alamb closed this as completed Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants