Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display success message in Verification Suite Result #375

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 7 additions & 4 deletions src/test/scala/com/amazon/deequ/VerificationResultTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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! " +
Expand All @@ -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",
Expand All @@ -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))",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down