click_house 1.2.5 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +131 -7
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +40 -32
- data/README.md +7 -10
- data/click_house.gemspec +3 -3
- data/docker-compose.yml +1 -1
- data/lib/click_house.rb +10 -0
- data/lib/click_house/config.rb +4 -2
- data/lib/click_house/connection.rb +2 -0
- data/lib/click_house/definition/column.rb +1 -1
- data/lib/click_house/definition/column_set.rb +2 -1
- data/lib/click_house/extend/connection_inserting.rb +9 -0
- data/lib/click_house/middleware/logging.rb +2 -2
- data/lib/click_house/type.rb +2 -0
- data/lib/click_house/type/date_time64_type.rb +15 -0
- data/lib/click_house/type/ip_type.rb +15 -0
- data/lib/click_house/version.rb +1 -1
- metadata +21 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 040e53c977b5a0ef62fd73ef8f8b21915a2ec128d0649e3882dd1779e787ff28
|
4
|
+
data.tar.gz: 0c9c46b6c9ce234b497fbb2cbc0834b09fd697ea6a140544465bda93c66d1b9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b93c038ae5da62bdf3a951120da771c21e0b4ce1cd92ed2e381827dacaad0f97fb9121c488d78fab7d6a58ee5ab79d04aed5fb1195d7bd9575cdfd344ab095b
|
7
|
+
data.tar.gz: 52bee84670bfa5c6b8bb8d6566b94f69935b80fc15bc14c1d9223ab3a7be7e7f972c8958b0c28f4836e21ba30b9c8269a1f58375ee87ccf99cbe670df5bd14df
|
data/.rubocop.yml
CHANGED
@@ -8,7 +8,7 @@ AllCops:
|
|
8
8
|
- 'bin/*'
|
9
9
|
- 'spec/**/*'
|
10
10
|
- 'vendor/**/*'
|
11
|
-
TargetRubyVersion: 2.
|
11
|
+
TargetRubyVersion: 2.7
|
12
12
|
|
13
13
|
Bundler/OrderedGems:
|
14
14
|
Enabled: false
|
@@ -17,6 +17,26 @@ Bundler/OrderedGems:
|
|
17
17
|
Style/Documentation:
|
18
18
|
Enabled: false
|
19
19
|
|
20
|
+
# =============================== Performance =======================
|
21
|
+
Performance/AncestorsInclude:
|
22
|
+
Enabled: true
|
23
|
+
Performance/BigDecimalWithNumericArgument:
|
24
|
+
Enabled: true
|
25
|
+
Performance/RedundantSortBlock:
|
26
|
+
Enabled: true
|
27
|
+
Performance/RedundantStringChars:
|
28
|
+
Enabled: true
|
29
|
+
Performance/ReverseFirst:
|
30
|
+
Enabled: true
|
31
|
+
Performance/SortReverse:
|
32
|
+
Enabled: true
|
33
|
+
Performance/Squeeze:
|
34
|
+
Enabled: true
|
35
|
+
Performance/StringInclude:
|
36
|
+
Enabled: true
|
37
|
+
Performance/Sum:
|
38
|
+
Enabled: true
|
39
|
+
|
20
40
|
# ============================== Metrics ============================
|
21
41
|
Metrics/ClassLength:
|
22
42
|
Max: 180
|
@@ -31,22 +51,22 @@ Metrics/AbcSize:
|
|
31
51
|
|
32
52
|
# ============================== Naming =============================
|
33
53
|
Naming/PredicateName:
|
34
|
-
|
54
|
+
ForbiddenPrefixes:
|
35
55
|
- is_
|
36
56
|
Naming/FileName:
|
37
57
|
Enabled: true
|
38
58
|
Exclude:
|
39
59
|
- 'Gemfile'
|
40
|
-
Naming/
|
60
|
+
Naming/MethodParameterName:
|
41
61
|
Enabled: false
|
42
62
|
Naming/AccessorMethodName:
|
43
63
|
Enabled: false
|
44
64
|
|
45
65
|
# ============================== Layout =============================
|
46
|
-
Layout/
|
66
|
+
Layout/HashAlignment:
|
47
67
|
EnforcedHashRocketStyle: key
|
48
68
|
EnforcedColonStyle: key
|
49
|
-
Layout/
|
69
|
+
Layout/ParameterAlignment:
|
50
70
|
EnforcedStyle: with_fixed_indentation
|
51
71
|
Layout/CaseIndentation:
|
52
72
|
EnforcedStyle: case
|
@@ -65,12 +85,16 @@ Layout/EmptyLinesAroundBlockBody:
|
|
65
85
|
Enabled: true
|
66
86
|
Layout/EndAlignment:
|
67
87
|
EnforcedStyleAlignWith: variable
|
68
|
-
Layout/
|
88
|
+
Layout/FirstHashElementIndentation:
|
69
89
|
EnforcedStyle: consistent
|
70
|
-
Layout/
|
90
|
+
Layout/HeredocIndentation:
|
71
91
|
Enabled: false
|
72
92
|
Layout/RescueEnsureAlignment:
|
73
93
|
Enabled: false
|
94
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
95
|
+
Enabled: true
|
96
|
+
Layout/SpaceAroundMethodCallOperator:
|
97
|
+
Enabled: true
|
74
98
|
|
75
99
|
# ============================== Style ==============================
|
76
100
|
Style/RescueModifier:
|
@@ -117,9 +141,109 @@ Style/GuardClause:
|
|
117
141
|
Enabled: false
|
118
142
|
Style/TrailingCommaInHashLiteral:
|
119
143
|
Enabled: false
|
144
|
+
Style/ExponentialNotation:
|
145
|
+
Enabled: true
|
146
|
+
Style/HashEachMethods:
|
147
|
+
Enabled: true
|
148
|
+
Style/HashTransformKeys:
|
149
|
+
Enabled: true
|
150
|
+
Style/HashTransformValues:
|
151
|
+
Enabled: true
|
152
|
+
Style/RedundantFetchBlock:
|
153
|
+
Enabled: true
|
154
|
+
Style/RedundantRegexpCharacterClass:
|
155
|
+
Enabled: true
|
156
|
+
Style/RedundantRegexpEscape:
|
157
|
+
Enabled: true
|
158
|
+
Style/SlicingWithRange:
|
159
|
+
Enabled: true
|
160
|
+
Style/AccessorGrouping:
|
161
|
+
Enabled: false
|
162
|
+
Style/ArrayCoercion:
|
163
|
+
Enabled: true
|
164
|
+
Style/BisectedAttrAccessor:
|
165
|
+
Enabled: true
|
166
|
+
Style/CaseLikeIf:
|
167
|
+
Enabled: true
|
168
|
+
Style/HashAsLastArrayItem:
|
169
|
+
Enabled: true
|
170
|
+
Style/HashLikeCase:
|
171
|
+
Enabled: true
|
172
|
+
Style/RedundantAssignment:
|
173
|
+
Enabled: true
|
174
|
+
Style/RedundantFileExtensionInRequire:
|
175
|
+
Enabled: true
|
176
|
+
Style/ExplicitBlockArgument:
|
177
|
+
Enabled: true
|
178
|
+
Style/GlobalStdStream:
|
179
|
+
Enabled: true
|
180
|
+
Style/OptionalBooleanParameter:
|
181
|
+
Enabled: true
|
182
|
+
Style/SingleArgumentDig:
|
183
|
+
Enabled: true
|
184
|
+
Style/StringConcatenation:
|
185
|
+
Enabled: true
|
186
|
+
Style/ClassEqualityComparison:
|
187
|
+
Enabled: true
|
188
|
+
Style/CombinableLoops:
|
189
|
+
Enabled: true
|
190
|
+
Style/KeywordParametersOrder:
|
191
|
+
Enabled: false
|
192
|
+
Style/RedundantSelfAssignment:
|
193
|
+
Enabled: true
|
194
|
+
Style/SoleNestedConditional:
|
195
|
+
Enabled: true
|
120
196
|
|
121
197
|
# ============================== Lint ==============================
|
122
198
|
Lint/DuplicateMethods:
|
123
199
|
Enabled: false
|
124
200
|
Lint/AmbiguousOperator:
|
125
201
|
Enabled: false
|
202
|
+
Lint/DeprecatedOpenSSLConstant:
|
203
|
+
Enabled: true
|
204
|
+
Lint/MixedRegexpCaptureTypes:
|
205
|
+
Enabled: true
|
206
|
+
Lint/RaiseException:
|
207
|
+
Enabled: true
|
208
|
+
Lint/StructNewOverride:
|
209
|
+
Enabled: true
|
210
|
+
Lint/DuplicateElsifCondition:
|
211
|
+
Enabled: true
|
212
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
213
|
+
Enabled: true
|
214
|
+
Lint/DuplicateRescueException:
|
215
|
+
Enabled: true
|
216
|
+
Lint/EmptyConditionalBody:
|
217
|
+
Enabled: true
|
218
|
+
Lint/FloatComparison:
|
219
|
+
Enabled: true
|
220
|
+
Lint/MissingSuper:
|
221
|
+
Enabled: false
|
222
|
+
Lint/OutOfRangeRegexpRef:
|
223
|
+
Enabled: true
|
224
|
+
Lint/SelfAssignment:
|
225
|
+
Enabled: true
|
226
|
+
Lint/TopLevelReturnWithArgument:
|
227
|
+
Enabled: true
|
228
|
+
Lint/UnreachableLoop:
|
229
|
+
Enabled: true
|
230
|
+
Layout/BeginEndAlignment:
|
231
|
+
Enabled: true
|
232
|
+
Lint/ConstantDefinitionInBlock:
|
233
|
+
Enabled: true
|
234
|
+
Lint/DuplicateRequire:
|
235
|
+
Enabled: true
|
236
|
+
Lint/EmptyFile:
|
237
|
+
Enabled: true
|
238
|
+
Lint/HashCompareByIdentity:
|
239
|
+
Enabled: true
|
240
|
+
Lint/IdentityComparison:
|
241
|
+
Enabled: true
|
242
|
+
Lint/RedundantSafeNavigation:
|
243
|
+
Enabled: true
|
244
|
+
Lint/TrailingCommaInAttributeDeclaration:
|
245
|
+
Enabled: true
|
246
|
+
Lint/UselessMethodDefinition:
|
247
|
+
Enabled: true
|
248
|
+
Lint/UselessTimes:
|
249
|
+
Enabled: true
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# 1.3.2
|
2
|
+
* fix null logger for windows users
|
3
|
+
|
4
|
+
# 1.3.1
|
5
|
+
* added request [headers](https://github.com/shlima/click_house/pull/8) support
|
6
|
+
|
7
|
+
# 1.3.0
|
8
|
+
* added support for IPv4/IPv6 types
|
9
|
+
|
10
|
+
# 1.2.7
|
11
|
+
* rubocop version bump
|
12
|
+
|
13
|
+
# 1.2.6
|
14
|
+
* Datetime64 field type support [#3](https://github.com/shlima/click_house/pull/3)
|
data/Gemfile.lock
CHANGED
@@ -1,67 +1,75 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
click_house (1.2
|
4
|
+
click_house (1.3.2)
|
5
5
|
faraday
|
6
6
|
faraday_middleware
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
ast (2.4.
|
12
|
-
coderay (1.1.
|
13
|
-
diff-lcs (1.
|
14
|
-
faraday (
|
11
|
+
ast (2.4.1)
|
12
|
+
coderay (1.1.3)
|
13
|
+
diff-lcs (1.4.4)
|
14
|
+
faraday (1.1.0)
|
15
15
|
multipart-post (>= 1.2, < 3)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
method_source (0.
|
16
|
+
ruby2_keywords
|
17
|
+
faraday_middleware (1.0.0)
|
18
|
+
faraday (~> 1.0)
|
19
|
+
method_source (1.0.0)
|
20
20
|
multipart-post (2.1.1)
|
21
|
-
parallel (1.
|
22
|
-
parser (2.
|
23
|
-
ast (~> 2.4.
|
24
|
-
pry (0.
|
25
|
-
coderay (~> 1.1
|
26
|
-
method_source (~>
|
21
|
+
parallel (1.19.2)
|
22
|
+
parser (2.7.2.0)
|
23
|
+
ast (~> 2.4.1)
|
24
|
+
pry (0.13.1)
|
25
|
+
coderay (~> 1.1)
|
26
|
+
method_source (~> 1.0)
|
27
27
|
rainbow (3.0.0)
|
28
|
-
rake (13.0.
|
28
|
+
rake (13.0.1)
|
29
|
+
regexp_parser (1.8.2)
|
30
|
+
rexml (3.2.4)
|
29
31
|
rspec (3.9.0)
|
30
32
|
rspec-core (~> 3.9.0)
|
31
33
|
rspec-expectations (~> 3.9.0)
|
32
34
|
rspec-mocks (~> 3.9.0)
|
33
|
-
rspec-core (3.9.
|
34
|
-
rspec-support (~> 3.9.
|
35
|
-
rspec-expectations (3.9.
|
35
|
+
rspec-core (3.9.3)
|
36
|
+
rspec-support (~> 3.9.3)
|
37
|
+
rspec-expectations (3.9.2)
|
36
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
39
|
rspec-support (~> 3.9.0)
|
38
|
-
rspec-mocks (3.9.
|
40
|
+
rspec-mocks (3.9.1)
|
39
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
42
|
rspec-support (~> 3.9.0)
|
41
|
-
rspec-support (3.9.
|
42
|
-
rubocop (0.
|
43
|
-
jaro_winkler (~> 1.5.1)
|
43
|
+
rspec-support (3.9.3)
|
44
|
+
rubocop (0.93.1)
|
44
45
|
parallel (~> 1.10)
|
45
|
-
parser (>= 2.
|
46
|
+
parser (>= 2.7.1.5)
|
46
47
|
rainbow (>= 2.2.2, < 4.0)
|
48
|
+
regexp_parser (>= 1.8)
|
49
|
+
rexml
|
50
|
+
rubocop-ast (>= 0.6.0)
|
47
51
|
ruby-progressbar (~> 1.7)
|
48
|
-
unicode-display_width (>= 1.4.0, <
|
49
|
-
rubocop-
|
50
|
-
|
52
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
53
|
+
rubocop-ast (0.8.0)
|
54
|
+
parser (>= 2.7.1.5)
|
55
|
+
rubocop-performance (1.8.1)
|
56
|
+
rubocop (>= 0.87.0)
|
57
|
+
rubocop-ast (>= 0.4.0)
|
51
58
|
ruby-progressbar (1.10.1)
|
52
|
-
|
59
|
+
ruby2_keywords (0.0.2)
|
60
|
+
unicode-display_width (1.7.0)
|
53
61
|
|
54
62
|
PLATFORMS
|
55
63
|
ruby
|
56
64
|
|
57
65
|
DEPENDENCIES
|
58
|
-
bundler
|
66
|
+
bundler
|
59
67
|
click_house!
|
60
68
|
pry
|
61
|
-
rake
|
62
|
-
rspec
|
69
|
+
rake
|
70
|
+
rspec
|
63
71
|
rubocop
|
64
72
|
rubocop-performance
|
65
73
|
|
66
74
|
BUNDLED WITH
|
67
|
-
1.
|
75
|
+
2.1.4
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
[![Gem Version](https://badge.fury.io/rb/click_house.svg)](https://badge.fury.io/rb/click_house)
|
8
8
|
|
9
9
|
```bash
|
10
|
-
# Requires modern Ruby (>= 2.5), tested with Yandex.Clickhouse v
|
10
|
+
# Requires modern Ruby (>= 2.5), tested with Yandex.Clickhouse v 20.9.3.45
|
11
11
|
gem install click_house
|
12
12
|
```
|
13
13
|
|
@@ -53,6 +53,7 @@ ClickHouse.config do |config|
|
|
53
53
|
config.timeout = 60
|
54
54
|
config.open_timeout = 3
|
55
55
|
config.ssl_verify = false
|
56
|
+
config.headers = {}
|
56
57
|
|
57
58
|
# or provide connection options separately
|
58
59
|
config.scheme = 'http'
|
@@ -216,7 +217,8 @@ ClickHouse.connection.create_table('visits', if_not_exists: true, engine: 'Merge
|
|
216
217
|
t.Decimal :money, 5, 4
|
217
218
|
t.String :event
|
218
219
|
t.UInt32 :user_id
|
219
|
-
t.
|
220
|
+
t.IPv4 :ipv4
|
221
|
+
t.IPv6 :ipv6
|
220
222
|
end
|
221
223
|
```
|
222
224
|
|
@@ -328,11 +330,11 @@ ClickHouse.add_type('Date', DateType.new)
|
|
328
330
|
Actually `serialize` function is not used for now, but you may use it manually:
|
329
331
|
|
330
332
|
```ruby
|
331
|
-
time_type = DateTimeType.new
|
332
|
-
string_type = FixedStringType.new
|
333
|
+
time_type = ClickHouse::Type::DateTimeType.new
|
334
|
+
string_type = ClickHouse::Type::FixedStringType.new
|
333
335
|
|
334
336
|
ClickHouse.connection.insert('table', columns: %i[name time]) do |buffer|
|
335
|
-
buffer << [string_type.serialize('a' * 1000, 20),
|
337
|
+
buffer << [string_type.serialize('a' * 1000, 20), time_type.serialize(Time.current, 'Europe/Moscow')]
|
336
338
|
end
|
337
339
|
|
338
340
|
## alternatively
|
@@ -448,11 +450,6 @@ class CreateAdvertVisits < ActiveRecord::Migration[6.0]
|
|
448
450
|
t.UInt16 :account_id
|
449
451
|
t.UInt16 :user_id
|
450
452
|
t.Date :date
|
451
|
-
t.DateTime :time, 'UTC'
|
452
|
-
t.UInt32 :ipv4
|
453
|
-
t.UInt64 :ipv6
|
454
|
-
t.UInt32 :device_type_id
|
455
|
-
t.UInt32 :os_family_id
|
456
453
|
end
|
457
454
|
end
|
458
455
|
|
data/click_house.gemspec
CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency 'faraday'
|
24
24
|
spec.add_dependency 'faraday_middleware'
|
25
|
-
spec.add_development_dependency 'bundler'
|
26
|
-
spec.add_development_dependency 'rake'
|
27
|
-
spec.add_development_dependency 'rspec'
|
25
|
+
spec.add_development_dependency 'bundler'
|
26
|
+
spec.add_development_dependency 'rake'
|
27
|
+
spec.add_development_dependency 'rspec'
|
28
28
|
spec.add_development_dependency 'pry'
|
29
29
|
spec.add_development_dependency 'rubocop'
|
30
30
|
spec.add_development_dependency 'rubocop-performance'
|
data/docker-compose.yml
CHANGED
data/lib/click_house.rb
CHANGED
@@ -41,6 +41,11 @@ module ClickHouse
|
|
41
41
|
add_type "Nullable(#{column})", Type::NullableType.new(Type::DateTimeType.new)
|
42
42
|
end
|
43
43
|
|
44
|
+
['DateTime64(%d, %s)'].each do |column|
|
45
|
+
add_type column, Type::DateTime64Type.new
|
46
|
+
add_type "Nullable(#{column})", Type::NullableType.new(Type::DateTime64Type.new)
|
47
|
+
end
|
48
|
+
|
44
49
|
['Decimal(%s, %s)', 'Decimal32(%s)', 'Decimal64(%s)', 'Decimal128(%s)'].each do |column|
|
45
50
|
add_type column, Type::DecimalType.new
|
46
51
|
add_type "Nullable(#{column})", Type::NullableType.new(Type::DecimalType.new)
|
@@ -55,4 +60,9 @@ module ClickHouse
|
|
55
60
|
add_type column, Type::FloatType.new
|
56
61
|
add_type "Nullable(#{column})", Type::NullableType.new(Type::IntegerType.new)
|
57
62
|
end
|
63
|
+
|
64
|
+
%w[IPv4 IPv6].each do |column|
|
65
|
+
add_type column, Type::IPType.new
|
66
|
+
add_type "Nullable(#{column})", Type::NullableType.new(Type::IPType.new)
|
67
|
+
end
|
58
68
|
end
|
data/lib/click_house/config.rb
CHANGED
@@ -18,7 +18,8 @@ module ClickHouse
|
|
18
18
|
password: nil,
|
19
19
|
timeout: nil,
|
20
20
|
open_timeout: nil,
|
21
|
-
ssl_verify: false
|
21
|
+
ssl_verify: false,
|
22
|
+
headers: {}
|
22
23
|
}.freeze
|
23
24
|
|
24
25
|
attr_accessor :adapter
|
@@ -33,6 +34,7 @@ module ClickHouse
|
|
33
34
|
attr_accessor :timeout
|
34
35
|
attr_accessor :open_timeout
|
35
36
|
attr_accessor :ssl_verify
|
37
|
+
attr_accessor :headers
|
36
38
|
|
37
39
|
def initialize(params = {})
|
38
40
|
assign(DEFAULTS.merge(params))
|
@@ -51,7 +53,7 @@ module ClickHouse
|
|
51
53
|
end
|
52
54
|
|
53
55
|
def logger!
|
54
|
-
@logger || Logger.new(
|
56
|
+
@logger || Logger.new(IO::NULL)
|
55
57
|
end
|
56
58
|
|
57
59
|
def url!
|
@@ -11,6 +11,7 @@ module ClickHouse
|
|
11
11
|
|
12
12
|
attr_reader :config
|
13
13
|
|
14
|
+
# @param [Config]
|
14
15
|
def initialize(config)
|
15
16
|
@config = config
|
16
17
|
end
|
@@ -31,6 +32,7 @@ module ClickHouse
|
|
31
32
|
@transport ||= Faraday.new(config.url!) do |conn|
|
32
33
|
conn.options.timeout = config.timeout
|
33
34
|
conn.options.open_timeout = config.open_timeout
|
35
|
+
conn.headers = config.headers
|
34
36
|
conn.ssl.verify = config.ssl_verify
|
35
37
|
conn.basic_auth(config.username, config.password) if config.auth?
|
36
38
|
conn.response Middleware::Logging, logger: config.logger!
|
@@ -39,7 +39,7 @@ module ClickHouse
|
|
39
39
|
def extension_type
|
40
40
|
extensions.nil? ? type : format(type, *extensions)
|
41
41
|
rescue TypeError, ArgumentError
|
42
|
-
raise
|
42
|
+
raise StandardError, "please provide extensions for <#{type}>"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -6,6 +6,15 @@ module ClickHouse
|
|
6
6
|
EMPTY_INSERT = true
|
7
7
|
|
8
8
|
# @return [Boolean]
|
9
|
+
#
|
10
|
+
# == Example with a block
|
11
|
+
# insert('rspec', columns: %i[name id]) do |buffer|
|
12
|
+
# buffer << ['Sun', 1]
|
13
|
+
# buffer << ['Moon', 2]
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# == Example with a param
|
17
|
+
# subject.insert('rspec', values: [{ name: 'Sun', id: 1 }, { name: 'Moon', id: 2 }])
|
9
18
|
def insert(table, columns: [], values: [])
|
10
19
|
yield(values) if block_given?
|
11
20
|
|
@@ -26,7 +26,7 @@ module ClickHouse
|
|
26
26
|
logger.level == Logger::DEBUG
|
27
27
|
end
|
28
28
|
|
29
|
-
# rubocop:disable
|
29
|
+
# rubocop:disable Layout/LineLength
|
30
30
|
def on_complete(env)
|
31
31
|
summary = extract_summary(env.response_headers)
|
32
32
|
elapsed = duration
|
@@ -36,7 +36,7 @@ module ClickHouse
|
|
36
36
|
logger.debug(body) if body
|
37
37
|
logger.info("\e[1m[36mRead: #{summary.fetch(:read_rows)} rows, #{summary.fetch(:read_bytes)}. Written: #{summary.fetch(:written_rows)}, rows #{summary.fetch(:written_bytes)}\e[0m")
|
38
38
|
end
|
39
|
-
# rubocop:enable
|
39
|
+
# rubocop:enable Layout/LineLength
|
40
40
|
|
41
41
|
def duration
|
42
42
|
timestamp - starting
|
data/lib/click_house/type.rb
CHANGED
@@ -7,6 +7,7 @@ module ClickHouse
|
|
7
7
|
autoload :UndefinedType, 'click_house/type/undefined_type'
|
8
8
|
autoload :DateType, 'click_house/type/date_type'
|
9
9
|
autoload :DateTimeType, 'click_house/type/date_time_type'
|
10
|
+
autoload :DateTime64Type, 'click_house/type/date_time64_type'
|
10
11
|
autoload :IntegerType, 'click_house/type/integer_type'
|
11
12
|
autoload :FloatType, 'click_house/type/float_type'
|
12
13
|
autoload :BooleanType, 'click_house/type/boolean_type'
|
@@ -14,5 +15,6 @@ module ClickHouse
|
|
14
15
|
autoload :FixedStringType, 'click_house/type/fixed_string_type'
|
15
16
|
autoload :ArrayType, 'click_house/type/array_type'
|
16
17
|
autoload :StringType, 'click_house/type/string_type'
|
18
|
+
autoload :IPType, 'click_house/type/ip_type'
|
17
19
|
end
|
18
20
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ClickHouse
|
4
|
+
module Type
|
5
|
+
class DateTime64Type < BaseType
|
6
|
+
def cast(value, _precision = nil, tz = nil)
|
7
|
+
DateTime.parse("#{value} #{tz}")
|
8
|
+
end
|
9
|
+
|
10
|
+
def serialize(value, precision = 3)
|
11
|
+
value.strftime("%Y-%m-%d %H:%M:%S.%#{precision}N")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/click_house/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: click_house
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aliaksandr Shylau
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -42,44 +42,44 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: pry
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- ".rspec"
|
134
134
|
- ".rubocop.yml"
|
135
135
|
- ".travis.yml"
|
136
|
+
- CHANGELOG.md
|
136
137
|
- Gemfile
|
137
138
|
- Gemfile.lock
|
138
139
|
- LICENCE.txt
|
@@ -173,12 +174,14 @@ files:
|
|
173
174
|
- lib/click_house/type/array_type.rb
|
174
175
|
- lib/click_house/type/base_type.rb
|
175
176
|
- lib/click_house/type/boolean_type.rb
|
177
|
+
- lib/click_house/type/date_time64_type.rb
|
176
178
|
- lib/click_house/type/date_time_type.rb
|
177
179
|
- lib/click_house/type/date_type.rb
|
178
180
|
- lib/click_house/type/decimal_type.rb
|
179
181
|
- lib/click_house/type/fixed_string_type.rb
|
180
182
|
- lib/click_house/type/float_type.rb
|
181
183
|
- lib/click_house/type/integer_type.rb
|
184
|
+
- lib/click_house/type/ip_type.rb
|
182
185
|
- lib/click_house/type/nullable_type.rb
|
183
186
|
- lib/click_house/type/string_type.rb
|
184
187
|
- lib/click_house/type/undefined_type.rb
|
@@ -191,7 +194,7 @@ files:
|
|
191
194
|
homepage: https://github.com/shlima/click_house
|
192
195
|
licenses: []
|
193
196
|
metadata: {}
|
194
|
-
post_install_message:
|
197
|
+
post_install_message:
|
195
198
|
rdoc_options: []
|
196
199
|
require_paths:
|
197
200
|
- lib
|
@@ -206,8 +209,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
209
|
- !ruby/object:Gem::Version
|
207
210
|
version: '0'
|
208
211
|
requirements: []
|
209
|
-
rubygems_version: 3.
|
210
|
-
signing_key:
|
212
|
+
rubygems_version: 3.1.2
|
213
|
+
signing_key:
|
211
214
|
specification_version: 4
|
212
215
|
summary: Modern Ruby database driver for ClickHouse
|
213
216
|
test_files: []
|