From 794982a668ebcd07773d4b72428df15846b47d8b Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Wed, 2 Jul 2025 09:24:48 +0800 Subject: [PATCH] branch-2.1: [fix](type) Fix TYPE_DATETIMEV2 upgrade and downgrade compatibility (#52530) Introduced from https://github.com/apache/doris/pull/49643 --- be/src/runtime/types.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/be/src/runtime/types.cpp b/be/src/runtime/types.cpp index f0112ebd2b..b64fd139ea 100644 --- a/be/src/runtime/types.cpp +++ b/be/src/runtime/types.cpp @@ -167,6 +167,8 @@ void TypeDescriptor::to_thrift(TTypeDesc* thrift_type) const { scalar_type.__set_scale(scale); } else if (type == TYPE_DATETIMEV2) { DCHECK_NE(scale, -1); + scalar_type.__set_precision( + precision); // -1, adapting upgrade and downgrade compatibility. scalar_type.__set_scale(scale); } } @@ -187,6 +189,7 @@ void TypeDescriptor::to_protobuf(PTypeDesc* ptype) const { scalar_type->set_scale(scale); } else if (type == TYPE_DATETIMEV2) { DCHECK_NE(scale, -1); + scalar_type->set_precision(precision); // -1, adapting upgrade and downgrade compatibility. scalar_type->set_scale(scale); } else if (type == TYPE_ARRAY) { node->set_type(TTypeNodeType::ARRAY);