From 0436d5a57a67491841b2ccb70aebc38ab0bf9658 Mon Sep 17 00:00:00 2001 From: romansegador Date: Thu, 14 Nov 2019 13:21:59 +0100 Subject: [PATCH] #169: Improve ApproxQuantile metrics instance description --- .../scala/com/amazon/deequ/analyzers/ApproxQuantile.scala | 6 +++--- src/main/scala/com/amazon/deequ/metrics/Metric.scala | 4 ++-- .../scala/com/amazon/deequ/analyzers/AnalysisTest.scala | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/amazon/deequ/analyzers/ApproxQuantile.scala b/src/main/scala/com/amazon/deequ/analyzers/ApproxQuantile.scala index ccbd3472a..bd6d91546 100644 --- a/src/main/scala/com/amazon/deequ/analyzers/ApproxQuantile.scala +++ b/src/main/scala/com/amazon/deequ/analyzers/ApproxQuantile.scala @@ -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] = { diff --git a/src/main/scala/com/amazon/deequ/metrics/Metric.scala b/src/main/scala/com/amazon/deequ/metrics/Metric.scala index e1b347170..0964d160a 100644 --- a/src/main/scala/com/amazon/deequ/metrics/Metric.scala +++ b/src/main/scala/com/amazon/deequ/metrics/Metric.scala @@ -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))) } } } diff --git a/src/test/scala/com/amazon/deequ/analyzers/AnalysisTest.scala b/src/test/scala/com/amazon/deequ/analyzers/AnalysisTest.scala index 5d4d5ef64..5036ae185 100644 --- a/src/test/scala/com/amazon/deequ/analyzers/AnalysisTest.scala +++ b/src/test/scala/com/amazon/deequ/analyzers/AnalysisTest.scala @@ -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))) }