You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "HappenLee (via GitHub)" <gi...@apache.org> on 2023/04/03 03:41:20 UTC

[GitHub] [doris] HappenLee commented on a diff in pull request #18277: [FE](mysql) support mysql protocol with precision and scale info for decimal type

HappenLee commented on code in PR #18277:
URL: https://github.com/apache/doris/pull/18277#discussion_r1155455320


##########
fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlSerializer.java:
##########
@@ -253,17 +255,53 @@ private int getMysqlTypeLength(PrimitiveType type) {
                 return 10;
             case DATETIME:
             case DATETIMEV2: {
-                if (type.isTimeType()) {
+                if (type.getPrimitiveType().isTimeType()) {
                     return 10;
-                }  else {
+                } else {
                     return 19;
                 }
             }
+            case DECIMALV2:
+            case DECIMAL32:
+            case DECIMAL64:
+            case DECIMAL128: {
+                // f.getDecimals() > 0 ? clampedGetLength(f) - 1 + f.getPrecisionAdjustFactor() :
+                // clampedGetLength(f) + f.getPrecisionAdjustFactor();
+                ScalarType decimalType = (ScalarType) type;
+                int precision = decimalType.decimalPrecision();
+                int scale = decimalType.decimalScale();
+                if (scale > 0) {
+                    precision += 2;
+                } else {

Review Comment:
   why scale == 0 need +=1 ?



-- 
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: commits-unsubscribe@doris.apache.org

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