github-actions[bot] commented on code in PR #63569:
URL: https://github.com/apache/doris/pull/63569#discussion_r3297255970
##########
be/src/core/data_type/data_type_factory.cpp:
##########
@@ -379,8 +379,17 @@ DataTypePtr DataTypeFactory::create_data_type(const
segment_v2::ColumnMetaPB& pc
nested = std::make_shared<DataTypeStruct>(dataTypes, names);
} else {
// TODO add precision and frac
- nested =
_create_primitive_data_type(static_cast<FieldType>(pcolumn.type()),
- pcolumn.precision(),
pcolumn.frac(), -1);
+ // 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".
+ auto meta_precision = pcolumn.precision();
+ UInt32 orig_precision =
+ meta_precision > 0 ? static_cast<UInt32>(meta_precision) :
UINT32_MAX;
+ UInt32 orig_scale = meta_precision > 0 ?
static_cast<UInt32>(pcolumn.frac()) : UINT32_MAX;
Review Comment:
This fallback is applied to every primitive ColumnMetaPB, not just legacy
DecimalV2. For example, DATETIMEV2/TIMESTAMPTZ reach this same branch and
`_create_primitive_data_type()` uses the `scale` argument in
`create_datetimev2(scale)`. Their `precision()` is normally unset/default,
while `frac()` carries the scale; with this change `meta_precision <= 0`
rewrites that scale to `UINT32_MAX`, so reading a DATETIMEV2 segment can throw
`scale_value 4294967295 > 6`. Please gate the UINT32_MAX sentinel on
`OLAP_FIELD_TYPE_DECIMAL` only (or otherwise preserve `pcolumn.frac()` for
non-DecimalV2 types), and add a regression test for a scaled
DATETIMEV2/TIMESTAMPTZ ColumnMetaPB.
--
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]