mirror of
https://github.com/apache/nifi.git
synced 2025-03-06 17:39:36 +00:00
NIFI-11655 Fixed float and double handling in GenerateRecord
This closes #7356 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
36da257e56
commit
5e6f3abdd2
@ -59,6 +59,7 @@ import org.apache.nifi.serialization.record.type.MapDataType;
|
||||
import org.apache.nifi.serialization.record.type.RecordDataType;
|
||||
import org.apache.nifi.util.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
@ -310,9 +311,13 @@ public class GenerateRecord extends AbstractProcessor {
|
||||
return (char) faker.number().numberBetween(Character.MIN_VALUE, Character.MAX_VALUE);
|
||||
case DATE:
|
||||
return FakerUtils.getFakeData(DEFAULT_DATE_PROPERTY_NAME, faker);
|
||||
case DECIMAL:
|
||||
case DOUBLE:
|
||||
return faker.number().randomDouble(6, Long.MIN_VALUE, Long.MAX_VALUE);
|
||||
case FLOAT:
|
||||
final double randomDouble = faker.number().randomDouble(6, Long.MIN_VALUE, Long.MAX_VALUE);
|
||||
final BigDecimal asBigDecimal = new BigDecimal(randomDouble);
|
||||
return asBigDecimal.floatValue();
|
||||
case DECIMAL:
|
||||
return faker.number().randomDouble(((DecimalDataType) recordField.getDataType()).getScale(), Long.MIN_VALUE, Long.MAX_VALUE);
|
||||
case INT:
|
||||
return faker.number().numberBetween(Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
|
@ -18,7 +18,13 @@
|
||||
}, {
|
||||
"name": "Name",
|
||||
"type": ["null", "string"]
|
||||
}]
|
||||
}, {
|
||||
"name": "TestFloat",
|
||||
"type": ["null", "float"]
|
||||
}, {
|
||||
"name": "TestDouble",
|
||||
"type": ["null", "double"]
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
"name": "EventID",
|
||||
|
Loading…
x
Reference in New Issue
Block a user