Skip to content

Commit 7c3f0a2

Browse files
committed
field length check
1 parent 31e7068 commit 7c3f0a2

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

oracle/oracle-side/oracle-async-side/src/main/java/com/dtstack/flink/sql/side/oracle/OracleAsyncSideInfo.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,13 @@
2525
import com.dtstack.flink.sql.side.rdb.table.RdbSideTableInfo;
2626
import com.dtstack.flink.sql.table.TableInfo;
2727
import com.dtstack.flink.sql.util.DtStringUtil;
28-
import com.dtstack.flink.sql.util.ParseUtils;
29-
import com.mchange.lang.CharUtils;
30-
import org.apache.calcite.sql.SqlNode;
3128
import org.apache.commons.lang3.StringUtils;
3229
import org.apache.flink.api.java.typeutils.RowTypeInfo;
33-
import com.google.common.collect.Lists;
34-
35-
import java.util.Arrays;
3630
import java.util.List;
3731

3832

3933
public class OracleAsyncSideInfo extends RdbAsyncSideInfo {
4034

41-
private final String SQL_DEFAULT_PLACEHOLDER = " ? ";
42-
private final String DEAL_CHAR_KEY = "char";
43-
private String RPAD_FORMAT = "rpad(?, %d, ' ')";
44-
45-
4635
public OracleAsyncSideInfo(RowTypeInfo rowTypeInfo, JoinInfo joinInfo, List<FieldInfo> outFieldInfoList, SideTableInfo sideTableInfo) {
4736
super(rowTypeInfo, joinInfo, outFieldInfoList, sideTableInfo);
4837
}
@@ -62,13 +51,16 @@ public String wrapperPlaceholder(String fieldName) {
6251
int pos = sideTableInfo.getFieldList().indexOf(fieldName);
6352
String type = sideTableInfo.getFieldTypeList().get(pos);
6453

65-
if (StringUtils.contains(type.toLowerCase(), DEAL_CHAR_KEY)) {
54+
String sqlDefaultPlaceholder = " ? ";
55+
String rpadFormat = "rpad(?, %d, ' ')";
56+
57+
if (StringUtils.contains(type.toLowerCase(), "char")) {
6658
TableInfo.FieldExtraInfo fieldExtraInfo = sideTableInfo.getFieldExtraInfoList().get(pos);
6759
int charLength = fieldExtraInfo == null ? 0 : fieldExtraInfo.getLength();
6860
if (charLength > 0) {
69-
return String.format(RPAD_FORMAT, charLength);
61+
return String.format(rpadFormat, charLength);
7062
}
7163
}
72-
return SQL_DEFAULT_PLACEHOLDER;
64+
return sqlDefaultPlaceholder;
7365
}
7466
}

rdb/rdb-side/src/main/java/com/dtstack/flink/sql/side/rdb/table/RdbSideTableInfo.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public boolean check() {
4747
Preconditions.checkNotNull(tableName, "rdb of tableName is required");
4848
Preconditions.checkNotNull(userName, "rdb of userName is required");
4949
Preconditions.checkNotNull(password, "rdb of password is required");
50+
Preconditions.checkArgument(getFieldList().size() == getFieldExtraInfoList().size(),
51+
"fields and fieldExtraInfoList attributes must be the same length");
5052
return true;
5153
}
5254

rdb/rdb-sink/src/main/java/com/dtstack/flink/sql/sink/rdb/table/RdbTableInfo.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public boolean check() {
144144
Preconditions.checkNotNull(tableName, "rdb field of tableName is required");
145145
Preconditions.checkNotNull(userName, "rdb field of userName is required");
146146
Preconditions.checkNotNull(password, "rdb field of password is required");
147+
Preconditions.checkArgument(getFieldList().size() == getFieldExtraInfoList().size(),
148+
"fields and fieldExtraInfoList attributes must be the same length");
147149
return true;
148150
}
149151

0 commit comments

Comments
 (0)