Closed
Conversation
Signed-off-by: remzi <[email protected]>
Signed-off-by: remzi <[email protected]>
Contributor
Author
|
Hi @tustvold, Could you please help review? |
Contributor
Author
|
@viirya @liukun4515 Could you please help to review? |
tustvold
reviewed
Aug 17, 2022
Contributor
There was a problem hiding this comment.
As #2001 hasn't been released yet, I think we have an opportunity to revisit this prior to the next release #2382 (comment)
In particular using a const generic and then constraining it in this way feels a bit derived. Perhaps we could instead have
pub trait DecimalType {
const BYTE_LENGTH: usize;
const MAX_PRECISION: usize;
const MAX_SCALE: usize;
const TYPE_CONSTRUCTOR: fn(usize, usize) -> DataType;
const DEFAULT_TYPE: DataType;
}
pub struct Decimal128Type {}
pub struct Decimal256Type {}
pub struct DecimalArray<T: DecimalType>
Contributor
Author
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #2440.
Rationale for this change
The current implementation of
BasicDecimalcannot restrict theBYTE_WIDTHto be 16 or 32, which means that you can create an invalid decimal value like thisWhat changes are included in this PR?
We create a new public trait
ValidDecimaland implement the trait forDecimal128andDecimal256. The idea is from https://users.rust-lang.org/t/how-to-seal-the-const-generic/77947/2.Because of the orphan rule, downstream users cannot implement
ValidDecimalfor otherBasicDecimaltypes.Are there any user-facing changes?
No breaking.