-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Schema change] Support More column type in schema change #4938
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
Conversation
1. Support modify column type CHAR to TINYINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE/DATE and TINYINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE convert to a wider range of numeric types (apache#4937) 2. Use template to refactor code of types.h and schema_change.cpp to delete redundant code.
| return StringParser::string_to_int<T>(src_value->get_data(), src_value->get_size(), &parse_res); | ||
| } | ||
|
|
||
| template <typename T> |
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.
There may use traits ?
Or use if constexpr (std::is_floating_point_v)) to distinguish the two cases.
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.
Hi, chaoyli.
if constexpr only support in c++17 and std::is_floating_point_v support in c++14.
Now, Doris only support C++11, So I use label assignment to distinguish the float and int.
| }; | ||
| template <FieldType fieldType> | ||
| struct FieldTypeTraits : public ArithmeTicFieldtypeTraits<fieldType, | ||
| std::is_arithmetic<typename BaseFieldtypeTraits<fieldType>::CppType>::value && std::is_signed<typename BaseFieldtypeTraits<fieldType>::CppType>::value> {}; |
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.
use std::is_signed for what?
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.
Now, ArithmeticField just to keep the small with old code.
old code only Partial Template Specialization the OLAP_FIELD_TYPE_INT but not OLAP_FIELD_TYPE_UNSIGNED_INT. There is no need to Partial Template Specialization for unsign type, so there check the CppType whether is_signed
be/src/olap/types.h
Outdated
| // Using ArithmeTicFieldtypeTraits to Derived code for OLAP_FIELD_TYPE_XXXINT, OLAP_FIELD_TYPE_FLOAT, | ||
| // OLAP_FIELD_TYPE_DOUBLE, to reduce redundant code | ||
| template <FieldType fieldType, bool isArithmetic> | ||
| struct ArithmeTicFieldtypeTraits : public BaseFieldtypeTraits<fieldType> { |
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.
Numeric may be a better name.
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.
OK,i will consider to change the name of it
Support modify column type CHAR to TINYINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE/DATE
and TINYINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE convert to a wider range of numeric types ([Proposal] Support more column type in schema change #4937)
Use template to refactor code of types.h and schema_change.cpp to delete redundant code.
fix issue:#4937
Proposed changes
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
Types of changes
What types of changes does your code introduce to Doris?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.