redshift_connector 8.1.0 → 8.1.2

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
  SHA256:
3
- metadata.gz: f91f71e729689abb4d8e006688ca6da92c0853050d8a06e82e90098ab4729fd9
4
- data.tar.gz: 871d84fffd775eb4abb820b4d91b2315a64b576e90d06c19fb4c33f5cb24ff23
3
+ metadata.gz: bf802a784e9ad99f3d43a7dcae9497c610ae46e4fcf5745ab7843ae8c50ce0eb
4
+ data.tar.gz: 710ef721c8e4a35384cfb71789413d70ec6dbb205c0395bedefdddc27b9a6f7d
5
5
  SHA512:
6
- metadata.gz: 2bd66b6346d27c293c74d74a422666cd28faa3116122458b2385e77c51b980af7686096df0feb8d37cf9cc7fb92c977dcce361667ee048321e62b89c5b445f06
7
- data.tar.gz: 43172e49458067e5d7b0fffd53c0bd6a1a0ab3b867cf66418ecbab55a828b2c01822890559b494291f1941de5089a22b4cd5694b094aaca77e58143e3cdff543
6
+ metadata.gz: 64bf13d4fdcc2a43d8ec1310599491a802d88584732a453cdb53f95e048cc5fb3617789b75c3bb78004e76ee2ddbc87fcf7d5d579bccbe76242a7e423a06e0e7
7
+ data.tar.gz: 404aa0311e7bf20028bf1bc53f2194ef8cd320e76a360c3542be39299a0f48d7df1f42a2d3e2dab67b914cc640127bac42f39bf2a8790d3d177e7b2bed0d19c6
data/RELEASE.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Release Note
2
2
 
3
+ ## version 8.1.2
4
+ - [new] Add type cast option instead of filter option for #transport_delta and #transport_all.
5
+ ## version 8.1.1
6
+ - [fix] Boolean type cast was reverse.
7
+
3
8
  ## version 8.1.0
4
9
 
5
10
  - [new] Add type cast option for queuery.
@@ -4,7 +4,8 @@ require 'redshift_connector/logger'
4
4
 
5
5
  module RedshiftConnector
6
6
  class ActiveRecordExporter
7
- def initialize(ds:, query:, bundle_params:, enable_sort: false, logger: RedshiftConnector.logger)
7
+ def initialize(ds:, query:, bundle_params:, enable_sort: false, enable_cast: false, logger: RedshiftConnector.logger)
8
+ raise ArgumentError, "ActiveRecordExporter does not support type cast" if enable_cast
8
9
  @ds = ds
9
10
  @query = query
10
11
  @bundle_params = bundle_params
@@ -49,13 +49,17 @@ module RedshiftConnector
49
49
  upsert_columns: nil,
50
50
  bucket: nil,
51
51
  txn_id: nil,
52
- filter:,
52
+ filter: nil,
53
+ enable_cast: false,
53
54
  logger: RedshiftConnector.logger,
54
55
  quiet: false
55
56
  )
56
57
  unless src_table and dest_table
57
58
  raise ArgumentError, "missing :table, :src_table or :dest_table"
58
59
  end
60
+ raise ArgumentError, "filter and enable_cast are exclusive" if filter and enable_cast
61
+ raise ArgumentError, "either filter or enable_cast is required" unless filter or enable_cast
62
+
59
63
  logger = NullLogger.new if quiet
60
64
  bundle_params = DataFileBundleParams.new(
61
65
  bucket: bucket,
@@ -70,6 +74,7 @@ module RedshiftConnector
70
74
  table: src_table,
71
75
  columns: columns,
72
76
  condition: condition,
77
+ enable_cast: enable_cast,
73
78
  logger: logger
74
79
  )
75
80
  importer = Importer.for_delta_upsert(
@@ -119,10 +124,14 @@ module RedshiftConnector
119
124
  columns:,
120
125
  bucket: nil,
121
126
  txn_id: nil,
122
- filter:,
127
+ filter: nil,
128
+ enable_cast: false,
123
129
  logger: RedshiftConnector.logger,
124
130
  quiet: false
125
131
  )
132
+ raise ArgumentError, "filter and enable_cast are exclusive" if filter and enable_cast
133
+ raise ArgumentError, "either filter or enable_cast is required" unless filter or enable_cast
134
+
126
135
  logger = NullLogger.new if quiet
127
136
  bundle_params = DataFileBundleParams.new(
128
137
  bucket: bucket,
@@ -136,6 +145,7 @@ module RedshiftConnector
136
145
  schema: schema,
137
146
  table: src_table,
138
147
  columns: columns,
148
+ enable_cast: enable_cast,
139
149
  logger: logger
140
150
  )
141
151
  importer = Importer.for_rebuild(
@@ -8,14 +8,14 @@ module RedshiftConnector
8
8
  @exporter_class = exporter_class
9
9
  end
10
10
 
11
- def build_for_table_delta(schema:, table:, condition:, columns:, bundle_params:, logger: RedshiftConnector.logger)
11
+ def build_for_table_delta(schema:, table:, condition:, columns:, enable_cast:, bundle_params:, logger: RedshiftConnector.logger)
12
12
  query = DeltaQuery.new(schema: schema, table: table, columns: columns, condition: condition)
13
- @exporter_class.new(ds: @ds, query: query, bundle_params: bundle_params, logger: logger)
13
+ @exporter_class.new(ds: @ds, query: query, bundle_params: bundle_params, enable_cast: enable_cast, logger: logger)
14
14
  end
15
15
 
16
- def build_for_table(schema:, table:, columns:, bundle_params:, logger: RedshiftConnector.logger)
16
+ def build_for_table(schema:, table:, columns:, enable_cast:, bundle_params:, logger: RedshiftConnector.logger)
17
17
  query = SelectAllQuery.new(schema: schema, table: table, columns: columns)
18
- @exporter_class.new(ds: @ds, query: query, bundle_params: bundle_params, logger: logger)
18
+ @exporter_class.new(ds: @ds, query: query, bundle_params: bundle_params, enable_cast: enable_cast, logger: logger)
19
19
  end
20
20
 
21
21
  def build_for_query(
@@ -1,6 +1,17 @@
1
1
 
2
2
  module RedshiftConnector
3
3
  module RedshiftDataType
4
+ FALSE_VALUES = [
5
+ false, 0,
6
+ "0", :"0",
7
+ "f", :f,
8
+ "F", :F,
9
+ "false", :false,
10
+ "FALSE", :FALSE,
11
+ "off", :off,
12
+ "OFF", :OFF,
13
+ ].to_set.freeze
14
+
4
15
  def self.type_cast(row, manifest_file)
5
16
  row.zip(manifest_file.column_types).map do |value, type|
6
17
  next nil if (value == '' and type != 'character varing') # null becomes '' on unload
@@ -17,7 +28,7 @@ module RedshiftConnector
17
28
  when 'date'
18
29
  Date.parse(value)
19
30
  when 'boolean'
20
- value == 'true' ? true : false
31
+ FALSE_VALUES.include?(value) ? false : true
21
32
  else
22
33
  raise "not support data type: #{type}"
23
34
  end
@@ -1,3 +1,3 @@
1
1
  module RedshiftConnector
2
- VERSION = '8.1.0'
2
+ VERSION = '8.1.2'
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.1.0
4
+ version: 8.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minero Aoki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-07 00:00:00.000000000 Z
11
+ date: 2021-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord