diff --git a/src/main/scala/com/amazon/deequ/constraints/AnalysisBasedConstraint.scala b/src/main/scala/com/amazon/deequ/constraints/AnalysisBasedConstraint.scala index e1a530c97..02f7145ac 100644 --- a/src/main/scala/com/amazon/deequ/constraints/AnalysisBasedConstraint.scala +++ b/src/main/scala/com/amazon/deequ/constraints/AnalysisBasedConstraint.scala @@ -74,7 +74,10 @@ private[deequ] case class AnalysisBasedConstraint[S <: State[S], M, V]( val assertionOk = runAssertion(assertOn) if (assertionOk) { - ConstraintResult(this, ConstraintStatus.Success, metric = Some(metric)) + var successMessage = s"Value: $assertOn meets the constraint requirement." + hint.foreach(hint => successMessage += s" $hint") + + ConstraintResult(this, ConstraintStatus.Success, Some(successMessage), Some(metric)) } else { var errorMessage = s"Value: $assertOn does not meet the constraint requirement!" hint.foreach(hint => errorMessage += s" $hint") diff --git a/src/test/scala/com/amazon/deequ/VerificationResultTest.scala b/src/test/scala/com/amazon/deequ/VerificationResultTest.scala index 43c51e759..595c9035f 100644 --- a/src/test/scala/com/amazon/deequ/VerificationResultTest.scala +++ b/src/test/scala/com/amazon/deequ/VerificationResultTest.scala @@ -124,11 +124,11 @@ class VerificationResultTest extends WordSpec with Matchers with SparkContextSpe import session.implicits._ val expected = Seq( ("group-1", "Error", "Success", "CompletenessConstraint(Completeness(att1,None))", - "Success", ""), + "Success", "Value: 1.0 meets the constraint requirement."), ("group-2-E", "Error", "Error", "SizeConstraint(Size(None))", "Failure", "Value: 4 does not meet the constraint requirement! Should be greater than 5!"), ("group-2-E", "Error", "Error", "CompletenessConstraint(Completeness(att2,None))", - "Success", ""), + "Success", "Value: 1.0 meets the constraint requirement. Should equal 1!"), ("group-2-W", "Warning", "Warning", "DistinctnessConstraint(Distinctness(List(item),None))", "Failure", "Value: 1.0 does not meet the constraint requirement! " + @@ -151,7 +151,8 @@ class VerificationResultTest extends WordSpec with Matchers with SparkContextSpe val expectedJson = """[{"check":"group-1","check_level":"Error","check_status":"Success", |"constraint":"CompletenessConstraint(Completeness(att1,None))", - |"constraint_status":"Success","constraint_message":""}, + |"constraint_status":"Success", + |"constraint_message":"Value: 1.0 meets the constraint requirement."}, | |{"check":"group-2-E","check_level":"Error","check_status":"Error", |"constraint":"SizeConstraint(Size(None))", "constraint_status":"Failure", @@ -160,7 +161,9 @@ class VerificationResultTest extends WordSpec with Matchers with SparkContextSpe | |{"check":"group-2-E","check_level":"Error","check_status":"Error", |"constraint":"CompletenessConstraint(Completeness(att2,None))", - |"constraint_status":"Success","constraint_message":""}, + |"constraint_status":"Success", + |"constraint_message":"Value: 1.0 meets the constraint requirement. + | Should equal 1!"}, | |{"check":"group-2-W","check_level":"Warning","check_status":"Warning", |"constraint":"DistinctnessConstraint(Distinctness(List(item),None))", diff --git a/src/test/scala/com/amazon/deequ/constraints/AnalysisBasedConstraintTest.scala b/src/test/scala/com/amazon/deequ/constraints/AnalysisBasedConstraintTest.scala index b7657ef29..c3dad91cb 100644 --- a/src/test/scala/com/amazon/deequ/constraints/AnalysisBasedConstraintTest.scala +++ b/src/test/scala/com/amazon/deequ/constraints/AnalysisBasedConstraintTest.scala @@ -83,7 +83,7 @@ class AnalysisBasedConstraintTest extends WordSpec with Matchers with SparkConte SampleAnalyzer("att1"), _ == 1.0), df) assert(resultA.status == ConstraintStatus.Success) - assert(resultA.message.isEmpty) + assert(resultA.message.contains("Value: 1.0 meets the constraint requirement.")) assert(resultA.metric.isDefined) // Analysis result should equal to 1.0 for an existing column