Skip to content

Commit 4221bcb

Browse files
committed
Fix NOT_BETWEEN to fail for NULL per AWS DQDL spec
1 parent 2be692a commit 4221bcb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/scala/com/amazon/deequ/dqdl/translation/rules/ColumnValuesRule.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ case class ColumnValuesRule() extends DQDLRuleConverter {
5858
rule: DQRule): Either[String, (Check, Seq[DeequMetricMapping])] = {
5959
val rawOperands = condition.getOperands.asScala
6060
if (!rawOperands.forall(op => op.isInstanceOf[AtomicNumberOperand] || op.isInstanceOf[NullNumericOperand])) {
61-
return Left("ColumnValues rule only supports atomic operands or NULL keyword in conditions.")
61+
return Left("ColumnValues rule only supports numeric operands or NULL keyword in conditions.")
6262
}
6363
if (rawOperands.isEmpty) {
6464
return Left("ColumnValues rule requires at least one operand.")
@@ -135,7 +135,7 @@ case class ColumnValuesRule() extends DQDLRuleConverter {
135135
if (numericOperands.size < 2) {
136136
return Left("NOT BETWEEN requires two operands.")
137137
}
138-
val sql = s"$transformedCol IS NULL OR " +
138+
val sql = s"$transformedCol IS NOT NULL AND " +
139139
s"($transformedCol <= ${numericOperands.head} OR $transformedCol >= ${numericOperands.last})"
140140
Right((addWhereClause(rule, check.satisfies(sql, check.description, _ == 1.0,
141141
columns = List(transformedCol))), complianceMetric(targetColumn, check.description, rule)))

src/test/scala/com/amazon/deequ/dqdl/translation/rules/ColumnValuesRuleSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ class ColumnValuesRuleSpec extends AnyWordSpec with Matchers {
309309
val (check, _) = result.right.get
310310
check.constraints.size shouldBe 1
311311
check.constraints(0).toString should include(
312-
"value IS NULL OR (value <= 10.0 OR value >= 20.0)")
312+
"value IS NOT NULL AND (value <= 10.0 OR value >= 20.0)")
313313
}
314314

315315
"convert EQUALS NULL numeric rule" in {

0 commit comments

Comments
 (0)