github-actions[bot] commented on code in PR #65419:
URL: https://github.com/apache/doris/pull/65419#discussion_r3563810532


##########
be/src/core/data_type/data_type_factory.cpp:
##########
@@ -379,23 +379,8 @@ DataTypePtr DataTypeFactory::create_data_type(const 
segment_v2::ColumnMetaPB& pc
         nested = std::make_shared<DataTypeStruct>(dataTypes, names);
     } else {
         // TODO add precision and frac
-        auto meta_precision = pcolumn.precision();
-        auto meta_scale = pcolumn.frac();
-        if (pcolumn.type() == 
static_cast<int>(FieldType::OLAP_FIELD_TYPE_DECIMAL)) {
-            // Segments written by Doris < 2.1.0 (before #26572) do not persist
-            // precision/frac in ColumnMetaPB, so they default to 0 when read 
back.
-            // Pass UINT32_MAX to DataTypeDecimalV2 to signal that the original
-            // precision/scale are unknown; otherwise check_type_precision(0) 
throws
-            // "meet invalid precision: real_precision=0".
-            UInt32 orig_precision =
-                    meta_precision > 0 ? static_cast<UInt32>(meta_precision) : 
UINT32_MAX;
-            UInt32 orig_scale = meta_precision > 0 ? 
static_cast<UInt32>(meta_scale) : UINT32_MAX;
-            nested = 
_create_primitive_data_type(static_cast<FieldType>(pcolumn.type()),
-                                                 orig_precision, orig_scale, 
-1);
-        } else {
-            nested = 
_create_primitive_data_type(static_cast<FieldType>(pcolumn.type()),
-                                                 meta_precision, meta_scale, 
-1);
-        }
+        nested = 
_create_primitive_data_type(static_cast<FieldType>(pcolumn.type()),
+                                             pcolumn.precision(), 
pcolumn.frac(), -1);

Review Comment:
   Moving the repair to `Segment::_parse_footer` fixes the normal rowset read 
path, but this factory is still used on raw `ColumnMetaPB`s that never see that 
schema repair. For example `meta_tool` reads a segment footer and calls 
`DataTypeFactory::create_data_type(column_meta)` directly; for a legacy 
DecimalV2 footer where precision/frac are absent this line now passes `0/0` 
into `_create_primitive_data_type`, and the DecimalV2 constructor rejects 
original precision 0. Before this PR the factory converted that missing 
precision to `UINT32_MAX`, so those raw callers could still construct the type. 
Please keep the DecimalV2 missing-precision fallback here, or otherwise 
enforce/cover every raw `ColumnMetaPB` caller before removing it.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to