@@ -22,6 +22,8 @@ import com.amazon.deequ.metrics.Distribution
2222import com .amazon .deequ .metrics .DistributionValue
2323import com .amazon .deequ .metrics .DoubleMetric
2424import com .amazon .deequ .metrics .Entity
25+ import com .amazon .deequ .repository .ResultKey
26+ import com .amazon .deequ .repository .memory .InMemoryMetricsRepository
2527import com .amazon .deequ .utils .AssertionUtils .TryUtils
2628import com .amazon .deequ .utils .FixtureSupport
2729import org .apache .spark .sql .Row
@@ -534,6 +536,22 @@ class AnalyzerTests extends AnyWordSpec with Matchers with SparkContextSpec with
534536 )
535537 }
536538
539+ " datetimeDistribution analyzer with VerificationSuite" in withSparkSessionJava8APIEnabled { sparkSession =>
540+ val df = getDfWithLocalDateAndInstant(sparkSession)
541+ val repository = new InMemoryMetricsRepository
542+ val resultKey = ResultKey (0 , Map .empty)
543+ VerificationSuite ().onData(df).useRepository(repository)
544+ .addRequiredAnalyzer(DateTimeDistribution (" dateOfBirth" , DistributionInterval .DAILY ))
545+ .saveOrAppendResult(resultKey).run()
546+ val metric = repository.loadByKey(resultKey).get.allMetrics.head
547+ metric.value shouldBe Success (
548+ distributionFrom(
549+ (Instant .parse(" 2021-11-11T00:00:00Z" ), Instant .parse(" 2021-11-11T23:59:59.999Z" ), DistributionValue (3 , 0.6 )),
550+ (Instant .parse(" 2019-04-11T00:00:00Z" ), Instant .parse(" 2019-04-11T23:59:59.999Z" ), DistributionValue (2 , 0.4 ))
551+ )
552+ )
553+ }
554+
537555 " success get datetimeDistribution with Long Interval" in withSparkSessionJava8APIEnabled { sparkSession =>
538556 val df = getDfWithLocalDateAndInstant(sparkSession)
539557 val actualDistribution = DateTimeDistribution (" dateOfBirth" , 86400000L ).calculate(df).value
0 commit comments