embulk-parser-query_string 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/embulk-parser-query_string.gemspec +1 -1
- data/lib/embulk/guess/query_string.rb +3 -3
- data/lib/embulk/parser/query_string.rb +13 -8
- data/test/embulk/guess/test_query_string.rb +14 -14
- data/test/embulk/parser/{test_query_string_plugin.rb → test_query_string.rb} +3 -3
- data/test/run-test.rb +1 -1
- data/test/test_embulk_run.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aacb287d4c071f254e3876d81896df78369f2a9
|
4
|
+
data.tar.gz: 214293101b683e49c23d05b1a85b42119ffdc5c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36517f8ac5bb32b3eb2e41683e305e081d2152ce096ce590a6dc603081da1f2e8e7b919807f15b13fe9dab725281c0443d3b2d09583dc318625a37cb916c248b
|
7
|
+
data.tar.gz: 397c4fe3fa874d46a5eb34a54de7b87254d1757f6661a0d7170a7b8335924099a6dbc94ab3d54f40fbcc3b052ec7f9169a7e263defdc8ec71a9eb6a81eda57be
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 0.2.0 - 2015-07-29
|
2
|
+
|
3
|
+
This version breaks backword compatibility. With this version, if you use config created by embulk-parser-query_string 0.1.3 or earlier, you should replace `schema:` key name with `columns:` in your config file (e.g. `config.yml`) .
|
4
|
+
|
5
|
+
* [fixed] Use "column" as key for schema in config file [#22](https://github.com/treasure-data/embulk-parser-query_string/pull/22) [[reported by @muga](https://github.com/treasure-data/embulk-parser-query_string/issues/21). Thanks!!]
|
6
|
+
* [enhancement] Display cast error log to human [#19](https://github.com/treasure-data/embulk-parser-query_string/pull/19)
|
7
|
+
* [maintenace] Fix same name tests weren't run [#18](https://github.com/treasure-data/embulk-parser-query_string/pull/18)
|
8
|
+
|
1
9
|
## 0.1.3 - 2015-07-16
|
2
10
|
* [enhancement] Fix bug nil value casting unexpectedly [#16](https://github.com/treasure-data/embulk-parser-query_string/pull/16)
|
3
11
|
* [maintenance] Improve test [#15](https://github.com/treasure-data/embulk-parser-query_string/pull/15)
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "embulk-parser-query_string"
|
4
|
-
spec.version = "0.
|
4
|
+
spec.version = "0.2.0"
|
5
5
|
spec.authors = ["yoshihara", "uu59"]
|
6
6
|
spec.summary = "Query String parser plugin for Embulk"
|
7
7
|
spec.description = "Parses Query String files read by other file input plugins."
|
@@ -25,12 +25,12 @@ module Embulk
|
|
25
25
|
end
|
26
26
|
result
|
27
27
|
end
|
28
|
-
guessed = {type: "query_string",
|
28
|
+
guessed = {type: "query_string", columns: []}
|
29
29
|
format.each_pair do |key, values|
|
30
30
|
if values.any? {|value| value.match(/[^0-9]/) }
|
31
|
-
guessed[:
|
31
|
+
guessed[:columns] << {name: key, type: :string}
|
32
32
|
else
|
33
|
-
guessed[:
|
33
|
+
guessed[:columns] << {name: key, type: :long}
|
34
34
|
end
|
35
35
|
end
|
36
36
|
return {"parser" => guessed}
|
@@ -17,7 +17,7 @@ module Embulk
|
|
17
17
|
}
|
18
18
|
|
19
19
|
columns = []
|
20
|
-
schema = config.param("
|
20
|
+
schema = config.param("columns", :array, default: [])
|
21
21
|
schema.each do |column|
|
22
22
|
name = column["name"]
|
23
23
|
type = column["type"].to_sym
|
@@ -84,13 +84,18 @@ module Embulk
|
|
84
84
|
|
85
85
|
next nil unless value
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
87
|
+
begin
|
88
|
+
case column.type
|
89
|
+
when :long
|
90
|
+
value.strip.empty? ? nil : Integer(value)
|
91
|
+
when :timestamp
|
92
|
+
value.strip.empty? ? nil : Time.parse(value)
|
93
|
+
else
|
94
|
+
value.to_s
|
95
|
+
end
|
96
|
+
rescue => e
|
97
|
+
Embulk.logger.error "Cast failed '#{value}' as '#{column.type}' (key is '#{column.name}')"
|
98
|
+
raise e
|
94
99
|
end
|
95
100
|
end
|
96
101
|
|
@@ -8,35 +8,35 @@ module Embulk
|
|
8
8
|
class TestGuessLines < self
|
9
9
|
data do
|
10
10
|
{
|
11
|
-
same_keys: [sample_lines_with_same_keys,
|
12
|
-
different_keys: [sample_lines_with_different_keys,
|
13
|
-
invalid: [sample_lines_with_invalid,
|
11
|
+
same_keys: [sample_lines_with_same_keys, columns_with_same_keys],
|
12
|
+
different_keys: [sample_lines_with_different_keys, columns_with_different_keys],
|
13
|
+
invalid: [sample_lines_with_invalid, columns_with_invalid],
|
14
14
|
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
sample_lines,
|
18
|
+
def test_columns(data)
|
19
|
+
sample_lines, columns = data
|
20
20
|
actual = QueryString.new.guess_lines(config, sample_lines)
|
21
21
|
expected = {
|
22
22
|
"parser" => {
|
23
23
|
type: "query_string",
|
24
|
-
|
24
|
+
columns: columns
|
25
25
|
}
|
26
26
|
}
|
27
27
|
assert_equal(expected, actual)
|
28
28
|
end
|
29
29
|
|
30
30
|
data do
|
31
|
-
|
31
|
+
valid_columns = {
|
32
32
|
"parser" => {
|
33
33
|
type: "query_string",
|
34
|
-
|
34
|
+
columns: columns_with_same_keys,
|
35
35
|
}
|
36
36
|
}
|
37
37
|
|
38
38
|
{
|
39
|
-
"query_string" => ["query_string",
|
39
|
+
"query_string" => ["query_string", valid_columns],
|
40
40
|
"other" => ["other", {}],
|
41
41
|
}
|
42
42
|
end
|
@@ -61,7 +61,7 @@ module Embulk
|
|
61
61
|
]
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
64
|
+
def columns_with_same_keys
|
65
65
|
[
|
66
66
|
{name: "foo", type: :long},
|
67
67
|
{name: "bar", type: :string},
|
@@ -76,7 +76,7 @@ module Embulk
|
|
76
76
|
]
|
77
77
|
end
|
78
78
|
|
79
|
-
def
|
79
|
+
def columns_with_different_keys
|
80
80
|
[
|
81
81
|
{name: "foo", type: :long},
|
82
82
|
{name: "bar", type: :string},
|
@@ -94,8 +94,8 @@ module Embulk
|
|
94
94
|
]
|
95
95
|
end
|
96
96
|
|
97
|
-
def
|
98
|
-
|
97
|
+
def columns_with_invalid
|
98
|
+
columns_with_same_keys
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -104,7 +104,7 @@ module Embulk
|
|
104
104
|
"parser" => {
|
105
105
|
"strip_quote" => true,
|
106
106
|
"strip_whitespace" => true,
|
107
|
-
"
|
107
|
+
"columns" => columns,
|
108
108
|
}
|
109
109
|
}
|
110
110
|
end
|
@@ -4,7 +4,7 @@ require "embulk/data_source"
|
|
4
4
|
|
5
5
|
module Embulk
|
6
6
|
module Parser
|
7
|
-
class
|
7
|
+
class QueryStringTest < Test::Unit::TestCase
|
8
8
|
class TestParse < self
|
9
9
|
def test_without_options
|
10
10
|
result = QueryString.parse(line)
|
@@ -106,7 +106,7 @@ module Embulk
|
|
106
106
|
|
107
107
|
def test_transaction
|
108
108
|
expected_task = task.dup
|
109
|
-
expected_task.delete("
|
109
|
+
expected_task.delete("columns")
|
110
110
|
|
111
111
|
QueryString.transaction(config) do |actual_task, actual_columns|
|
112
112
|
assert_equal(expected_task, actual_task)
|
@@ -130,7 +130,7 @@ module Embulk
|
|
130
130
|
"strip_quote" => true,
|
131
131
|
"strip_whitespace" => true,
|
132
132
|
"capture" => "(.*)",
|
133
|
-
"
|
133
|
+
"columns" => columns,
|
134
134
|
}
|
135
135
|
end
|
136
136
|
|
data/test/run-test.rb
CHANGED
data/test/test_embulk_run.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-parser-query_string
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshihara
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-07-
|
12
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,7 +145,7 @@ files:
|
|
145
145
|
- partial-config.yml
|
146
146
|
- test/capture_io.rb
|
147
147
|
- test/embulk/guess/test_query_string.rb
|
148
|
-
- test/embulk/parser/
|
148
|
+
- test/embulk/parser/test_query_string.rb
|
149
149
|
- test/embulk_run_helper.rb
|
150
150
|
- test/prepare_embulk.rb
|
151
151
|
- test/run-test.rb
|
@@ -177,7 +177,7 @@ summary: Query String parser plugin for Embulk
|
|
177
177
|
test_files:
|
178
178
|
- test/capture_io.rb
|
179
179
|
- test/embulk/guess/test_query_string.rb
|
180
|
-
- test/embulk/parser/
|
180
|
+
- test/embulk/parser/test_query_string.rb
|
181
181
|
- test/embulk_run_helper.rb
|
182
182
|
- test/prepare_embulk.rb
|
183
183
|
- test/run-test.rb
|