Github user ashutakGG commented on a diff in the pull request:
https://github.com/apache/incubator-griffin/pull/434#discussion_r224425167
--- 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 --
Whole point of nesting levels here to increase readability. Now, I have an
idea where it will "good enough" to read even with 1 level of nesting.
---