-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Decimal improvements #3047
Merged
Merged
Decimal improvements #3047
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e0b1e9a
array functions for Decimal [CLICKHOUSE-3765CLICKHOUSE-3765]
4ertus2 0581545
disable Decimal Comparison and Conditional compilation [CLICKHOUSE-3765]
4ertus2 7e26ff0
Merge branch 'master' into decimal
4ertus2 6096c69
minor fix: remove unused func
4ertus2 a0309b5
fix build with embedded compiler
4ertus2 a969292
revert textCanContainOnlyValidUTF8() for Decimal; add DataTypeExtract…
4ertus2 3bd586c
Merge branch 'master' into decimal
4ertus2 5bbfdc2
supertypes for Decimals [CLICKHOUSE-3765]
4ertus2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -423,5 +423,77 @@ class IDataType : private boost::noncopyable | |
}; | ||
|
||
|
||
struct DataTypeExtractor | ||
{ | ||
TypeIndex idx; | ||
|
||
DataTypeExtractor(const IDataType * data_type) | ||
: idx(data_type->getTypeId()) | ||
{} | ||
|
||
bool isUInt8() const { return idx == TypeIndex::UInt8; } | ||
bool isUInt16() const { return idx == TypeIndex::UInt16; } | ||
bool isUInt32() const { return idx == TypeIndex::UInt32; } | ||
bool isUInt64() const { return idx == TypeIndex::UInt64; } | ||
bool isUInt128() const { return idx == TypeIndex::UInt128; } | ||
bool isUInt() const { return isUInt8() || isUInt16() || isUInt32() || isUInt64() || isUInt128(); } | ||
|
||
bool isInt8() const { return idx == TypeIndex::Int8; } | ||
bool isInt16() const { return idx == TypeIndex::Int16; } | ||
bool isInt32() const { return idx == TypeIndex::Int32; } | ||
bool isInt64() const { return idx == TypeIndex::Int64; } | ||
bool isInt128() const { return idx == TypeIndex::Int128; } | ||
bool isInt() const { return isInt8() || isInt16() || isInt32() || isInt64() || isInt128(); } | ||
|
||
bool isDecimal32() const { return idx == TypeIndex::Decimal32; } | ||
bool isDecimal64() const { return idx == TypeIndex::Decimal64; } | ||
bool isDecimal128() const { return idx == TypeIndex::Decimal128; } | ||
bool isDecimal() const { return isDecimal32() || isDecimal64() || isDecimal128(); } | ||
|
||
bool isFloat32() const { return idx == TypeIndex::Float32; } | ||
bool isFloat64() const { return idx == TypeIndex::Float64; } | ||
bool isFloat() const { return isFloat32() || isFloat64(); } | ||
|
||
bool isEnum8() const { return idx == TypeIndex::Enum8; } | ||
bool isEnum16() const { return idx == TypeIndex::Enum16; } | ||
bool isEnum() const { return isEnum8() || isEnum16(); } | ||
|
||
bool isDate() const { return idx == TypeIndex::Date; } | ||
bool isDateTime() const { return idx == TypeIndex::DateTime; } | ||
bool isDateOrDateTime() const { return isDate() || isDateTime(); } | ||
|
||
bool isString() const { return idx == TypeIndex::String; } | ||
bool isFixedString() const { return idx == TypeIndex::FixedString; } | ||
bool isStringOrFixedString() const { return isString() || isFixedString(); } | ||
|
||
bool isUUID() const { return idx == TypeIndex::UUID; } | ||
bool isArray() const { return idx == TypeIndex::Array; } | ||
bool isTuple() const { return idx == TypeIndex::Tuple; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now you have to replace typeid_casts, checkDataType across all the codebase. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
}; | ||
|
||
/// IDataType helpers (alternative for IDataType virtual methods) | ||
|
||
inline bool isEnum(const IDataType * data_type) | ||
{ | ||
return DataTypeExtractor(data_type).isEnum(); | ||
} | ||
|
||
inline bool isDecimal(const IDataType * data_type) | ||
{ | ||
return DataTypeExtractor(data_type).isDecimal(); | ||
} | ||
|
||
inline bool isNotDecimalButComparableToDecimal(const IDataType * data_type) | ||
{ | ||
DataTypeExtractor which(data_type); | ||
return which.isInt() || which.isUInt(); | ||
} | ||
|
||
inline bool isCompilableType(const IDataType * data_type) | ||
{ | ||
return data_type->isValueRepresentedByNumber() && !isDecimal(data_type); | ||
} | ||
|
||
|
||
} | ||
|
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much cases where isNumber() means something more then expected.
In example, when isNumber enabled it leads to compareAt() for Decimals with different scales in some cases.