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

add support for casting string to decimal #3478

Closed
Tracked by #3480
kmitchener opened this issue Sep 14, 2022 · 5 comments
Closed
Tracked by #3480

add support for casting string to decimal #3478

kmitchener opened this issue Sep 14, 2022 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@kmitchener
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
(This section helps Arrow developers understand the context and why for this feature, in addition to the what)

Describe the solution you'd like
A clear and concise description of what you want to happen.
Would like to be able to cast string to decimal as is supported by float types.

select arrow_typeof('1.1'::decimal);
Internal("Unsupported CAST from Utf8 to Decimal128(38, 10)")

but should work like it does for float:

select arrow_typeof('1.1'::double);
+--------------------------+
| arrowtypeof(Utf8("1.1")) |
+--------------------------+
| Float64                  |
+--------------------------+
1 row in set. Query took 0.010 seconds.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@liukun4515
Copy link
Contributor

about the cast, you can refer the apache/arrow-rs#1043 #1443

we don't support the cast/try_cast from decimal to utf8 or utf8 to decimal

you can implement this in the arrow-rs kernel about the cast.
@kmitchener

@alamb
Copy link
Contributor

alamb commented Nov 14, 2022

Here is a PR to add the appropriate support in arrow-rs: apache/arrow-rs#3106 👍

@Dandandan
Copy link
Contributor

❯ select arrow_typeof('1.1'::decimal);
+--------------------------+
| arrowtypeof(Utf8("1.1")) |
+--------------------------+
| Decimal128(38, 10)       |
+--------------------------+
1 row in set. Query took 0.030 seconds.

@finlaydotb
Copy link

❯ select arrow_typeof('1.1'::decimal);
+--------------------------+
| arrowtypeof(Utf8("1.1")) |
+--------------------------+
| Decimal128(38, 10)       |
+--------------------------+
1 row in set. Query took 0.030 seconds.

Maybe someone can help clarify...Why does this come out as Decimal128(38, 10)? Where is the 38 and 10 coming from

@alamb
Copy link
Contributor

alamb commented Jun 1, 2024

The 38 is the maximum precision of Decimal128 in arrow

https://docs.rs/arrow-schema/51.0.0/src/arrow_schema/datatype.rs.html#676

The 10 is the default scale: https://docs.rs/arrow-schema/51.0.0/src/arrow_schema/datatype.rs.html#689

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants