You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/07/04 01:42:08 UTC

[GitHub] [incubator-doris] WingsGo commented on a change in pull request #4009: [Bug]Fix some schema change not work right

WingsGo commented on a change in pull request #4009:
URL: https://github.com/apache/incubator-doris/pull/4009#discussion_r449728088



##########
File path: be/src/olap/schema_change.cpp
##########
@@ -194,6 +194,64 @@ ColumnMapping* RowBlockChanger::get_mutable_column_mapping(size_t column_index)
         break; \
     }
 
+struct ConvertTypeMapHash {
+    size_t operator()(const std::pair<FieldType, FieldType>& pair) const {
+        return (pair.first + 31) ^ pair.second;
+    }
+};
+
+class ConvertTypeResolver {
+DECLARE_SINGLETON(ConvertTypeResolver);
+public:
+    bool get_convert_type_info(const FieldType from_type, const FieldType to_type) const {
+        return _convert_type_set.find(std::make_pair(from_type, to_type)) != _convert_type_set.end();
+    }
+
+    template<FieldType from_type, FieldType to_type>
+    void add_convert_type_mapping() {
+        _convert_type_set.emplace(std::make_pair(from_type, to_type));
+    }
+
+private:
+    typedef std::pair<FieldType, FieldType> convert_type_pair;
+    std::unordered_set<convert_type_pair, ConvertTypeMapHash> _convert_type_set;
+
+    DISALLOW_COPY_AND_ASSIGN(ConvertTypeResolver);
+};
+
+ConvertTypeResolver::ConvertTypeResolver() {
+    // supported type convert should annotate in doc:
+    // http://doris.incubator.apache.org/master/zh-CN/sql-reference/sql-statements/Data%20Definition/ALTER%20TABLE.html#description
+    // from varchar type
+    add_convert_type_mapping<OLAP_FIELD_TYPE_VARCHAR, OLAP_FIELD_TYPE_TINYINT>();
+    add_convert_type_mapping<OLAP_FIELD_TYPE_VARCHAR, OLAP_FIELD_TYPE_SMALLINT>();
+    add_convert_type_mapping<OLAP_FIELD_TYPE_VARCHAR, OLAP_FIELD_TYPE_INT>();
+    add_convert_type_mapping<OLAP_FIELD_TYPE_VARCHAR, OLAP_FIELD_TYPE_BIGINT>();
+    add_convert_type_mapping<OLAP_FIELD_TYPE_VARCHAR, OLAP_FIELD_TYPE_LARGEINT>();
+    add_convert_type_mapping<OLAP_FIELD_TYPE_VARCHAR, OLAP_FIELD_TYPE_FLOAT>();

Review comment:
       VAHRCHAR->DOUBLE is supported. Support VARCHAR->DATETIME maybe supported in next PR.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org