dgraph-io / dgraph

The high-performance database for modern applications
https://dgraph.io
Other
20.36k stars 1.49k forks source link

[ENHANCEMENT]: BigInt data type support #8813

Closed rderbier closed 2 months ago

rderbier commented 1 year ago

Use case and current behavior

DQL types include int64. Some use cases (finance and others) require arbitrary-precision arithmetic (big numbers).

Enhancement

Big.Int must be supported.

As Go Big package also has Rat (rational) Float, would be nice to have those types too.

Solution proposal

No response

Links to Discuss, RFC or previous Issues and PRs

No response

Links to examples and research

No response

Additional Information

No response

rarvikar commented 1 year ago

There was some demand in the past to add support for BigDecimal scalar types like uint256. We currently only support int64 for decimal scalar types and uint64 for the UID type. This was added as a low priority backlog via the GitHub issue and later 'Closed'.

But uint256 is heavily used in all crypto implementations. Ethereum uses 256-bit words natively. Their design rationale is that 4 or 8 byte words are too restrictive to store both addresses and values for computations and 32 byte words provide the perfect balance between performance and building a successful GAS model around it. Banks and financial institutions also rely on BigDecimal to avoid loss of precision while working with very large numbers.

Some requests from customers for this feat.:

https://discuss.dgraph.io/t/support-arbitrary-precision-numeric-types/8746 https://discuss.dgraph.io/t/data-type-for-money/4899/3 https://github.com/dgraph-io/dgraph/issues/2107

This feature was requested in the recent past by multiple prospects in the fields of finance, commerce and block-chain etc.

mangalaman93 commented 1 year ago

Existing work on this feature: https://github.com/dgraph-io/dgraph/pull/3981

github-actions[bot] commented 2 months ago

This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.