Skip to content

Commit

Permalink
Merge branch '1.5_v3.6.0' into v1.5.0_dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	core/src/main/java/com/dtstack/flink/sql/Main.java
#	core/src/main/java/com/dtstack/flink/sql/side/SideSqlExec.java
  • Loading branch information
zoudaokoulife committed Jul 25, 2019
2 parents 7ebe1c1 + 38f39fa commit 235dcc8
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target/
plugins/
lib/
.vertx/
.DS_Store
bin/nohup.out
.DS_Store
bin/sideSql.txt
30 changes: 24 additions & 6 deletions core/src/main/java/com/dtstack/flink/sql/util/ClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;

/**
Expand All @@ -35,38 +36,55 @@ public class ClassUtil {
public static Class<?> stringConvertClass(String str) {
switch (str.toLowerCase()) {
case "boolean":
case "bit":
return Boolean.class;

case "smallint":
case "smallintunsigned":
case "tinyint":
case "tinyintunsigned":
case "mediumint":
case "mediumintunsigned":
case "integer":
case "int":
return Integer.class;

case "bigint":
return Long.class;

case "tinyint":
case "blob":
return Byte.class;

case "smallint":
return Short.class;
case "bigint":
case "intunsigned":
case "integerunsigned":
case "bigintunsigned":
return Long.class;

case "varchar":
case "char":
case "text":
return String.class;

case "real":
case "float":
case "realunsigned":
case "floatunsigned":
return Float.class;

case "double":
case "doubleunsigned":
return Double.class;

case "date":
return Date.class;

case "datetime":
case "timestamp":
return Timestamp.class;

case "time":
return Time.class;

case "decimal":
case "decimalunsigned":
return BigDecimal.class;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ public static List<String> splitIgnoreQuota(String str, char delimiter){
List<String> tokensList = new ArrayList<>();
boolean inQuotes = false;
boolean inSingleQuotes = false;
int bracketLeftNum = 0;
StringBuilder b = new StringBuilder();
for (char c : str.toCharArray()) {
if(c == delimiter){
if (inQuotes) {
b.append(c);
} else if(inSingleQuotes){
b.append(c);
} else if(bracketLeftNum > 0){
b.append(c);
}else {
tokensList.add(b.toString());
b = new StringBuilder();
Expand All @@ -74,6 +77,12 @@ public static List<String> splitIgnoreQuota(String str, char delimiter){
}else if(c == '\''){
inSingleQuotes = !inSingleQuotes;
b.append(c);
}else if(c == '('){
bracketLeftNum++;
b.append(c);
}else if(c == ')'){
bracketLeftNum--;
b.append(c);
}else{
b.append(c);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,52 @@ public class SwitchUtil {
public static Object getTarget(Object obj, String targetType) {
targetType = targetType.toLowerCase();
switch (targetType) {
case "int":

case "smallint":
case "smallintunsigned":
case "tinyint":
case "tinyintunsigned":
case "mediumint":
case "mediumintunsigned":
case "integer":
case "int":
return MathUtil.getIntegerVal(obj);

case "bigint":
case "intunsigned":
case "integerunsigned":
return MathUtil.getLongVal(obj);

case "boolean":
return MathUtil.getBoolean(obj);
case "tinyint":

case "blob":
return MathUtil.getByte(obj);
case "smallint":
return MathUtil.getShort(obj);

case "varchar":
case "char":
case "text":
return MathUtil.getString(obj);

case "real":
case "float":
case "realunsigned":
case "floatunsigned":
return MathUtil.getFloatVal(obj);

case "double":
case "doubleunsigned":
return MathUtil.getDoubleVal(obj);

case "decimal":
case "decimalunsigned":
return MathUtil.getBigDecimal(obj);

case "date":
return MathUtil.getDate(obj);

case "timestamp":
case "datetime":
return MathUtil.getTimestamp(obj);
}
return obj;
Expand Down

0 comments on commit 235dcc8

Please sign in to comment.