This is an automated email from the ASF dual-hosted git repository. mattyb149 pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push: new 80e71068be NIFI-11860 fixed bug in ResultSetRecordSet affecting decimalScale when resultSetScale was zero. 80e71068be is described below commit 80e71068bec6a665486d1264bb582ed94bd84bd3 Author: Tamas Neumer <tamas.neu...@posedio.com> AuthorDate: Mon Jul 31 05:12:23 2023 +0200 NIFI-11860 fixed bug in ResultSetRecordSet affecting decimalScale when resultSetScale was zero. Signed-off-by: Matt Burgess <mattyb...@apache.org> This closes #7545 --- .../nifi/serialization/record/ResultSetRecordSet.java | 2 +- .../nifi/serialization/record/ResultSetRecordSetTest.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/ResultSetRecordSet.java b/nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/ResultSetRecordSet.java index 84a7b4569a..3357b06a7f 100644 --- a/nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/ResultSetRecordSet.java +++ b/nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/ResultSetRecordSet.java @@ -325,7 +325,7 @@ public class ResultSetRecordSet implements RecordSet, Closeable { decimalPrecision = resultSetPrecision; //For the float data type Oracle return decimalScale < 0 which cause is not expected to org.apache.avro.LogicalTypes //Hence falling back to default scale if decimalScale < 0 - decimalScale = resultSetScale > 0 ? resultSetScale : defaultScale; + decimalScale = resultSetScale >= 0 ? resultSetScale : defaultScale; } else { // If not, use default precision. decimalPrecision = defaultPrecision; diff --git a/nifi-commons/nifi-record/src/test/java/org/apache/nifi/serialization/record/ResultSetRecordSetTest.java b/nifi-commons/nifi-record/src/test/java/org/apache/nifi/serialization/record/ResultSetRecordSetTest.java index e9e5ec861b..b1c272cdf6 100644 --- a/nifi-commons/nifi-record/src/test/java/org/apache/nifi/serialization/record/ResultSetRecordSetTest.java +++ b/nifi-commons/nifi-record/src/test/java/org/apache/nifi/serialization/record/ResultSetRecordSetTest.java @@ -130,6 +130,20 @@ public class ResultSetRecordSetTest { thenAllColumnDataTypesAreCorrect(COLUMNS, expectedSchema, actualSchema); } + @Test + public void testCreateSchemaWhenScaleIsNonDefault() throws SQLException { + // given + final RecordSchema recordSchema = givenRecordSchema(COLUMNS); + final RecordSchema expectedSchema = givenRecordSchema(COLUMNS); + + // when + final ResultSetRecordSet testSubject = new ResultSetRecordSet(resultSet, recordSchema, 10, 2); + final RecordSchema actualSchema = testSubject.getSchema(); + + // then + thenAllColumnDataTypesAreCorrect(COLUMNS, expectedSchema, actualSchema); + } + @Test public void testCreateSchemaWhenNoRecordSchema() throws SQLException { // given