From 1fb1ed66f4794363c4f037baae96ce7eac14097b Mon Sep 17 00:00:00 2001 From: sierzput Date: Thu, 25 Apr 2024 14:30:31 +0200 Subject: [PATCH 1/2] fix: decimal scale condition --- src/Parquet/Schema/DecimalDataField.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Parquet/Schema/DecimalDataField.cs b/src/Parquet/Schema/DecimalDataField.cs index 5bee46f2..cb81046a 100644 --- a/src/Parquet/Schema/DecimalDataField.cs +++ b/src/Parquet/Schema/DecimalDataField.cs @@ -41,8 +41,8 @@ public DecimalDataField(string name, throw new ArgumentException("precision is required and must be a non-zero positive integer", nameof(precision)); if(scale < 0) throw new ArgumentException("scale must be zero or a positive integer", nameof(scale)); - if(scale >= precision) - throw new ArgumentException("scale must be less than the precision", nameof(scale)); + if(scale > precision) + throw new ArgumentException("scale must be less than or equal to the precision", nameof(scale)); Precision = precision; Scale = scale; From 8719011c4b325c27ec9bd83f96750f68c0cd12e6 Mon Sep 17 00:00:00 2001 From: sierzput Date: Thu, 25 Apr 2024 14:42:55 +0200 Subject: [PATCH 2/2] test: correct message in assert --- src/Parquet.Test/DecimalTypeTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parquet.Test/DecimalTypeTest.cs b/src/Parquet.Test/DecimalTypeTest.cs index ad598326..4367c745 100644 --- a/src/Parquet.Test/DecimalTypeTest.cs +++ b/src/Parquet.Test/DecimalTypeTest.cs @@ -44,7 +44,7 @@ public void Validate_Scale_Bigger_Then_Precision_Throws_Exception() { const int precision = 3; const int scale = 4; ArgumentException ex = Assert.Throws(() => new DecimalDataField("field-name", precision, scale)); - Assert.Equal("scale must be less than the precision (Parameter 'scale')", ex.Message); + Assert.Equal("scale must be less than or equal to the precision (Parameter 'scale')", ex.Message); } } } \ No newline at end of file