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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 577bbbbfd20a0b5ac1a95053773531166aa6abf4
4
- data.tar.gz: d371c84d90510138671ff77fcd991d73596f5213
3
+ metadata.gz: 4aacb287d4c071f254e3876d81896df78369f2a9
4
+ data.tar.gz: 214293101b683e49c23d05b1a85b42119ffdc5c9
5
5
  SHA512:
6
- metadata.gz: df8f61b4304e53d7e6fa13cbbaa10506db82e911c99b1ed65f4c02047144c3c84b4c7eddf1b88bf17e6b4d878613f35ad6c2ac3fef2f8650901476f2a893f8e5
7
- data.tar.gz: 23f03b8da79ef4e96911f2477dbe686198ca97c47a09609e5038d1b0d17b7808f46060c2fe39200f8052082807969be4c469c4b2cbb20274c602b3efba36d3d5
6
+ metadata.gz: 36517f8ac5bb32b3eb2e41683e305e081d2152ce096ce590a6dc603081da1f2e8e7b919807f15b13fe9dab725281c0443d3b2d09583dc318625a37cb916c248b
7
+ data.tar.gz: 397c4fe3fa874d46a5eb34a54de7b87254d1757f6661a0d7170a7b8335924099a6dbc94ab3d54f40fbcc3b052ec7f9169a7e263defdc8ec71a9eb6a81eda57be
@@ -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
@@ -65,7 +65,7 @@ in:
65
65
  charset: ISO-8859-2
66
66
  newline: CRLF
67
67
  type: query_string
68
- schema:
68
+ columns:
69
69
  - {name: user_id, type: long}
70
70
  - {name: some_param, type: string}
71
71
  exec: {}
@@ -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.1.3"
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", schema: []}
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[:schema] << {name: key, type: :string}
31
+ guessed[:columns] << {name: key, type: :string}
32
32
  else
33
- guessed[:schema] << {name: key, type: :long}
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("schema", :array, default: [])
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
- case column.type
88
- when :long
89
- value.strip.empty? ? nil : Integer(value)
90
- when :timestamp
91
- value.strip.empty? ? nil : Time.parse(value)
92
- else
93
- value.to_s
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, schema_with_same_keys],
12
- different_keys: [sample_lines_with_different_keys, schema_with_different_keys],
13
- invalid: [sample_lines_with_invalid, schema_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 test_schema(data)
19
- sample_lines, schema = data
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
- schema: schema
24
+ columns: columns
25
25
  }
26
26
  }
27
27
  assert_equal(expected, actual)
28
28
  end
29
29
 
30
30
  data do
31
- valid_schema = {
31
+ valid_columns = {
32
32
  "parser" => {
33
33
  type: "query_string",
34
- schema: schema_with_same_keys,
34
+ columns: columns_with_same_keys,
35
35
  }
36
36
  }
37
37
 
38
38
  {
39
- "query_string" => ["query_string", valid_schema],
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 schema_with_same_keys
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 schema_with_different_keys
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 schema_with_invalid
98
- schema_with_same_keys
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
- "schema" => columns,
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 QueryStringPluginTest < Test::Unit::TestCase
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("schema")
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
- "schema" => columns,
133
+ "columns" => columns,
134
134
  }
135
135
  end
136
136
 
@@ -15,4 +15,4 @@ ENV["TEST_UNIT_MAX_DIFF_TARGET_STRING_SIZE"] ||= "5000"
15
15
 
16
16
  CodeClimate::TestReporter.start
17
17
 
18
- exit Test::Unit::AutoRunner.run(true, test_dir)
18
+ exit Test::Unit::AutoRunner.run(true, test_dir, ARGV + %w(--collector=dir))
@@ -97,7 +97,7 @@ in:
97
97
  charset: UTF-8
98
98
  newline: CRLF
99
99
  type: query_string
100
- schema:
100
+ columns:
101
101
  - {name: foo, type: string}
102
102
  - {name: bar, type: long}
103
103
  exec: {}
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.1.3
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-16 00:00:00.000000000 Z
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/test_query_string_plugin.rb
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/test_query_string_plugin.rb
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