embulk-filter-expand_json 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -1
- data/CHANGELOG.md +5 -0
- data/README.md +1 -0
- data/build.gradle +1 -1
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +2 -2
- data/src/main/java/org/embulk/filter/expand_json/FilteredPageOutput.java +7 -1
- data/src/test/java/org/embulk/filter/expand_json/TestExpandJsonFilterPlugin.java +49 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab391ec7a08e2c564a88ab1984b2331df266d360
|
4
|
+
data.tar.gz: 34c7c68b0ebb842a0b7e50866ba07f05a3565036
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50363ce3c2f5ba54554f4e8aa31f7d9a7ac7a1f58588e0004e6210d4cd3dddf2c8197517924dfb7de99d19a9704c969cad75246a791304c2d2a72fac75d6a974
|
7
|
+
data.tar.gz: 668b2b73ba967ca41b27902456290ead55fd4678ddfc2ebe4758448674b214a78a5beae3886fd46e07691720c0beff26a7165404713ca8b2ed9fb0676cc2e589
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.2.1 (2017-09-12)
|
2
|
+
==================
|
3
|
+
- [Enhancement] Support type conversion from floating point numbers to integers
|
4
|
+
- https://github.com/civitaspo/embulk-filter-expand_json/pull/33
|
5
|
+
|
1
6
|
0.2.0 (2017-07-14)
|
2
7
|
==================
|
3
8
|
- [Incompatible Change]: Remove `time_zone` option, use `default_timezone` instead and column-based timezone.
|
data/README.md
CHANGED
@@ -17,6 +17,7 @@ expand columns having json into multiple columns
|
|
17
17
|
- **name**: name of the column. you can define [JsonPath](http://goessner.net/articles/JsonPath/) style.
|
18
18
|
- **type**: type of the column (see below)
|
19
19
|
- **format**: format of the timestamp if type is timestamp
|
20
|
+
- **timezone**: Time zone of each timestamp columns if values don’t include time zone description (`UTC` by default)
|
20
21
|
- **keep_expanding_json_column**: Not remove the expanding json column from input schema if it's true (false by default)
|
21
22
|
- **default_timezone**: Time zone of timestamp columns if values don’t include time zone description (`UTC` by default)
|
22
23
|
- **stop_on_invalid_record**: Stop bulk load transaction if an invalid record is included (false by default)
|
data/build.gradle
CHANGED
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
#Sun Jan 08 00:35:58 PST 2017
|
2
2
|
distributionBase=GRADLE_USER_HOME
|
3
3
|
distributionPath=wrapper/dists
|
4
4
|
zipStoreBase=GRADLE_USER_HOME
|
5
5
|
zipStorePath=wrapper/dists
|
6
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.
|
6
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip
|
@@ -329,7 +329,13 @@ public class FilteredPageOutput
|
|
329
329
|
pageBuilder.setLong(expandedJsonColumn.getColumn(), Long.parseLong(finalValue));
|
330
330
|
}
|
331
331
|
catch (NumberFormatException e) {
|
332
|
-
|
332
|
+
// ad-hoc workaround for exponential notation
|
333
|
+
try {
|
334
|
+
pageBuilder.setLong(expandedJsonColumn.getColumn(), (long) Double.parseDouble(finalValue));
|
335
|
+
}
|
336
|
+
catch (NumberFormatException e2) {
|
337
|
+
throw new JsonValueInvalidException(String.format("Failed to parse '%s' as long", finalValue), e);
|
338
|
+
}
|
333
339
|
}
|
334
340
|
}
|
335
341
|
else if (Types.TIMESTAMP.equals(expandedJsonColumn.getColumn().getType())) {
|
@@ -966,6 +966,55 @@ public class TestExpandJsonFilterPlugin
|
|
966
966
|
});
|
967
967
|
}
|
968
968
|
|
969
|
+
@Test
|
970
|
+
public void testParseNumbersInExponentialNotation()
|
971
|
+
{
|
972
|
+
final String configYaml = "" +
|
973
|
+
"type: expand_json\n" +
|
974
|
+
"json_column_name: _c1\n" +
|
975
|
+
"root: $.\n" +
|
976
|
+
"expanded_columns:\n" +
|
977
|
+
" - {name: _j0, type: double}\n" +
|
978
|
+
" - {name: _j1, type: long}\n";
|
979
|
+
ConfigSource config = getConfigFromYaml(configYaml);
|
980
|
+
final Schema schema = schema("_c1", STRING);
|
981
|
+
|
982
|
+
expandJsonFilterPlugin.transaction(config, schema, new Control()
|
983
|
+
{
|
984
|
+
@Override
|
985
|
+
public void run(TaskSource taskSource, Schema outputSchema)
|
986
|
+
{
|
987
|
+
MockPageOutput mockPageOutput = new MockPageOutput();
|
988
|
+
|
989
|
+
String doubleFloatingPoint = "-1.234e-5";
|
990
|
+
double doubleFixedPoint = -0.00001234; // Use in Asserting.
|
991
|
+
String longFloatingPoint = "12345e3";
|
992
|
+
long longFixedPoint = 12_345_000L; // Use in Asserting.
|
993
|
+
|
994
|
+
String data = String.format(
|
995
|
+
"{\"_j0\":%s, \"_j1\":%s}",
|
996
|
+
doubleFloatingPoint,
|
997
|
+
longFloatingPoint);
|
998
|
+
|
999
|
+
try (PageOutput pageOutput = expandJsonFilterPlugin.open(taskSource, schema, outputSchema, mockPageOutput)) {
|
1000
|
+
for (Page page : PageTestUtils.buildPage(runtime.getBufferAllocator(), schema, data, c1Data)) {
|
1001
|
+
pageOutput.add(page);
|
1002
|
+
}
|
1003
|
+
|
1004
|
+
pageOutput.finish();
|
1005
|
+
}
|
1006
|
+
|
1007
|
+
PageReader pageReader = new PageReader(outputSchema);
|
1008
|
+
|
1009
|
+
for (Page page : mockPageOutput.pages) {
|
1010
|
+
pageReader.setPage(page);
|
1011
|
+
assertEquals(doubleFixedPoint, pageReader.getDouble(outputSchema.getColumn(0)), 0.0);
|
1012
|
+
assertEquals(longFixedPoint, pageReader.getLong(outputSchema.getColumn(1)));
|
1013
|
+
}
|
1014
|
+
}
|
1015
|
+
});
|
1016
|
+
}
|
1017
|
+
|
969
1018
|
private static Schema schema(Object... nameAndTypes)
|
970
1019
|
{
|
971
1020
|
Schema.Builder builder = Schema.builder();
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-filter-expand_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Civitaspo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,7 +65,7 @@ files:
|
|
65
65
|
- src/test/java/org/embulk/filter/expand_json/TestExpandJsonFilterPlugin.java
|
66
66
|
- classpath/accessors-smart-1.2.jar
|
67
67
|
- classpath/asm-5.0.4.jar
|
68
|
-
- classpath/embulk-filter-expand_json-0.2.
|
68
|
+
- classpath/embulk-filter-expand_json-0.2.1.jar
|
69
69
|
- classpath/json-path-2.4.0.jar
|
70
70
|
- classpath/json-smart-2.3.jar
|
71
71
|
- classpath/slf4j-api-1.7.25.jar
|