This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 41838e6acb [fix](string-type) rectify string type' len to MAX_STRING_LENGTH (#14985) 41838e6acb is described below commit 41838e6acbf07b8a46ada599457094b64a9ca9e8 Author: Mingyu Chen <morning...@163.com> AuthorDate: Wed Dec 14 15:41:08 2022 +0800 [fix](string-type) rectify string type' len to MAX_STRING_LENGTH (#14985) cherry pick from #14587 --- .../src/main/java/org/apache/doris/catalog/Column.java | 15 ++++++++++++++- .../src/main/java/org/apache/doris/catalog/Type.java | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java index 532a49b0eb..4432db3335 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java @@ -29,6 +29,7 @@ import org.apache.doris.common.DdlException; import org.apache.doris.common.io.Text; import org.apache.doris.common.io.Writable; import org.apache.doris.common.util.SqlUtils; +import org.apache.doris.persist.gson.GsonPostProcessable; import org.apache.doris.persist.gson.GsonUtils; import org.apache.doris.thrift.TColumn; import org.apache.doris.thrift.TColumnType; @@ -52,7 +53,7 @@ import java.util.Set; /** * This class represents the column-related metadata. */ -public class Column implements Writable { +public class Column implements Writable, GsonPostProcessable { private static final Logger LOG = LogManager.getLogger(Column.class); public static final String DELETE_SIGN = "__DORIS_DELETE_SIGN__"; public static final String SEQUENCE_COL = "__DORIS_SEQUENCE_COL__"; @@ -699,4 +700,16 @@ public class Column implements Writable { public void setCompoundKey(boolean compoundKey) { isCompoundKey = compoundKey; } + + @Override + public void gsonPostProcess() throws IOException { + // This just for bugfix. Because when user upgrade from 0.x to 1.1.x, + // the length of String type become 1. The reason is not very clear and maybe fixed by #14275. + // Here we try to rectify the error string length, by setting all String' length to MAX_STRING_LENGTH + // when replaying edit log. + if (type.isScalarType() && type.getPrimitiveType() == PrimitiveType.STRING + && type.getLength() != ScalarType.MAX_STRING_LENGTH) { + ((ScalarType) type).setLength(ScalarType.MAX_STRING_LENGTH); + } + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java index 949c4a3e79..b8ee68aacd 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java @@ -65,9 +65,9 @@ public abstract class Type { public static final ScalarType DATEV2 = new ScalarType(PrimitiveType.DATEV2); public static final ScalarType TIMEV2 = new ScalarType(PrimitiveType.TIMEV2); public static final ScalarType TIME = new ScalarType(PrimitiveType.TIME); - public static final ScalarType STRING = new ScalarType(PrimitiveType.STRING); + public static final ScalarType STRING = ScalarType.createStringType(); public static final ScalarType DEFAULT_DECIMALV2 = ScalarType.createDecimalType(PrimitiveType.DECIMALV2, - ScalarType.DEFAULT_PRECISION, ScalarType.DEFAULT_SCALE); + ScalarType.DEFAULT_PRECISION, ScalarType.DEFAULT_SCALE); public static final ScalarType MAX_DECIMALV2_TYPE = ScalarType.createDecimalType(PrimitiveType.DECIMALV2, ScalarType.MAX_DECIMALV2_PRECISION, ScalarType.MAX_DECIMALV2_SCALE); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org