Skip to content

Commit 6fed17c

Browse files
authored
Merge pull request #45 from target/adds-byte-to-columnsumcheck
Adds support for Bytes to ColumnSumCheck
2 parents d829d66 + 01515df commit 6fed17c

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/main/scala/com/target/data_validator/validator/ColumnSumCheck.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ case class ColumnSumCheck(
6363
case LongType => evaluate(r.getLong(idx))
6464
case FloatType => evaluate(r.getFloat(idx))
6565
case DoubleType => evaluate(r.getDouble(idx))
66+
case ByteType => evaluate(r.getByte(idx))
6667
case ut => throw new Exception(s"Unsupported type for $name found in schema: $ut")
6768
}
6869

src/test/scala/com/target/data_validator/TestHelpers.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ object TestHelpers {
2525
case "java.lang.Double" => DoubleType
2626
case "java.lang.Boolean" => BooleanType
2727
case "java.lang.Long" => LongType
28+
case "java.lang.Byte" => ByteType
2829
case _ => throw new IllegalArgumentException(s"Unknown type '${v.getClass.getCanonicalName}'")
2930
}
3031

src/test/scala/com/target/data_validator/validator/ColumnSumCheckSpec.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,22 @@ class ColumnSumCheckSpec extends FunSpec with Matchers with TestingSparkSession
200200
assert(!sut.failed)
201201
}
202202

203-
it("upper bound success") {
203+
it("upper bound success with short") {
204204
val check = ColumnSumCheck("foo", maxValue = Some(Json.fromDouble(10).get)) // scalastyle:ignore magic.number
205205
val df = mkDf(spark, "foo" -> List[Short](1, 2, 1))
206206
val sut = ValidatorDataFrame(df, None, None, List(check))
207207
assert(!sut.quickChecks(spark, mkDict())(config))
208208
assert(!sut.failed)
209209
}
210210

211+
it("upper bound success with byte") {
212+
val check = ColumnSumCheck("foo", maxValue = Some(Json.fromDouble(10).get)) // scalastyle:ignore magic.number
213+
val df = mkDf(spark, "foo" -> List[Byte](1, 2, 1))
214+
val sut = ValidatorDataFrame(df, None, None, List(check))
215+
assert(!sut.quickChecks(spark, mkDict())(config))
216+
assert(!sut.failed)
217+
}
218+
211219
it("upper bound failure") {
212220
val check = ColumnSumCheck("foo", maxValue = Some(Json.fromFloat(1).get)) // scalastyle:ignore magic.number
213221
val df = mkDf(spark, "foo" -> List(1L, 1L, 1L))

0 commit comments

Comments
 (0)