Github user chemikadze commented on a diff in the pull request: https://github.com/apache/incubator-griffin/pull/434#discussion_r224150974 --- Diff: measure/src/main/scala/org/apache/griffin/measure/step/builder/dsl/transform/AccuracyExpr2DQSteps.scala --- @@ -125,14 +126,26 @@ case class AccuracyExpr2DQSteps(context: DQContext, // 4. accuracy metric val accuracyTableName = ruleParam.getOutDfName() val matchedColName = details.getStringOrKey(_matched) + val matchedFractionColName = details.getStringOrKey(_matchedFraction) val accuracyMetricSql = procType match { case BatchProcessType => s""" - |SELECT `${totalCountTableName}`.`${totalColName}` AS `${totalColName}`, - |coalesce(`${missCountTableName}`.`${missColName}`, 0) AS `${missColName}`, - |(`${totalCountTableName}`.`${totalColName}` - coalesce(`${missCountTableName}`.`${missColName}`, 0)) AS `${matchedColName}` - |FROM `${totalCountTableName}` LEFT JOIN `${missCountTableName}` - """.stripMargin + SELECT `${totalColName}`, + `${missColName}`, + `${matchedColName}`, + coalesce(`${matchedColName}` / `${totalColName}`, 1.0) AS `${matchedFractionColName}` + + FROM ( + SELECT `${totalColName}`, + `${missColName}`, + (`${totalColName}` - `${missColName}`) AS `${matchedColName}` --- End diff -- is it possible to compute `matchedFractionColName` here, without extra level of nesting?
---