Skip to content

Commit

Permalink
#169: Improve ApproxQuantile metrics instance description
Browse files Browse the repository at this point in the history
  • Loading branch information
romansegador authored and sscdotopen committed Nov 14, 2019
1 parent c7b906d commit 0436d5a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ case class ApproxQuantile(column: String, quantile: Double, relativeError: Doubl
state match {
case Some(theState) =>
val percentile = theState.percentileDigest.getPercentiles(Array(quantile)).head
Analyzers.metricFromValue(percentile, "ApproxQuantile", column)
Analyzers.metricFromValue(percentile, s"ApproxQuantile-$quantile", column)
case _ =>
Analyzers.metricFromEmpty(this, "ApproxQuantile", column)
Analyzers.metricFromEmpty(this, s"ApproxQuantile-$quantile", column)
}
}

override def toFailureMetric(exception: Exception): DoubleMetric = {
Analyzers.metricFromFailure(exception, "ApproxQuantile", column)
Analyzers.metricFromFailure(exception, s"ApproxQuantile-$quantile", column)
}

override def preconditions: Seq[StructType => Unit] = {
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/com/amazon/deequ/metrics/Metric.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ case class KeyedDoubleMetric(
override def flatten(): Seq[DoubleMetric] = {
if (value.isSuccess) {
value.get.map { case (key, correspondingValue) =>
DoubleMetric(entity, s"name-$key", instance, Success(correspondingValue))
DoubleMetric(entity, s"$name-$key", instance, Success(correspondingValue))
}
.toSeq
} else {
Seq(DoubleMetric(entity, s"name", instance, Failure(value.failed.get)))
Seq(DoubleMetric(entity, s"$name", instance, Failure(value.failed.get)))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class AnalysisTest extends WordSpec with Matchers with SparkContextSpec with Fix
Success(6.0)))
resultMetrics should contain(DoubleMetric(Entity.Column, "CountDistinct", "att1",
Success(6.0)))
resultMetrics should contain(DoubleMetric(Entity.Column, "ApproxQuantile", "att1",
resultMetrics should contain(DoubleMetric(Entity.Column, "ApproxQuantile-0.5", "att1",
Success(3.0)))
}

Expand Down

0 comments on commit 0436d5a

Please sign in to comment.