NIFI-11860 fixed bug in ResultSetRecordSet affecting decimalScale when resultSetScale was zero.

Signed-off-by: Matt Burgess <mattyb149@apache.org>

This closes #7545
This commit is contained in:
Tamas Neumer 2023-07-31 05:12:23 +02:00 committed by Matt Burgess
parent 3a1bc44b88
commit 80e71068be
2 changed files with 15 additions and 1 deletions

View File

@ -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;

View File

@ -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