sql2avro 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/sql2avro.rb +3 -3
  2. metadata +6 -6
data/lib/sql2avro.rb CHANGED
@@ -27,7 +27,7 @@ module Sql2Avro
27
27
  # table is the table to pull from.
28
28
  #
29
29
  # min_id specifies the value of the id column from which to start.
30
- def Sql2Avro.avroize(database_config, table, min_id, max_rows_per_batch=nil)
30
+ def Sql2Avro.avroize(database_config, table, min_id, max_rows_per_batch=nil, directory='/tmp')
31
31
  raise "Database interface not specified." if !database_config.has_key? 'adapter'
32
32
  raise "Database interface not supported: #{database_config['adapter']}" unless ['mysql', 'mysql2'].include? database_config['adapter']
33
33
 
@@ -53,7 +53,7 @@ module Sql2Avro
53
53
  prev_default_internal = Encoding.default_internal
54
54
  Encoding.default_internal = nil
55
55
 
56
- json_file = "#{filename}.json"
56
+ json_file = File.join(directory, "#{filename}.json")
57
57
  File.open(json_file, 'w') do |f|
58
58
  interface.data(table, min_id, max_id_this_batch) do |datum|
59
59
  Yajl::Encoder.encode(datum, f)
@@ -63,7 +63,7 @@ module Sql2Avro
63
63
 
64
64
  Encoding.default_internal = prev_default_internal
65
65
 
66
- cmd = "java -jar #{AVRO_TOOLS_PATH} fromjson --codec snappy --schema '#{schema}' #{json_file} > #{filename}"
66
+ cmd = "java -jar #{AVRO_TOOLS_PATH} fromjson --codec snappy --schema '#{schema}' #{json_file} > #{File.join(directory, filename)}"
67
67
  `#{cmd}`
68
68
  if !$?.success?
69
69
  raise "Error converting JSON to Avro.\n\nCommand: #{cmd}\nStatus: #{$?}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sql2avro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-21 00:00:00.000000000 Z
12
+ date: 2013-06-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
16
- requirement: &70297282972760 !ruby/object:Gem::Requirement
16
+ requirement: &70185617063480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70297282972760
24
+ version_requirements: *70185617063480
25
25
  description: sql2avro extracts data from a specified SQL database table and transforms
26
26
  it into an Avro file with a schema based on the database table's schema. The intended
27
27
  use case is to incrementally load data out of an SQL database and into HDFS for
@@ -52,7 +52,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
52
  version: '0'
53
53
  segments:
54
54
  - 0
55
- hash: -3119210657153955613
55
+ hash: 2389578270000039778
56
56
  required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  segments:
63
63
  - 0
64
- hash: -3119210657153955613
64
+ hash: 2389578270000039778
65
65
  requirements: []
66
66
  rubyforge_project:
67
67
  rubygems_version: 1.8.10