diff --git a/src/main/scala/com/target/data_validator/validator/ColumnSumCheck.scala b/src/main/scala/com/target/data_validator/validator/ColumnSumCheck.scala index 94340de..7ff6b07 100644 --- a/src/main/scala/com/target/data_validator/validator/ColumnSumCheck.scala +++ b/src/main/scala/com/target/data_validator/validator/ColumnSumCheck.scala @@ -63,6 +63,7 @@ case class ColumnSumCheck( case LongType => evaluate(r.getLong(idx)) case FloatType => evaluate(r.getFloat(idx)) case DoubleType => evaluate(r.getDouble(idx)) + case ByteType => evaluate(r.getByte(idx)) case ut => throw new Exception(s"Unsupported type for $name found in schema: $ut") } diff --git a/src/test/scala/com/target/data_validator/TestHelpers.scala b/src/test/scala/com/target/data_validator/TestHelpers.scala index 1277f8f..d43a356 100644 --- a/src/test/scala/com/target/data_validator/TestHelpers.scala +++ b/src/test/scala/com/target/data_validator/TestHelpers.scala @@ -25,6 +25,7 @@ object TestHelpers { case "java.lang.Double" => DoubleType case "java.lang.Boolean" => BooleanType case "java.lang.Long" => LongType + case "java.lang.Byte" => ByteType case _ => throw new IllegalArgumentException(s"Unknown type '${v.getClass.getCanonicalName}'") } diff --git a/src/test/scala/com/target/data_validator/validator/ColumnSumCheckSpec.scala b/src/test/scala/com/target/data_validator/validator/ColumnSumCheckSpec.scala index eb89dc7..2b6759b 100644 --- a/src/test/scala/com/target/data_validator/validator/ColumnSumCheckSpec.scala +++ b/src/test/scala/com/target/data_validator/validator/ColumnSumCheckSpec.scala @@ -200,7 +200,7 @@ class ColumnSumCheckSpec extends FunSpec with Matchers with TestingSparkSession assert(!sut.failed) } - it("upper bound success") { + it("upper bound success with short") { val check = ColumnSumCheck("foo", maxValue = Some(Json.fromDouble(10).get)) // scalastyle:ignore magic.number val df = mkDf(spark, "foo" -> List[Short](1, 2, 1)) val sut = ValidatorDataFrame(df, None, None, List(check)) @@ -208,6 +208,14 @@ class ColumnSumCheckSpec extends FunSpec with Matchers with TestingSparkSession assert(!sut.failed) } + it("upper bound success with byte") { + val check = ColumnSumCheck("foo", maxValue = Some(Json.fromDouble(10).get)) // scalastyle:ignore magic.number + val df = mkDf(spark, "foo" -> List[Byte](1, 2, 1)) + val sut = ValidatorDataFrame(df, None, None, List(check)) + assert(!sut.quickChecks(spark, mkDict())(config)) + assert(!sut.failed) + } + it("upper bound failure") { val check = ColumnSumCheck("foo", maxValue = Some(Json.fromFloat(1).get)) // scalastyle:ignore magic.number val df = mkDf(spark, "foo" -> List(1L, 1L, 1L))