redshift_connector 8.0.1 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f537c83a87a3eb1a0299d4bb5c33d9ea597a1893942257cb24fe6d0bff33892
4
- data.tar.gz: b337cb256f704548668f9c0e7f70852e4b2e7d66adc0b28301ddace2379758c8
3
+ metadata.gz: f91f71e729689abb4d8e006688ca6da92c0853050d8a06e82e90098ab4729fd9
4
+ data.tar.gz: 871d84fffd775eb4abb820b4d91b2315a64b576e90d06c19fb4c33f5cb24ff23
5
5
  SHA512:
6
- metadata.gz: dc3d01359c08e23fa5c82b6d75929f9332172c18724d891e6fd563ba2a276e110d21ec5cc56c50a51eb2c5b24ae40965c3b4a5bd07e4a43999baaf44bd18806b
7
- data.tar.gz: 462e755a64d4a92822d56c78dd76d4bbff2403da7c7191290a8d5fa02541d418b18040aaf8118be923b1775552c7e51632df806227e7d7cfad196d80143f4cf8
6
+ metadata.gz: 2bd66b6346d27c293c74d74a422666cd28faa3116122458b2385e77c51b980af7686096df0feb8d37cf9cc7fb92c977dcce361667ee048321e62b89c5b445f06
7
+ data.tar.gz: 43172e49458067e5d7b0fffd53c0bd6a1a0ab3b867cf66418ecbab55a828b2c01822890559b494291f1941de5089a22b4cd5694b094aaca77e58143e3cdff543
data/RELEASE.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release Note
2
2
 
3
+ ## version 8.1.0
4
+
5
+ - [new] Add type cast option for queuery.
6
+
3
7
  ## version 8.0.1
4
8
 
5
9
  - [fix] Loosen pg version restriction to allow >0.18 to support Rails 5.
@@ -1,4 +1,5 @@
1
1
  require 'redshift_connector/logger'
2
+ require 'redshift_connector/redshift_data_type'
2
3
  require 'forwardable'
3
4
 
4
5
  module RedshiftConnector
@@ -22,7 +23,14 @@ module RedshiftConnector
22
23
 
23
24
  def each_row(&block)
24
25
  each_object do |obj|
25
- obj.each_row(&block)
26
+ if @bundle.respond_to?(:has_manifest?) && @bundle.has_manifest?
27
+ obj.each_row do |row|
28
+ yield RedshiftDataType.type_cast(row, @bundle.manifest_file)
29
+ end
30
+ else
31
+ obj.each_row(&block)
32
+ end
33
+
26
34
  end
27
35
  end
28
36
 
@@ -68,5 +76,6 @@ module RedshiftConnector
68
76
  yield buf unless buf.empty?
69
77
  end
70
78
  private :do_each_batch
79
+
71
80
  end
72
81
  end
@@ -23,8 +23,10 @@ module RedshiftConnector
23
23
  table:,
24
24
  bucket: nil,
25
25
  query:,
26
+ query_params: [],
26
27
  txn_id: "#{Time.now.strftime('%Y%m%d_%H%M%S')}_#{$$}",
27
28
  enable_sort: false,
29
+ enable_cast: false,
28
30
  logger: RedshiftConnector.logger,
29
31
  quiet: false
30
32
  )
@@ -39,8 +41,10 @@ module RedshiftConnector
39
41
  @exporter_class.new(
40
42
  ds: @ds,
41
43
  query: ArbitraryQuery.new(query),
44
+ query_params: query_params,
42
45
  bundle_params: bundle_params,
43
46
  enable_sort: enable_sort,
47
+ enable_cast: enable_cast,
44
48
  logger: logger
45
49
  )
46
50
  end
@@ -0,0 +1,27 @@
1
+
2
+ module RedshiftConnector
3
+ module RedshiftDataType
4
+ def self.type_cast(row, manifest_file)
5
+ row.zip(manifest_file.column_types).map do |value, type|
6
+ next nil if (value == '' and type != 'character varing') # null becomes '' on unload
7
+
8
+ case type
9
+ when 'smallint', 'integer', 'bigint'
10
+ value.to_i
11
+ when 'numeric', 'double precision'
12
+ value.to_f
13
+ when 'character', 'character varying'
14
+ value
15
+ when 'timestamp without time zone', 'timestamp with time zone'
16
+ Time.parse(value)
17
+ when 'date'
18
+ Date.parse(value)
19
+ when 'boolean'
20
+ value == 'true' ? true : false
21
+ else
22
+ raise "not support data type: #{type}"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module RedshiftConnector
2
- VERSION = '8.0.1'
2
+ VERSION = '8.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redshift_connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.1
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minero Aoki
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-17 00:00:00.000000000 Z
11
+ date: 2021-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -159,6 +159,7 @@ files:
159
159
  - lib/redshift_connector/reader/exception.rb
160
160
  - lib/redshift_connector/reader/redshift_csv.rb
161
161
  - lib/redshift_connector/reader/tsv.rb
162
+ - lib/redshift_connector/redshift_data_type.rb
162
163
  - lib/redshift_connector/s3_bucket.rb
163
164
  - lib/redshift_connector/s3_data_file.rb
164
165
  - lib/redshift_connector/s3_data_file_bundle.rb
@@ -168,7 +169,7 @@ homepage: https://github.com/bricolages/redshift_connector
168
169
  licenses:
169
170
  - MIT
170
171
  metadata: {}
171
- post_install_message:
172
+ post_install_message:
172
173
  rdoc_options: []
173
174
  require_paths:
174
175
  - lib
@@ -183,8 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
184
  - !ruby/object:Gem::Version
184
185
  version: '0'
185
186
  requirements: []
186
- rubygems_version: 3.1.2
187
- signing_key:
187
+ rubygems_version: 3.1.6
188
+ signing_key:
188
189
  specification_version: 4
189
190
  summary: Redshift bulk data connector
190
191
  test_files: []