LittleZhao commented on a change in pull request #538: [GRIFFIN-289]New feature
for griffin COMPLETENESS dq type
URL: https://github.com/apache/griffin/pull/538#discussion_r332411787
##########
File path:
measure/src/main/scala/org/apache/griffin/measure/step/builder/dsl/transform/CompletenessExpr2DQSteps.scala
##########
@@ -167,4 +175,46 @@ case class CompletenessExpr2DQSteps(context: DQContext,
}
}
+ /**
+ * get 'error' where clause
+ * @param errorConfs error configuraion list
+ * @return 'error' where clause
+ */
+ def getErrorConfCompleteWhereClause(errorConfs: Seq[RuleErrorConfParam]):
String = {
+ errorConfs.map(errorConf =>
this.getEachErrorWhereClause(errorConf)).mkString(" OR ")
+ }
+
+ /**
+ * get error sql for each column
+ * @param errorConf error configuration
+ * @return 'error' sql for each column
+ */
+ 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.apply(0)
+ val afterReplace: String = regexValue.replaceAll("""\\""", """\\\\""")
+ val result: String = s"`${columnName}` REGEXP '${afterReplace}'"
+ return result
+ } else if ("enumeration".equalsIgnoreCase(errorType.get)) {
+ val values: Seq[String] = errorConf.getValues
+ // hive_none means None
+ var hasNone: Boolean = false
+ if (values.contains("hive_none")) {
+ hasNone = true
+ }
+
+ val valueWithQuote: String = values.filter(value =>
!"hive_none".equals(value))
+ .map(value => s"'${value}'").mkString(", ")
Review comment:
@guoyuepeng could you please close this PR, or is there anything should I
do?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services