mirror of https://github.com/apache/nifi.git
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:
parent
3a1bc44b88
commit
80e71068be
|
@ -325,7 +325,7 @@ public class ResultSetRecordSet implements RecordSet, Closeable {
|
||||||
decimalPrecision = resultSetPrecision;
|
decimalPrecision = resultSetPrecision;
|
||||||
//For the float data type Oracle return decimalScale < 0 which cause is not expected to org.apache.avro.LogicalTypes
|
//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
|
//Hence falling back to default scale if decimalScale < 0
|
||||||
decimalScale = resultSetScale > 0 ? resultSetScale : defaultScale;
|
decimalScale = resultSetScale >= 0 ? resultSetScale : defaultScale;
|
||||||
} else {
|
} else {
|
||||||
// If not, use default precision.
|
// If not, use default precision.
|
||||||
decimalPrecision = defaultPrecision;
|
decimalPrecision = defaultPrecision;
|
||||||
|
|
|
@ -130,6 +130,20 @@ public class ResultSetRecordSetTest {
|
||||||
thenAllColumnDataTypesAreCorrect(COLUMNS, expectedSchema, actualSchema);
|
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
|
@Test
|
||||||
public void testCreateSchemaWhenNoRecordSchema() throws SQLException {
|
public void testCreateSchemaWhenNoRecordSchema() throws SQLException {
|
||||||
// given
|
// given
|
||||||
|
|
Loading…
Reference in New Issue