embulk-filter-query_string 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e23eed64d1e327f08947f81c6b6244455c12e57d
4
- data.tar.gz: 14a42b37b91926e1b51cbbcfbd9ddc97f8e86269
3
+ metadata.gz: d3af78f6e9fa1f55d7a8817b3439b2465b958778
4
+ data.tar.gz: 18c445e7f9a77f1031fb8208327cf87505c9016c
5
5
  SHA512:
6
- metadata.gz: d4aab3501d0169dc55b68fe1e9f44c728a3abcb83060a77e9ce251f69d527f4f6d58c4ab297f0c3ef3717a492cf144149ec6a0bfbe02b88ae4456d91361498c1
7
- data.tar.gz: 70a4113aaf1b485e8bfefd09c453a9367fa8fd30999fada48c06270892d7c15b4633ce3bdf1815e01c9db1d79d4b576da4ba1f8d59f25aeda790a28c0bac03fc
6
+ metadata.gz: 4b971c444060d50586dfdbe435ec1c4b21ed654331a15869c9f1365f7bba4e69470342af9202a2d9e4873fd093f632077f611483df3a3a540cee0470312265c9
7
+ data.tar.gz: eac337937754d47bd4e6ed5e154e65427d6718eae9fdefa91bfc61157894e431137ef5d2ce1e4efff20e7638ac394bc47bf9d3a542dc59af0914ae50928a7b19
File without changes
data/NOTICE ADDED
@@ -0,0 +1,2 @@
1
+ Query String filter plugin for Embulk
2
+ Copyright 2016 Minnano Wedding Co., Ltd.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  The query string filter plugin parses the column contents as query string and insert columns from that field.
4
4
 
5
+ [![Circle CI](https://circleci.com/gh/mwed/embulk-filter-query_string.svg?style=svg)](https://circleci.com/gh/mwed/embulk-filter-query_string)
6
+
5
7
  ## Overview
6
8
 
7
9
  * **Plugin type**: filter
data/build.gradle CHANGED
@@ -79,7 +79,7 @@ task gemspec {
79
79
  gemspecFile.write($/
80
80
  Gem::Specification.new do |spec|
81
81
  spec.name = "embulk-filter-query_string"
82
- spec.version = "0.1.0"
82
+ spec.version = "0.1.1"
83
83
  spec.authors = ["Minnano Wedding Co., Ltd."]
84
84
  spec.summary = %[Query String filter plugin for Embulk]
85
85
  spec.description = %[The query string filter plugin parses the column contents as query string and insert columns from that field.]
@@ -115,7 +115,12 @@ public class QueryStringFilterPlugin
115
115
  String key = queryString.substring(keyStart, keyEnd);
116
116
  String value = queryString.substring(valueStart, valueEnd);
117
117
 
118
- storage.put(key, Double.parseDouble(value));
118
+ try {
119
+ storage.put(key, Double.parseDouble(value));
120
+ }
121
+ catch (NumberFormatException e) {
122
+ storage.put(key, null);
123
+ }
119
124
  }
120
125
  };
121
126
 
@@ -125,9 +130,15 @@ public class QueryStringFilterPlugin
125
130
  public void parseKeyValuePair(String queryString, int keyStart, int keyEnd, int valueStart, int valueEnd, Map<String, Object> storage)
126
131
  {
127
132
  String key = queryString.substring(keyStart, keyEnd);
128
- long value = ParseUtils.parseUnsignedLong(queryString, valueStart, valueEnd);
129
133
 
130
- storage.put(key, value);
134
+ try {
135
+ long value = ParseUtils.parseUnsignedLong(queryString, valueStart, valueEnd);
136
+
137
+ storage.put(key, value);
138
+ }
139
+ catch (NumberFormatException e) {
140
+ storage.put(key, null);
141
+ }
131
142
  }
132
143
  };
133
144
 
@@ -137,9 +148,15 @@ public class QueryStringFilterPlugin
137
148
  public void parseKeyValuePair(String queryString, int keyStart, int keyEnd, int valueStart, int valueEnd, Map<String, Object> storage)
138
149
  {
139
150
  String key = queryString.substring(keyStart, keyEnd);
140
- long value = ParseUtils.parseUnsignedLong(queryString, valueStart, valueEnd);
141
151
 
142
- storage.put(key, Timestamp.ofEpochSecond(value));
152
+ try {
153
+ long value = ParseUtils.parseUnsignedLong(queryString, valueStart, valueEnd);
154
+
155
+ storage.put(key, Timestamp.ofEpochSecond(value));
156
+ }
157
+ catch (NumberFormatException e) {
158
+ storage.put(key, null);
159
+ }
143
160
  }
144
161
  };
