-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in MinLength and MaxLength analyzers where given the NullBeha…
…vior.EmptyString option, the where filter wasn't properly applied (#538)
- Loading branch information
1 parent
3339cfe
commit 9d398a1
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -697,6 +697,21 @@ class CheckTest extends AnyWordSpec with Matchers with SparkContextSpec with Fix | |
assertSuccess(baseCheck.hasMaxLength("att1", _ == 4.0), context) | ||
} | ||
|
||
"yield correct results for minimum and maximum length stats with where clause" in | ||
withSparkSession { sparkSession => | ||
val emptyNulLBehavior = Option(AnalyzerOptions(NullBehavior.EmptyString)) | ||
val baseCheck = Check(CheckLevel.Error, description = "a description") | ||
val df = getDfCompleteAndInCompleteColumnsAndVarLengthStrings(sparkSession) | ||
val context = AnalysisRunner.onData(df) | ||
.addAnalyzers(Seq(MinLength("item", Option("val1 > 3"), emptyNulLBehavior), | ||
MaxLength("item", Option("val1 <= 3"), emptyNulLBehavior))).run() | ||
|
||
assertSuccess(baseCheck.hasMinLength("item", _ >= 4.0, analyzerOptions = emptyNulLBehavior) | ||
.where("val1 > 3"), context) // 1 without where clause | ||
assertSuccess(baseCheck.hasMaxLength("item", _ <= 3.0, analyzerOptions = emptyNulLBehavior) | ||
.where("val1 <= 3"), context) // 6 without where clause | ||
} | ||
|
||
"work on regular expression patterns for E-Mails" in withSparkSession { sparkSession => | ||
val col = "some" | ||
val df = dataFrameWithColumn(col, StringType, sparkSession, Row("[email protected]"), | ||
|