Skip to content

Commit dba0d55

Browse files
committed
RdbAsyncReqRow convertDataType
1 parent 507e4cb commit dba0d55

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

rdb/rdb-side/src/main/java/com/dtstack/flink/sql/side/rdb/async/RdbAsyncReqRow.java

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
import org.slf4j.Logger;
4040
import org.slf4j.LoggerFactory;
4141

42+
import java.math.BigDecimal;
4243
import java.sql.Timestamp;
44+
import java.time.Instant;
4345
import java.util.Date;
4446
import java.util.List;
4547
import java.util.Map;
@@ -87,7 +89,7 @@ public void asyncInvoke(Row input, ResultFuture<Row> resultFuture) throws Except
8789
dealMissKey(inputRow, resultFuture);
8890
return;
8991
}
90-
inputParams.add(convertDateType(equalObj));
92+
inputParams.add(convertDataType(equalObj));
9193
}
9294

9395
String key = buildCacheKey(inputParams);
@@ -151,15 +153,43 @@ public void asyncInvoke(Row input, ResultFuture<Row> resultFuture) throws Except
151153
});
152154
}
153155

154-
private Object convertDateType(Object val) {
155-
if (val instanceof Timestamp) {
156+
157+
private Object convertDataType(Object val) {
158+
if (val == null) {
159+
// OK
160+
} else if (val instanceof Number && !(val instanceof BigDecimal)) {
161+
// OK
162+
} else if (val instanceof Boolean) {
163+
// OK
164+
} else if (val instanceof String) {
165+
// OK
166+
} else if (val instanceof Character) {
167+
// OK
168+
} else if (val instanceof CharSequence) {
169+
170+
} else if (val instanceof JsonObject) {
171+
172+
} else if (val instanceof JsonArray) {
173+
174+
} else if (val instanceof Map) {
175+
176+
} else if (val instanceof List) {
177+
178+
} else if (val instanceof byte[]) {
179+
180+
} else if (val instanceof Instant) {
181+
182+
} else if (val instanceof Timestamp) {
156183
val = DateUtil.getStringFromTimestamp((Timestamp) val);
157-
} else if (val instanceof Date) {
184+
} else if (val instanceof java.util.Date) {
158185
val = DateUtil.getStringFromDate((java.sql.Date) val);
186+
} else {
187+
val = val.toString();
159188
}
160189
return val;
161190
}
162191

192+
163193
protected List<Row> getRows(Row inputRow, List<JsonArray> cacheContent, List<JsonArray> results) {
164194
List<Row> rowList = Lists.newArrayList();
165195
for (JsonArray line : results) {

0 commit comments

Comments
 (0)