Skip to content

Commit e7ea151

Browse files
committed
hotfix 31226 json转换失败 日志取消
1 parent 0439225 commit e7ea151

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

flinkx-hive/flinkx-hive-writer/src/main/java/com/dtstack/flinkx/hive/writer/HiveOutputFormat.java

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@
3030
import com.dtstack.flinkx.restore.FormatState;
3131
import com.dtstack.flinkx.util.ExceptionUtil;
3232
import com.dtstack.flinkx.util.GsonUtil;
33-
import com.google.common.collect.Maps;
3433
import com.google.gson.JsonSyntaxException;
35-
import org.apache.commons.collections.CollectionUtils;
3634
import org.apache.commons.collections.MapUtils;
3735
import org.apache.commons.math3.util.Pair;
3836
import org.apache.flink.types.Row;
3937
import org.apache.hadoop.conf.Configuration;
4038

4139
import java.io.IOException;
4240
import java.io.Serializable;
43-
import java.util.*;
41+
import java.util.HashMap;
42+
import java.util.Iterator;
43+
import java.util.List;
44+
import java.util.Map;
4445

4546
/**
4647
* @author toutian
@@ -193,25 +194,11 @@ public void writeRecord(Row row) throws IOException {
193194
event = (Map) tempObj;
194195
} else if (tempObj instanceof String) {
195196
try {
196-
List<String> columns = tableInfos.entrySet().iterator().next().getValue().getColumns();
197-
//如果写入的hive表字段包含column message,并且tempObj不符合简单json定义【以{开头 以}结尾】,同时不以message开头 则直接将tempObj作为value
198-
if(CollectionUtils.isNotEmpty(columns) && columns.size()==1 && columns.get(0).equals("message")){
199-
String data = (String) tempObj;
200-
if(!data.startsWith("{") || !data.endsWith("}") || !data.substring(1,data.length()-1).trim().startsWith("\"message\":")){
201-
event = Collections.singletonMap("message",data);
202-
}
203-
}else{
204-
event = GsonUtil.GSON.fromJson((String) tempObj, GsonUtil.gsonMapTypeToken);
205-
}
197+
event = GsonUtil.GSON.fromJson((String) tempObj, GsonUtil.gsonMapTypeToken);
206198
}catch (JsonSyntaxException e){
207-
208-
List<String> columns = tableInfos.entrySet().iterator().next().getValue().getColumns();
209-
//如果hive没有message column,那么认为是脏数据 打印日志
210-
if(CollectionUtils.isNotEmpty(columns) && !columns.contains("message")){
211-
LOG.warn("bad json string:【{}】", tempObj);
212-
}
213199
// is not a json string
214-
event = Collections.singletonMap("message",tempObj);
200+
//tempObj 不是map类型 则event直接往下传递
201+
// LOG.warn("bad json string:【{}】", tempObj);
215202
}
216203
}
217204
}

0 commit comments

Comments
 (0)