yiguolei commented on a change in pull request #8142:
URL: https://github.com/apache/incubator-doris/pull/8142#discussion_r810115301
##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
##########
@@ -659,6 +659,36 @@ public Integer getColumnSize() {
}
}
+ /**
+ * For schema change, convert data type to string,
+ * get the size of string representation
+ */
+ public Integer getColumnStringRepSize() {
+ if (!isScalarType()) return null;
+ if (isScalarType(PrimitiveType.FLOAT)) {
+ return 24; // see be/src/gutil/strings/numbers.h
+ }
+ if (isScalarType(PrimitiveType.DOUBLE)) {
+ return 32; // see be/src/gutil/strings/numbers.h
kDoubleToBufferSize
+ }
+ if (isNumericType()) {
+ Integer size = getPrecision() + 1; // +1 for minus symbol
+ if (isScalarType(PrimitiveType.DECIMALV2)) {
+ size += 1; // +1 for decimal point
+ }
+ return size;
+ }
+ ScalarType t = (ScalarType) this;
+ switch (t.getPrimitiveType()) {
+ case CHAR:
+ case VARCHAR:
+ case STRING:
+ return t.getLength();
+ default:
+ return null;
Review comment:
It is better to throw exception here?
--
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]