Skip to content

Commit 070cbd9

Browse files
committed
integer unsigned parse
1 parent 450bfa5 commit 070cbd9

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

core/src/main/java/com/dtstack/flink/sql/util/ClassUtil.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.math.BigDecimal;
2424
import java.sql.Date;
25+
import java.sql.Time;
2526
import java.sql.Timestamp;
2627

2728
/**
@@ -35,22 +36,29 @@ public class ClassUtil {
3536
public static Class<?> stringConvertClass(String str) {
3637
switch (str.toLowerCase()) {
3738
case "boolean":
39+
case "bit":
3840
return Boolean.class;
3941

4042
case "integer":
4143
case "int":
44+
case "mediumint":
45+
case "tinyint":
4246
return Integer.class;
4347

48+
case "blob":
49+
return Byte.class;
50+
4451
case "bigint":
52+
case "intunsigned":
53+
case "integerunsigned":
4554
return Long.class;
4655

47-
case "tinyint":
48-
return Byte.class;
49-
5056
case "smallint":
5157
return Short.class;
5258

5359
case "varchar":
60+
case "char":
61+
case "text":
5462
return String.class;
5563

5664
case "real":
@@ -63,9 +71,13 @@ public static Class<?> stringConvertClass(String str) {
6371
case "date":
6472
return Date.class;
6573

74+
case "datetime":
6675
case "timestamp":
6776
return Timestamp.class;
6877

78+
case "time":
79+
return Time.class;
80+
6981
case "decimal":
7082
return BigDecimal.class;
7183

rdb/rdb-side/src/main/java/com/dtstack/flink/sql/side/rdb/util/SwitchUtil.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,47 @@ public class SwitchUtil {
3030
public static Object getTarget(Object obj, String targetType) {
3131
targetType = targetType.toLowerCase();
3232
switch (targetType) {
33+
34+
case "tinyint":
3335
case "int":
3436
case "integer":
37+
case "mediumint":
3538
return MathUtil.getIntegerVal(obj);
39+
3640
case "bigint":
41+
case "intunsigned":
42+
case "integerunsigned":
3743
return MathUtil.getLongVal(obj);
44+
3845
case "boolean":
3946
return MathUtil.getBoolean(obj);
40-
case "tinyint":
47+
48+
case "blob":
4149
return MathUtil.getByte(obj);
50+
4251
case "smallint":
4352
return MathUtil.getShort(obj);
53+
4454
case "varchar":
55+
case "char":
56+
case "text":
4557
return MathUtil.getString(obj);
58+
4659
case "real":
4760
case "float":
4861
return MathUtil.getFloatVal(obj);
62+
4963
case "double":
5064
return MathUtil.getDoubleVal(obj);
65+
5166
case "decimal":
5267
return MathUtil.getBigDecimal(obj);
68+
5369
case "date":
5470
return MathUtil.getDate(obj);
71+
5572
case "timestamp":
73+
case "datetime":
5674
return MathUtil.getTimestamp(obj);
5775
}
5876
return obj;

0 commit comments

Comments
 (0)