Skip to content

Commit

Permalink
1. Added null check in TDengineSinkWriter's convertDataType method
Browse files Browse the repository at this point in the history
2. related code change in test case
  • Loading branch information
edisonX-sudo committed Apr 19, 2024
1 parent 256640b commit 63c8041
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ private Object[] convertDataType(Object[] objects) {
return Arrays.stream(objects)
.map(
object -> {
if (object == null) {
log.debug("fast fail 2 prevent null exception followed");
return "null";
}
if (LocalDateTime.class.equals(object.getClass())) {
// transform timezone according to the config
return "'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ private void read(TDengineSourceSplit split, Collector<SeaTunnelRow> output) thr
}

private Object convertDataType(Object object) {
if(object == null){
if (object == null) {
log.debug("fast fail 2 prevent null exception followed");
return null;
}
if (Timestamp.class.equals(object.getClass())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private static List<String> getRawData() {
"d1001,2018-10-03 14:38:05.000,10.30000,219,0.31000,'California.SanFrancisco',2,true",
"d1001,2018-10-03 14:38:15.000,12.60000,218,0.33000,'California.SanFrancisco',2,false",
"d1001,2018-10-03 14:38:16.800,12.30000,221,0.31000,'California.SanFrancisco',2,true",
"d1002,2018-10-03 14:38:16.650,10.30000,218,0.25000,'California.SanFrancisco',3,true",
"d1002,2018-10-03 14:38:16.650,10.30000,null,0.25000,'California.SanFrancisco',3,true",//without reader/sinker null checker,data like this will cause null-exception
"d1003,2018-10-03 14:38:05.500,11.80000,221,0.28000,'California.LosAngeles',2,true",
"d1003,2018-10-03 14:38:16.600,13.40000,223,0.29000,'California.LosAngeles',2,true",
"d1004,2018-10-03 14:38:05.000,10.80000,223,0.29000,'California.LosAngeles',3,true",
Expand Down

0 comments on commit 63c8041

Please sign in to comment.