|
@@ -0,0 +1,37 @@
|
|
|
+package com.winhc.bigdata.udf.biz;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.aliyun.odps.udf.UDF;
|
|
|
+import com.aliyun.odps.utils.StringUtils;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author: XuJiakai
|
|
|
+ * 2021/10/26 09:50
|
|
|
+ */
|
|
|
+@Deprecated
|
|
|
+public class BinlogParsePro extends UDF {
|
|
|
+
|
|
|
+ private String evl(String data, String field) {
|
|
|
+ if (StringUtils.isEmpty(data)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONArray array = JSON.parseArray(data);
|
|
|
+ JSONObject jsonObject = array.getJSONObject(0);
|
|
|
+ String key = field.toUpperCase();
|
|
|
+ String string = jsonObject.getString(key);
|
|
|
+ return string;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public String evaluate(String data, String old_data, String type, String field, String new_or_old) {
|
|
|
+ if ("old".equals(new_or_old)) {
|
|
|
+ return evl(old_data, field);
|
|
|
+ } else if ("new".equals(new_or_old)) {
|
|
|
+ return evl(data, field);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("new or old !");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|