in measure/src/main/scala/org/apache/griffin/measure/step/builder/dsl/transform/CompletenessExpr2DQSteps.scala [203:242]
def getEachErrorWhereClause(errorConf: RuleErrorConfParam): String = {
val errorType: Option[String] = errorConf.getErrorType
val columnName: String = errorConf.getColumnName.get
if ("regex".equalsIgnoreCase(errorType.get)) {
// only have one regular expression
val regexValue: String = errorConf.getValues.head
val afterReplace: String = regexValue.replaceAll("""\\""", """\\\\""")
return s"(`$columnName` REGEXP '$afterReplace')"
} else if ("enumeration".equalsIgnoreCase(errorType.get)) {
val values: Seq[String] = errorConf.getValues
var inResult = ""
var nullResult = ""
if (values.contains("hive_none")) {
// hive_none means NULL
nullResult = s"`$columnName` IS NULL"
}
val valueWithQuote: String = values
.filter(value => !"hive_none".equals(value))
.map(value => s"'$value'")
.mkString(", ")
if (!StringUtils.isEmpty(valueWithQuote)) {
inResult = s"`$columnName` IN ($valueWithQuote)"
}
var result = ""
if (!StringUtils.isEmpty(inResult) && !StringUtils.isEmpty(nullResult)) {
result = s"($inResult OR $nullResult)"
} else if (!StringUtils.isEmpty(inResult)) {
result = s"($inResult)"
} else {
result = s"($nullResult)"
}
return result
}
throw new IllegalArgumentException(
"type in error.confs only supports regex and enumeration way")
}