alien11689 commented on a change in pull request #5081:
URL: https://github.com/apache/nifi/pull/5081#discussion_r637704662
##########
File path:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/test/java/org/apache/nifi/processors/hive/TestConvertAvroToORC.java
##########
@@ -320,6 +322,78 @@ public void test_onTrigger_complex_record() throws
Exception {
assertEquals(sampleBigDecimal, ((HiveDecimalWritable)
decimalFieldObject).getHiveDecimal().bigDecimalValue());
}
+ @Test
+ public void test_onTrigger_complex_records_with_bigdecimals() throws
Exception {
+
+ Map<String, Double> mapData1 = new TreeMap<String, Double>() {{
+ put("key1", 1.0);
+ put("key2", 2.0);
+ }};
+
+ DatumWriter<GenericData.Record> writer;
+ DataFileWriter<GenericData.Record> fileWriter = null;
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ Random random = new Random();
+ double bigDecimalUpperRange = 200;
+ for (int i = 0; i < 1000; ++i) {
+ ByteBuffer bigDecimalAsBytes = toByteBuffer(new
BigDecimal(random.nextDouble() * bigDecimalUpperRange).setScale(2,
RoundingMode.HALF_UP));
+ GenericData.Record record =
TestNiFiOrcUtils.buildComplexAvroRecord(null, mapData1, "XYZ", 4L,
Arrays.asList(100, 200), bigDecimalAsBytes);
+ if (i == 0) {
+ writer = new GenericDatumWriter<>(record.getSchema());
+ fileWriter = new DataFileWriter<>(writer);
+ fileWriter.create(record.getSchema(), out);
+ }
+ fileWriter.append(record);
+ }
Review comment:
Thanks, I simplified the test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]