Compare commits
No commits in common. "c35a6151bc90c19c45b0b8fa3c62375ecfc92450" and "0bcb7cdf15c16a65e201f829264ada15814d03a9" have entirely different histories.
c35a6151bc
...
0bcb7cdf15
@ -1,20 +0,0 @@
|
|||||||
package cn.datax.service.data.quality.api.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ch
|
|
||||||
* @date 2023/12/25 17:18
|
|
||||||
*
|
|
||||||
* 正则校验
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class Regular implements Serializable {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则表达
|
|
||||||
*/
|
|
||||||
private String regular;
|
|
||||||
}
|
|
@ -32,11 +32,4 @@ public class RuleConfig implements Serializable {
|
|||||||
* 准确性
|
* 准确性
|
||||||
*/
|
*/
|
||||||
private Accuracy accuracy;
|
private Accuracy accuracy;
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则表达
|
|
||||||
*/
|
|
||||||
|
|
||||||
private Regular regular;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,6 @@ public enum RuleItem {
|
|||||||
Integrity("integrity_key", "验证表中必须出现的字段非空"),
|
Integrity("integrity_key", "验证表中必须出现的字段非空"),
|
||||||
Relevance("relevance_key", "验证关联性"),
|
Relevance("relevance_key", "验证关联性"),
|
||||||
Timeliness("timeliness_key", "验证及时性"),
|
Timeliness("timeliness_key", "验证及时性"),
|
||||||
Regular("regular_key","正则表达式"),
|
|
||||||
|
|
||||||
Consistent("consistent_key", "验证用户指定的字段枚举值是否合乎要求");
|
Consistent("consistent_key", "验证用户指定的字段枚举值是否合乎要求");
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
package cn.datax.service.data.quality.schedule.rules;
|
|
||||||
|
|
||||||
import cn.datax.common.database.constants.DbType;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ch
|
|
||||||
* @date 2023/12/25 18:14
|
|
||||||
*/
|
|
||||||
public class RegularRule implements RuleItem{
|
|
||||||
private static String REGULAR = "regular";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String parse(DbType dbType, String table, String column, Map<String, Object> map) {
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
|
||||||
switch (dbType) {
|
|
||||||
case ORACLE:
|
|
||||||
case ORACLE_12C:
|
|
||||||
builder.append("SELECT SUM(CASE WHEN ROUND(TO_NUMBER(SYSDATE - ").append(column).append(")) >= ").append(map.get(REGULAR)).append(" THEN 1 ELSE 0 END), COUNT(*) FROM ").append(table);
|
|
||||||
break;
|
|
||||||
case MYSQL:
|
|
||||||
builder.append("select sum(case when ").append(column).append(" REGEXP ").append("'"+map.get(REGULAR)+"'").append(" != '' THEN 0 ELSE 1 END),")
|
|
||||||
.append(" COUNT(*) from ").append(table);
|
|
||||||
case MARIADB:
|
|
||||||
case SQL_SERVER:
|
|
||||||
case SQL_SERVER2008:
|
|
||||||
case POSTGRE_SQL:
|
|
||||||
case OTHER:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String code() {
|
|
||||||
return "timeliness_key";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,5 @@
|
|||||||
package cn.datax.service.data.quality.schedule.rules;
|
package cn.datax.service.data.quality.schedule.rules;
|
||||||
|
|
||||||
import cn.datax.service.data.quality.api.dto.Regular;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -15,7 +13,6 @@ public class RuleItemRegistry {
|
|||||||
this.rule_item_map.put("integrity_key", new IntegrityRule());
|
this.rule_item_map.put("integrity_key", new IntegrityRule());
|
||||||
this.rule_item_map.put("relevance_key", new RelevanceRule());
|
this.rule_item_map.put("relevance_key", new RelevanceRule());
|
||||||
this.rule_item_map.put("timeliness_key", new TimelinessRule());
|
this.rule_item_map.put("timeliness_key", new TimelinessRule());
|
||||||
this.rule_item_map.put("regular_key", new RegularRule());
|
|
||||||
this.rule_item_map.put("accuracy_key_length", new AccuracyLengthRule());
|
this.rule_item_map.put("accuracy_key_length", new AccuracyLengthRule());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,12 @@ import cn.datax.common.base.BaseServiceImpl;
|
|||||||
import cn.datax.common.core.RedisConstant;
|
import cn.datax.common.core.RedisConstant;
|
||||||
import cn.datax.common.database.constants.DbType;
|
import cn.datax.common.database.constants.DbType;
|
||||||
import cn.datax.common.redis.service.RedisService;
|
import cn.datax.common.redis.service.RedisService;
|
||||||
import cn.datax.service.data.quality.api.dto.*;
|
import cn.datax.service.data.quality.api.dto.Accuracy;
|
||||||
|
import cn.datax.service.data.quality.api.dto.CheckRuleDto;
|
||||||
|
import cn.datax.service.data.quality.api.dto.Consistent;
|
||||||
|
import cn.datax.service.data.quality.api.dto.Relevance;
|
||||||
|
import cn.datax.service.data.quality.api.dto.RuleConfig;
|
||||||
|
import cn.datax.service.data.quality.api.dto.Timeliness;
|
||||||
import cn.datax.service.data.quality.api.entity.CheckRuleEntity;
|
import cn.datax.service.data.quality.api.entity.CheckRuleEntity;
|
||||||
import cn.datax.service.data.quality.api.enums.RuleItem;
|
import cn.datax.service.data.quality.api.enums.RuleItem;
|
||||||
import cn.datax.service.data.quality.dao.CheckRuleDao;
|
import cn.datax.service.data.quality.dao.CheckRuleDao;
|
||||||
@ -127,11 +132,6 @@ public class CheckRuleServiceImpl extends BaseServiceImpl<CheckRuleDao, CheckRul
|
|||||||
Accuracy accuracy = ruleConfig.getAccuracy();
|
Accuracy accuracy = ruleConfig.getAccuracy();
|
||||||
map.put("max_length", accuracy.getMaxLength());
|
map.put("max_length", accuracy.getMaxLength());
|
||||||
break;
|
break;
|
||||||
// 正则表达
|
|
||||||
case Regular:
|
|
||||||
Regular regular = ruleConfig.getRegular();
|
|
||||||
map.put("regular", regular.getRegular());
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user