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 2019/11/06 14:41:13 UTC

[GitHub] [incubator-doris] imay commented on a change in pull request #2134: Fix default value column bug

imay commented on a change in pull request #2134: Fix default value column bug
URL: https://github.com/apache/incubator-doris/pull/2134#discussion_r343129174
 
 

 ##########
 File path: be/src/olap/rowset/segment_v2/column_reader.cpp
 ##########
 @@ -483,16 +483,28 @@ Status FileColumnIterator::_read_page(const OrdinalPageIndexIterator& iter, Pars
 Status DefaultValueColumnIterator::init(const ColumnIteratorOptions& opts) {
     _opts = opts;
     // be consistent with segment v1
-    if (_default_value == "NULL" && _is_nullable) {
+    // be consistent with segment v1
+    // if _has_default_value, we should create default column iterator for this column, and
+    // "NULL" is a special default value which means the default value is null.
+    if (_has_default_value) {
+        if (_default_value == "NULL") {
+            DCHECK(_is_nullable);
+            _is_default_value_null = true;
+        } else {
+            TypeInfo* type_info = get_type_info(_type);
+            _value_size = type_info->size();
+            _mem_value.reserve(_value_size);
+            OLAPStatus s = type_info->from_string(_mem_value.data(), _default_value);
+            if (s != OLAP_SUCCESS) {
+                return Status::InternalError(
+                        strings::Substitute("get value of type from default value failed. status:$0", s));
+            }
+        }
+    } else if (_is_nullable) {
+        // if _has_default_value is true but _is_nullable, we should create return null as default value.
 
 Review comment:
   ```suggestion
           // if _has_default_value is false but _is_nullable, we should create return null as default value.
   ```

----------------------------------------------------------------
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


With regards,
Apache Git Services

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