!224 修复starrocks字符串类型的判断&&填充列remark时提前跳出循环

* 填充列remark时提前跳出循环
* 修复sr字符串类型的判断
This commit is contained in:
茶叶蛋
2024-12-06 11:20:03 +00:00
committed by inrgihc
parent 88955ac6e5
commit 3305ef0ce9
2 changed files with 13 additions and 24 deletions

View File

@@ -157,6 +157,8 @@ public abstract class AbstractMetadataProvider
for (ColumnDescription cd : ret) { for (ColumnDescription cd : ret) {
if (columnName.equals(cd.getFieldName())) { if (columnName.equals(cd.getFieldName())) {
cd.setRemarks(remarks); cd.setRemarks(remarks);
//break out of the loop early
break;
} }
} }
} }

View File

@@ -274,7 +274,9 @@ public class StarrocksMetadataQueryProvider extends AbstractMetadataProvider {
case ColumnMetaData.TYPE_BIGNUMBER: case ColumnMetaData.TYPE_BIGNUMBER:
if (null != pks && !pks.isEmpty() && pks.contains(fieldname)) { if (null != pks && !pks.isEmpty() && pks.contains(fieldname)) {
if (useAutoInc) { if (useAutoInc) {
retval += "BIGINT AUTO_INCREMENT NOT NULL"; //see: https://docs.starrocks.io/zh/docs/sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE/#column_definition
//fix: AUTO_INCREMENT should be after not null
retval += "BIGINT NOT NULL AUTO_INCREMENT";
} else { } else {
retval += "BIGINT NOT NULL"; retval += "BIGINT NOT NULL";
} }
@@ -310,30 +312,15 @@ public class StarrocksMetadataQueryProvider extends AbstractMetadataProvider {
} }
break; break;
case ColumnMetaData.TYPE_STRING: case ColumnMetaData.TYPE_STRING:
if (length > 0) { //see: https://docs.starrocks.io/zh/docs/category/string/
if (length == 1) { if (length <= 255) {
retval += "CHAR(1)"; retval += "CHAR(" + length + ")";
} else if (length < 256) { } else if (length <= 65533) {
retval += "VARCHAR(" + length * 2 + ")"; retval += "STRING";
} else if (null != pks && !pks.isEmpty() && pks.contains(fieldname)) { } else if (length <= 1048576){
/* retval += "VARCHAR(" + length + ")";
* MySQL5.6中varchar字段为主键时最大长度为254,例如如下的建表语句在MySQL5.7下能通过但在MySQL5.6下无法通过:
* create table `t_test`(
* `key` varchar(1024) binary,
* `val` varchar(1024) binary,
* primary key(`key`)
* );
*/
retval += "VARCHAR(254) BINARY";
} else if (length < 65536) {
retval += "TEXT";
} else if (length < 16777216) {
retval += "MEDIUMTEXT";
} else {
retval += "LONGTEXT";
}
} else { } else {
retval += "TINYTEXT"; retval += "VARBINARY";
} }
break; break;
case ColumnMetaData.TYPE_BINARY: case ColumnMetaData.TYPE_BINARY: