-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathStructures.scala
More file actions
31 lines (23 loc) · 1.08 KB
/
Structures.scala
File metadata and controls
31 lines (23 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.databricks.labs.validation.utils
import com.databricks.labs.validation.Rule
import org.apache.spark.sql.{Column, DataFrame}
object Structures {
case class Bounds(
lower: Double = Double.NegativeInfinity,
upper: Double = Double.PositiveInfinity,
lowerInclusive: Boolean = false,
upperInclusive: Boolean = false) {
def validationLogic(c: Column): Column = {
val lowerLogic = if (lowerInclusive) c >= lower else c > lower
val upperLogic = if (upperInclusive) c <= upper else c < upper
lowerLogic && upperLogic
}
}
case class MinMaxRuleDef(ruleName: String, column: Column, bounds: Bounds, by: Column*)
case class ValidationResults(completeReport: DataFrame, summaryReport: DataFrame)
private[validation] class ValidationException(s: String) extends Exception(s) {}
private[validation] class InvalidRuleException(r: Rule, s: String) extends Exception(s) {
val msg: String = s"RULE VALIDATION FAILED: ${r.toString}"
throw new ValidationException(msg)
}
}