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

[C#] Better support for decimal values which exceed the range of the BCL's System.Decimal in Decimal128 #38351

Closed
CurtHagenlocher opened this issue Oct 19, 2023 · 2 comments · Fixed by #38481

Comments

@CurtHagenlocher
Copy link
Contributor

Describe the enhancement requested

There should be a way to read decimal values outside the (untruncated) range of System.Decimal despite the lack of a "standard" .NET type for doing this. Some possible options:

Add a new scalar type to represent BigDecimal
Allow the mantissa to be read as a BigInteger
Add an extension mechanism which allows consuming libraries to supply their own conversions

The drawback of the first is that (at least in my opinion) it would be better to keep "opinions" out of the base library and a new custom BigDecimal type won't be what anyone is already using.

One advantage of an extension mechanism is that (if general enough) it could also be used to e.g. consume Float16 on downlevel platforms which don't support it in the BCL.

Component(s)

C#

@rohanjain101
Copy link

rohanjain101 commented Oct 19, 2023

What about using SqlDecimal (https://learn.microsoft.com/en-us/dotnet/api/system.data.sqltypes.sqldecimal?view=netstandard-2.0)? Although it wouldn't work for Decimal256, but it should support same range as Decimal128.

@CurtHagenlocher
Copy link
Contributor Author

Oh, interesting; I didn't know about that type.

My gut reaction is that it's a little weird to have different stories for Decimal128 than for Decimal256, but it also seems foolish not to take advantage of a standard type where one exists.

@CurtHagenlocher CurtHagenlocher changed the title [C#] Better support for decimal values which exceed the range of the BCL's System.Decimal [C#] Better support for decimal values which exceed the range of the BCL's System.Decimal in Decimal128 Oct 26, 2023
CurtHagenlocher added a commit that referenced this issue Oct 27, 2023
### What changes are included in this PR?

Adds support for reading and writing System.Data.SqlTypes.SqlDecimal against Decimal128Array.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Adds functions to the API.
* Closes: #38351

Authored-by: Curt Hagenlocher <curt@hagenlocher.org>
Signed-off-by: Curt Hagenlocher <curt@hagenlocher.org>
@CurtHagenlocher CurtHagenlocher added this to the 15.0.0 milestone Oct 27, 2023
loicalleyne pushed a commit to loicalleyne/arrow that referenced this issue Nov 13, 2023
…e#38481)

### What changes are included in this PR?

Adds support for reading and writing System.Data.SqlTypes.SqlDecimal against Decimal128Array.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Adds functions to the API.
* Closes: apache#38351

Authored-by: Curt Hagenlocher <curt@hagenlocher.org>
Signed-off-by: Curt Hagenlocher <curt@hagenlocher.org>
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…e#38481)

### What changes are included in this PR?

Adds support for reading and writing System.Data.SqlTypes.SqlDecimal against Decimal128Array.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Adds functions to the API.
* Closes: apache#38351

Authored-by: Curt Hagenlocher <curt@hagenlocher.org>
Signed-off-by: Curt Hagenlocher <curt@hagenlocher.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants