Skip to content

Commit fc2fc08

Browse files
author
gituser
committed
Merge branch '1.8_release_3.10.x' into 1.8_release_4.0.x
2 parents d8e636d + 17ab509 commit fc2fc08

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

flinkx-core/src/main/java/com/dtstack/flinkx/constants/ConstantValue.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public class ConstantValue {
3838
public static final String LEFT_PARENTHESIS_SYMBOL = "(";
3939
public static final String RIGHT_PARENTHESIS_SYMBOL = ")";
4040

41+
42+
public static final String DATA_TYPE_UNSIGNED = "UNSIGNED";
43+
44+
4145
public static final String KEY_HTTP = "http";
4246

4347
public static final String PROTOCOL_HTTP = "http://";

flinkx-core/src/main/java/com/dtstack/flinkx/enums/ColumnType.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
package com.dtstack.flinkx.enums;
2020

2121
import com.dtstack.flinkx.constants.ConstantValue;
22+
import org.apache.commons.lang3.StringUtils;
2223

2324
import java.util.Arrays;
2425
import java.util.List;
26+
import java.util.Locale;
2527

2628
/**
2729
* Define standard column type for all the readers or writers that do not
@@ -66,6 +68,12 @@ public enum ColumnType {
6668
STRING, VARCHAR, VARCHAR2, CHAR, NVARCHAR, TEXT, KEYWORD, BINARY
6769
);
6870

71+
/**
72+
* 根据字段类型的字符串找出对应的枚举
73+
* 找不到直接报错 IllegalArgumentException
74+
* @param type
75+
* @return
76+
*/
6977
public static ColumnType fromString(String type) {
7078
if(type == null) {
7179
throw new RuntimeException("null ColumnType!");
@@ -75,15 +83,31 @@ public static ColumnType fromString(String type) {
7583
type = type.substring(0, type.indexOf(ConstantValue.LEFT_PARENTHESIS_SYMBOL));
7684
}
7785

78-
return valueOf(type.toUpperCase());
86+
type = type.toUpperCase(Locale.ENGLISH);
87+
//为了支持无符号类型 如 int unsigned
88+
if(StringUtils.contains(type,ConstantValue.DATA_TYPE_UNSIGNED)){
89+
type = type.replace(ConstantValue.DATA_TYPE_UNSIGNED,"").trim();
90+
}
91+
return valueOf(type);
7992
}
8093

94+
/**
95+
* 根据字段类型的字符串找到对应的枚举 找不到就直接返回ColumnType.STRING;
96+
* @param type
97+
* @return
98+
*/
8199
public static ColumnType getType(String type){
100+
type = type.toUpperCase(Locale.ENGLISH);
82101
if(type.contains(ConstantValue.LEFT_PARENTHESIS_SYMBOL)){
83102
type = type.substring(0, type.indexOf(ConstantValue.LEFT_PARENTHESIS_SYMBOL));
84103
}
85104

86-
if(type.toLowerCase().contains(ColumnType.TIMESTAMP.name().toLowerCase())){
105+
//为了支持无符号类型 如 int unsigned
106+
if(StringUtils.contains(type,ConstantValue.DATA_TYPE_UNSIGNED)){
107+
type = type.replaceAll(ConstantValue.DATA_TYPE_UNSIGNED,"").trim();
108+
}
109+
110+
if(type.contains(ColumnType.TIMESTAMP.name())){
87111
return TIMESTAMP;
88112
}
89113

0 commit comments

Comments
 (0)