Closed SubhojitM1 closed 3 years ago
Hi SubhojitM1,
it's a strange behavior: every numeric field is mapped (in MemPOI and in Apache POI) to a double. I suspect that the Snowflake data type is a particular one and that MemPOI can't bind it to the double.
I'll do some checks, in the meantime please specify the MemPOI version so I can bind the exception line number to the right code.
Thanks for the response. This is what I am using.
Hi @SubhojitM1
I should have solved the bug. MemPOI had a mapping error between data types. Unfortunately I'm not comfortable with Snowflake, can I ask you to double-check if the fix works for you, please?
The procedure is really simple:
MEM-29_big-number-bug
branchit.firegloves.mempoi.testutil.ConnectionHelper
according to your datasource parametersit.firegloves.mempoi.integration.BigNumbersIT
(there is only one method)out/report-files/test_with_big_numbers.xlsx
, inside MemPOI root folder)If you can confirm that the fix worked, I'll proceed to release the fix and to publish it on maven central
Should be solved in v1.5
Code snippet: try (Connection conn = snowflakeDataSource().getConnection(); PreparedStatement prepStmt = conn.prepareStatement(sql);) { log.info("Starting to writing results to file: {}", fileName); MemPOI memPOI = MempoiBuilder.aMemPOI().withFile(file).addMempoiSheet(new MempoiSheet(prepStmt)).build(); String absoluteFileName = memPOI.prepareMempoiReportToFile().get(); log.info("Completed writing results to file: {}", absoluteFileName); }
Error: java.lang.NumberFormatException: For input string: "20219327490"
Stacktrace: java.util.concurrent.ExecutionException: it.firegloves.mempoi.exception.MempoiException: it.firegloves.mempoi.exception.MempoiException: java.lang.reflect.InvocationTargetException at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357) at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908) at com.kwe.portal.runner.file.XLSXFileGenerator.generate(XLSXFileGenerator.java:36) at com.kwe.portal.runner.processor.FileProcessor.process(FileProcessor.java:33) at com.kwe.portal.runner.processor.MainProcessor.process(MainProcessor.java:51) at com.kwe.portal.runner.SQLBatchRunner.run(SQLBatchRunner.java:44) at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795) at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779) at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) at com.kwe.portal.runner.SQLBatchRunner.main(SQLBatchRunner.java:36) Caused by: it.firegloves.mempoi.exception.MempoiException: it.firegloves.mempoi.exception.MempoiException: java.lang.reflect.InvocationTargetException at it.firegloves.mempoi.strategos.Strategos.generateSheet(Strategos.java:159) at java.util.ArrayList.forEach(ArrayList.java:1257) at it.firegloves.mempoi.strategos.Strategos.generateReport(Strategos.java:117) at it.firegloves.mempoi.strategos.Strategos.generateMempoiReport(Strategos.java:89) at it.firegloves.mempoi.strategos.Strategos.generateMempoiReportToFile(Strategos.java:64) at it.firegloves.mempoi.MemPOI.lambda$prepareMempoiReportToFile$0(MemPOI.java:45) at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604) at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1596) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) Caused by: it.firegloves.mempoi.exception.MempoiException: java.lang.reflect.InvocationTargetException at it.firegloves.mempoi.strategos.DataStrategos.createDataRows(DataStrategos.java:117) at it.firegloves.mempoi.strategos.Strategos.createSheetData(Strategos.java:187) at it.firegloves.mempoi.strategos.Strategos.generateSheet(Strategos.java:144) ... 11 common frames omitted Caused by: java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at it.firegloves.mempoi.strategos.DataStrategos.createDataRows(DataStrategos.java:102) ... 13 common frames omitted Caused by: java.lang.NumberFormatException: For input string: "20219327490" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:583) at java.lang.Integer.parseInt(Integer.java:615) at net.snowflake.client.core.SFBaseResultSet.getInt(SFBaseResultSet.java:253) at net.snowflake.client.jdbc.SnowflakeResultSetV1.getInt(SnowflakeResultSetV1.java:155) at net.snowflake.client.jdbc.SnowflakeBaseResultSet.getInt(SnowflakeBaseResultSet.java:387) ... 18 common frames omitted
Expected behavior Should convert the resultset to xls file. The same functionality working for CSV when using OpenCSV libraries.
In DB column mentioned as NUMBER(16,0). So it can be out of the Java 8 integer precession. It is not in my control so that I can mention it to convert it to long.