145
162
 
@@ -29,6 +29,7 @@ import org.embulk.spi.PageReader;
29
29
  import org.embulk.spi.PageTestUtils;
30
30
  import org.embulk.spi.Schema;
31
31
  import org.embulk.spi.TestPageBuilderReader;
32
+ import org.junit.Ignore;
32
33
  import org.junit.Rule;
33
34
  import org.junit.Test;
34
35
 
@@ -38,7 +39,9 @@ import java.util.List;
38
39
 
39
40
  import static org.embulk.spi.type.Types.STRING;
40
41
  import static org.hamcrest.CoreMatchers.is;
42
+ import static org.junit.Assert.assertEquals;
41
43
  import static org.junit.Assert.assertThat;
44
+ import static org.junit.Assert.assertTrue;
42
45
 
43
46
  public class TestQueryStringFilterPlugin
44
47
  {
@@ -106,13 +109,49 @@ public class TestQueryStringFilterPlugin
106
109
 
107
110
  assertThat(pageReader.getString(0), is("before"));
108
111
  assertThat(pageReader.getString(1), is("one"));
109
- assertThat(pageReader.getLong(2), is(Long.valueOf(2L)));
112
+ assertEquals(2L, pageReader.getLong(2));
110
113
  assertThat(pageReader.getString(3), is("after"));
111
114
  }
112
115
  }
113
116
  });
114
117
  }
115
118
 
119
+ @Ignore
120
+ @Test
121
+ public void testOpenWithInvalidValue()
122
+ {
123
+ ConfigSource configSource = loadConfigSource("testOpenWithInvalidValue.yml");
124
+ final Schema inputSchema = Schema.builder()
125
+ .add("qs", STRING)
126
+ .build();
127
+
128
+ final QueryStringFilterPlugin plugin = new QueryStringFilterPlugin();
129
+ plugin.transaction(configSource, inputSchema, new FilterPlugin.Control()
130
+ {
131
+ @Override
132
+ public void run(TaskSource taskSource, Schema outputSchema)
133
+ {
134
+ TestPageBuilderReader.MockPageOutput mockPageOutput = new TestPageBuilderReader.MockPageOutput();
135
+ PageOutput pageOutput = plugin.open(taskSource, inputSchema, outputSchema, mockPageOutput);
136
+
137
+ List<Page> pages = PageTestUtils.buildPage(runtime.getBufferAllocator(), inputSchema, "/path?q1=alpha");
138
+ for (Page page : pages) {
139
+ pageOutput.add(page);
140
+ }
141
+
142
+ pageOutput.finish();
143
+ pageOutput.close();
144
+
145
+ PageReader pageReader = new PageReader(outputSchema);
146
+ for (Page page : mockPageOutput.pages) {
147
+ pageReader.setPage(page);
148
+
149
+ assertTrue(pageReader.isNull(0));
150
+ }
151
+ }
152
+ });
153
+ }
154
+
116
155
  private ConfigSource loadConfigSource(String yamlPath)
117
156
  {
118
157
  try {
@@ -0,0 +1,4 @@
1
+ type: query_string
2
+ query_string_column_name: qs
3
+ expanded_columns:
4
+ - {name: q1, type: long}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-filter-query_string
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minnano Wedding Co., Ltd.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -46,7 +46,8 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - .gitignore
49
- - LICENSE.txt
49
+ - LICENSE
50
+ - NOTICE
50
51
  - README.md
51
52
  - build.gradle
52
53
  - config/checkstyle/checkstyle.xml
@@ -59,6 +60,7 @@ files:
59
60
  - src/main/java/org/embulk/filter/query_string/QueryStringFilterPlugin.java
60
61
  - src/test/java/org/embulk/filter/query_string/TestQueryStringFilterPlugin.java
61
62
  - src/test/resources/testOpen.yml
63
+ - src/test/resources/testOpenWithInvalidValue.yml
62
64
  - src/test/resources/testTransaction.yml
63
65
  - classpath/commons-codec-1.9.jar
64
66
  - classpath/commons-logging-1.2.jar