Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frsyuki/b8a8987f57a3dcb3d07ba715119a9b7c to your computer and use it in GitHub Desktop.
Save frsyuki/b8a8987f57a3dcb3d07ba715119a9b7c to your computer and use it in GitHub Desktop.
diff --git a/src/main/java/org/embulk/filter/expand_json/FilteredPageOutput.java b/src/main/java/org/embulk/filter/expand_json/FilteredPageOutput.java
index afb2884..1148e54 100644
--- a/src/main/java/org/embulk/filter/expand_json/FilteredPageOutput.java
+++ b/src/main/java/org/embulk/filter/expand_json/FilteredPageOutput.java
@@ -329,7 +329,13 @@ public class FilteredPageOutput
pageBuilder.setLong(expandedJsonColumn.getColumn(), Long.parseLong(finalValue));
}
catch (NumberFormatException e) {
- throw new JsonValueInvalidException(String.format("Failed to parse '%s' as long", finalValue), e);
+ // ad-hoc workaround for exponential notation
+ try {
+ pageBuilder.setLong(expandedJsonColumn.getColumn(), (long) Double.parseDouble(finalValue));
+ }
+ catch (NumberFormatException e2) {
+ throw new JsonValueInvalidException(String.format("Failed to parse '%s' as long", finalValue), e);
+ }
}
}
else if (Types.TIMESTAMP.equals(expandedJsonColumn.getColumn().getType())) {
2017-09-07 17:35:38.904 -0700 [INFO] (0001:preview): Loaded plugin embulk/filter/expand_json from a load path
2017-09-07 17:35:38.958 -0700 [INFO] (0001:preview): Loaded plugin embulk-filter-calc (0.1.0)
2017-09-07 17:35:38.973 -0700 [INFO] (0001:preview): Listing local files at directory '.' filtering filename by prefix 'test.json'
2017-09-07 17:35:38.976 -0700 [INFO] (0001:preview): Loading files [test.json]
2017-09-07 17:35:39.015 -0700 [INFO] (0001:preview): removed column: name: record, type: json, index: 0
2017-09-07 17:35:39.015 -0700 [INFO] (0001:preview): added column: name: double, type: double, options: {}, index: 0
2017-09-07 17:35:39.015 -0700 [INFO] (0001:preview): added column: name: string, type: string, options: {}, index: 1
2017-09-07 17:35:39.015 -0700 [INFO] (0001:preview): added column: name: long, type: long, options: {}, index: 2
2017-09-07 17:35:39.015 -0700 [INFO] (0001:preview): added column: name: boolean, type: boolean, options: {}, index: 3
+------------------------+---------------+------------+-----------------+
| double:double | string:string | long:long | boolean:boolean |
+------------------------+---------------+------------+-----------------+
| -1.2340000000000002E-4 | string | 12,345,000 | true |
+------------------------+---------------+------------+-----------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment