click_house 1.2.3 → 1.3.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 +4 -4
- data/.rubocop.yml +99 -7
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +37 -32
- data/README.md +66 -7
- data/click_house.gemspec +3 -3
- data/docker-compose.yml +1 -1
- data/lib/click_house.rb +10 -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 +14 -0
- data/lib/click_house/middleware/logging.rb +2 -2
- data/lib/click_house/type.rb +2 -0
- data/lib/click_house/type/base_type.rb +2 -2
- data/lib/click_house/type/date_time64_type.rb +15 -0
- data/lib/click_house/type/date_time_type.rb +1 -1
- data/lib/click_house/type/ip_type.rb +15 -0
- data/lib/click_house/type/nullable_type.rb +2 -2
- data/lib/click_house/type/undefined_type.rb +1 -1
- 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: 73a7b3a1d277214b437bf34712185e436d372a6396d0e388a446e3f29c61ac0e
|
4
|
+
data.tar.gz: 42869ca836d053d80299126149dc88266da4a0b31ce96837fc02348d60dc0394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e308c6f52fc984e3532453a869603d727620d3db61533ff80307caa06c481a5dec29685c38fb46527dea94e9d3577ee5c8918af79aa85bd8697ae7a22063b26
|
7
|
+
data.tar.gz: 9dc3e6b31f65c6b3cee80aaa657fe924face07474d256714da34d4287128a26563a463e7b14019564895d4d6821b5b2aaf7324418530fd8c548d629522f15008
|
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,24 @@ 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
|
+
|
20
38
|
# ============================== Metrics ============================
|
21
39
|
Metrics/ClassLength:
|
22
40
|
Max: 180
|
@@ -31,22 +49,22 @@ Metrics/AbcSize:
|
|
31
49
|
|
32
50
|
# ============================== Naming =============================
|
33
51
|
Naming/PredicateName:
|
34
|
-
|
52
|
+
ForbiddenPrefixes:
|
35
53
|
- is_
|
36
54
|
Naming/FileName:
|
37
55
|
Enabled: true
|
38
56
|
Exclude:
|
39
57
|
- 'Gemfile'
|
40
|
-
Naming/
|
58
|
+
Naming/MethodParameterName:
|
41
59
|
Enabled: false
|
42
60
|
Naming/AccessorMethodName:
|
43
61
|
Enabled: false
|
44
62
|
|
45
63
|
# ============================== Layout =============================
|
46
|
-
Layout/
|
64
|
+
Layout/HashAlignment:
|
47
65
|
EnforcedHashRocketStyle: key
|
48
66
|
EnforcedColonStyle: key
|
49
|
-
Layout/
|
67
|
+
Layout/ParameterAlignment:
|
50
68
|
EnforcedStyle: with_fixed_indentation
|
51
69
|
Layout/CaseIndentation:
|
52
70
|
EnforcedStyle: case
|
@@ -65,12 +83,16 @@ Layout/EmptyLinesAroundBlockBody:
|
|
65
83
|
Enabled: true
|
66
84
|
Layout/EndAlignment:
|
67
85
|
EnforcedStyleAlignWith: variable
|
68
|
-
Layout/
|
86
|
+
Layout/FirstHashElementIndentation:
|
69
87
|
EnforcedStyle: consistent
|
70
|
-
Layout/
|
88
|
+
Layout/HeredocIndentation:
|
71
89
|
Enabled: false
|
72
90
|
Layout/RescueEnsureAlignment:
|
73
91
|
Enabled: false
|
92
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
93
|
+
Enabled: true
|
94
|
+
Layout/SpaceAroundMethodCallOperator:
|
95
|
+
Enabled: true
|
74
96
|
|
75
97
|
# ============================== Style ==============================
|
76
98
|
Style/RescueModifier:
|
@@ -117,9 +139,79 @@ Style/GuardClause:
|
|
117
139
|
Enabled: false
|
118
140
|
Style/TrailingCommaInHashLiteral:
|
119
141
|
Enabled: false
|
142
|
+
Style/ExponentialNotation:
|
143
|
+
Enabled: true
|
144
|
+
Style/HashEachMethods:
|
145
|
+
Enabled: true
|
146
|
+
Style/HashTransformKeys:
|
147
|
+
Enabled: true
|
148
|
+
Style/HashTransformValues:
|
149
|
+
Enabled: true
|
150
|
+
Style/RedundantFetchBlock:
|
151
|
+
Enabled: true
|
152
|
+
Style/RedundantRegexpCharacterClass:
|
153
|
+
Enabled: true
|
154
|
+
Style/RedundantRegexpEscape:
|
155
|
+
Enabled: true
|
156
|
+
Style/SlicingWithRange:
|
157
|
+
Enabled: true
|
158
|
+
Style/AccessorGrouping:
|
159
|
+
Enabled: false
|
160
|
+
Style/ArrayCoercion:
|
161
|
+
Enabled: true
|
162
|
+
Style/BisectedAttrAccessor:
|
163
|
+
Enabled: true
|
164
|
+
Style/CaseLikeIf:
|
165
|
+
Enabled: true
|
166
|
+
Style/HashAsLastArrayItem:
|
167
|
+
Enabled: true
|
168
|
+
Style/HashLikeCase:
|
169
|
+
Enabled: true
|
170
|
+
Style/RedundantAssignment:
|
171
|
+
Enabled: true
|
172
|
+
Style/RedundantFileExtensionInRequire:
|
173
|
+
Enabled: true
|
174
|
+
Style/ExplicitBlockArgument:
|
175
|
+
Enabled: true
|
176
|
+
Style/GlobalStdStream:
|
177
|
+
Enabled: true
|
178
|
+
Style/OptionalBooleanParameter:
|
179
|
+
Enabled: true
|
180
|
+
Style/SingleArgumentDig:
|
181
|
+
Enabled: true
|
182
|
+
Style/StringConcatenation:
|
183
|
+
Enabled: true
|
120
184
|
|
121
185
|
# ============================== Lint ==============================
|
122
186
|
Lint/DuplicateMethods:
|
123
187
|
Enabled: false
|
124
188
|
Lint/AmbiguousOperator:
|
125
189
|
Enabled: false
|
190
|
+
Lint/DeprecatedOpenSSLConstant:
|
191
|
+
Enabled: true
|
192
|
+
Lint/MixedRegexpCaptureTypes:
|
193
|
+
Enabled: true
|
194
|
+
Lint/RaiseException:
|
195
|
+
Enabled: true
|
196
|
+
Lint/StructNewOverride:
|
197
|
+
Enabled: true
|
198
|
+
Lint/DuplicateElsifCondition:
|
199
|
+
Enabled: true
|
200
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
201
|
+
Enabled: true
|
202
|
+
Lint/DuplicateRescueException:
|
203
|
+
Enabled: true
|
204
|
+
Lint/EmptyConditionalBody:
|
205
|
+
Enabled: true
|
206
|
+
Lint/FloatComparison:
|
207
|
+
Enabled: true
|
208
|
+
Lint/MissingSuper:
|
209
|
+
Enabled: false
|
210
|
+
Lint/OutOfRangeRegexpRef:
|
211
|
+
Enabled: true
|
212
|
+
Lint/SelfAssignment:
|
213
|
+
Enabled: true
|
214
|
+
Lint/TopLevelReturnWithArgument:
|
215
|
+
Enabled: true
|
216
|
+
Lint/UnreachableLoop:
|
217
|
+
Enabled: true
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,67 +1,72 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
click_house (1.
|
4
|
+
click_house (1.3.0)
|
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 (0.
|
11
|
+
ast (2.4.1)
|
12
|
+
coderay (1.1.3)
|
13
|
+
diff-lcs (1.4.4)
|
14
|
+
faraday (1.0.1)
|
15
15
|
multipart-post (>= 1.2, < 3)
|
16
|
-
faraday_middleware (0.
|
17
|
-
faraday (
|
18
|
-
|
19
|
-
method_source (0.9.2)
|
16
|
+
faraday_middleware (1.0.0)
|
17
|
+
faraday (~> 1.0)
|
18
|
+
method_source (1.0.0)
|
20
19
|
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 (~>
|
20
|
+
parallel (1.19.2)
|
21
|
+
parser (2.7.1.4)
|
22
|
+
ast (~> 2.4.1)
|
23
|
+
pry (0.13.1)
|
24
|
+
coderay (~> 1.1)
|
25
|
+
method_source (~> 1.0)
|
27
26
|
rainbow (3.0.0)
|
28
|
-
rake (13.0.
|
27
|
+
rake (13.0.1)
|
28
|
+
regexp_parser (1.7.1)
|
29
|
+
rexml (3.2.4)
|
29
30
|
rspec (3.9.0)
|
30
31
|
rspec-core (~> 3.9.0)
|
31
32
|
rspec-expectations (~> 3.9.0)
|
32
33
|
rspec-mocks (~> 3.9.0)
|
33
|
-
rspec-core (3.9.
|
34
|
-
rspec-support (~> 3.9.
|
35
|
-
rspec-expectations (3.9.
|
34
|
+
rspec-core (3.9.2)
|
35
|
+
rspec-support (~> 3.9.3)
|
36
|
+
rspec-expectations (3.9.2)
|
36
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
38
|
rspec-support (~> 3.9.0)
|
38
|
-
rspec-mocks (3.9.
|
39
|
+
rspec-mocks (3.9.1)
|
39
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
41
|
rspec-support (~> 3.9.0)
|
41
|
-
rspec-support (3.9.
|
42
|
-
rubocop (0.
|
43
|
-
jaro_winkler (~> 1.5.1)
|
42
|
+
rspec-support (3.9.3)
|
43
|
+
rubocop (0.89.1)
|
44
44
|
parallel (~> 1.10)
|
45
|
-
parser (>= 2.
|
45
|
+
parser (>= 2.7.1.1)
|
46
46
|
rainbow (>= 2.2.2, < 4.0)
|
47
|
+
regexp_parser (>= 1.7)
|
48
|
+
rexml
|
49
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
47
50
|
ruby-progressbar (~> 1.7)
|
48
|
-
unicode-display_width (>= 1.4.0, <
|
49
|
-
rubocop-
|
50
|
-
|
51
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
52
|
+
rubocop-ast (0.3.0)
|
53
|
+
parser (>= 2.7.1.4)
|
54
|
+
rubocop-performance (1.7.1)
|
55
|
+
rubocop (>= 0.82.0)
|
51
56
|
ruby-progressbar (1.10.1)
|
52
|
-
unicode-display_width (1.
|
57
|
+
unicode-display_width (1.7.0)
|
53
58
|
|
54
59
|
PLATFORMS
|
55
60
|
ruby
|
56
61
|
|
57
62
|
DEPENDENCIES
|
58
|
-
bundler
|
63
|
+
bundler
|
59
64
|
click_house!
|
60
65
|
pry
|
61
|
-
rake
|
62
|
-
rspec
|
66
|
+
rake
|
67
|
+
rspec
|
63
68
|
rubocop
|
64
69
|
rubocop-performance
|
65
70
|
|
66
71
|
BUNDLED WITH
|
67
|
-
1.
|
72
|
+
2.1.4
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
[](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.2.20
|
11
11
|
gem install click_house
|
12
12
|
```
|
13
13
|
|
@@ -38,6 +38,9 @@ Yandex uses HTTP interface for working from Java and Perl, Python and Go as well
|
|
38
38
|
* [Type casting](#type-casting)
|
39
39
|
* [Using with a connection pool](#using-with-a-connection-pool)
|
40
40
|
* [Using with Rails](#using-with-rails)
|
41
|
+
* [Using with ActiveRecord](#using-with-activerecord)
|
42
|
+
* [Using with RSpec](#using-with-rspec)
|
43
|
+
* [Development](#development)
|
41
44
|
|
42
45
|
## Configuration
|
43
46
|
|
@@ -330,7 +333,15 @@ string_type = FixedStringType.new
|
|
330
333
|
|
331
334
|
ClickHouse.connection.insert('table', columns: %i[name time]) do |buffer|
|
332
335
|
buffer << [string_type.serialize('a' * 1000, 20), time.serialize(Time.current, 'Europe/Moscow')]
|
333
|
-
end
|
336
|
+
end
|
337
|
+
|
338
|
+
## alternatively
|
339
|
+
data = @records.map do |record|
|
340
|
+
{
|
341
|
+
id: record.id,
|
342
|
+
time: ClickHouse.types['DateTime(%s)'].serialize(Time.current)
|
343
|
+
}
|
344
|
+
end
|
334
345
|
```
|
335
346
|
|
336
347
|
If native type supports arguments, define type with `%s` argument:
|
@@ -345,6 +356,15 @@ end
|
|
345
356
|
ClickHouse.add_type('DateTime(%s)', DateTimeType.new)
|
346
357
|
```
|
347
358
|
|
359
|
+
if you need to redefine all built-in types with your implementation,
|
360
|
+
just clear the default type system:
|
361
|
+
|
362
|
+
```ruby
|
363
|
+
ClickHouse.types.clear
|
364
|
+
ClickHouse.types # => {}
|
365
|
+
ClickHouse.types.default #=> #<ClickHouse::Type::UndefinedType:0x00007fc1cfabd630>
|
366
|
+
```
|
367
|
+
|
348
368
|
## Using with a connection pool
|
349
369
|
|
350
370
|
```ruby
|
@@ -429,8 +449,8 @@ class CreateAdvertVisits < ActiveRecord::Migration[6.0]
|
|
429
449
|
t.UInt16 :user_id
|
430
450
|
t.Date :date
|
431
451
|
t.DateTime :time, 'UTC'
|
432
|
-
t.
|
433
|
-
t.
|
452
|
+
t.IPv4 :ipv4
|
453
|
+
t.IPv6 :ipv6
|
434
454
|
t.UInt32 :device_type_id
|
435
455
|
t.UInt32 :os_family_id
|
436
456
|
end
|
@@ -442,18 +462,57 @@ class CreateAdvertVisits < ActiveRecord::Migration[6.0]
|
|
442
462
|
end
|
443
463
|
```
|
444
464
|
|
465
|
+
## Using with ActiveRecord
|
466
|
+
|
445
467
|
if you use `ActiveRecord`, you can use the ORM query builder by using fake models
|
468
|
+
(empty tables must be present in the SQL database `create_table :visits`)
|
469
|
+
|
470
|
+
```ruby
|
471
|
+
class ClickHouseRecord < ActiveRecord::Base
|
472
|
+
self.abstract_class = true
|
473
|
+
|
474
|
+
class << self
|
475
|
+
def agent
|
476
|
+
ClickHouse.connection
|
477
|
+
end
|
478
|
+
|
479
|
+
def insert(*argv, &block)
|
480
|
+
agent.insert(table_name, *argv, &block)
|
481
|
+
end
|
482
|
+
|
483
|
+
def select_one
|
484
|
+
agent.select_one(current_scope.to_sql)
|
485
|
+
end
|
486
|
+
|
487
|
+
def select_value
|
488
|
+
agent.select_value(current_scope.to_sql)
|
489
|
+
end
|
490
|
+
|
491
|
+
def select_all
|
492
|
+
agent.select_all(current_scope.to_sql)
|
493
|
+
end
|
494
|
+
end
|
495
|
+
end
|
496
|
+
````
|
446
497
|
|
447
498
|
````ruby
|
448
499
|
# FAKE MODEL FOR ClickHouse
|
449
|
-
class Visit <
|
500
|
+
class Visit < ClickHouseRecord
|
450
501
|
scope :with_os, -> { where.not(os_family_id: nil) }
|
451
502
|
end
|
452
503
|
|
453
|
-
|
454
|
-
|
504
|
+
Visit.with_os.select('COUNT(*) as counter').group(:ipv4).select_all
|
505
|
+
#=> [{ 'ipv4' => 1455869, 'counter' => 104 }]
|
506
|
+
|
507
|
+
Visit.with_os.select('COUNT(*)').select_value
|
508
|
+
#=> 20_345_678
|
509
|
+
|
510
|
+
Visit.where(user_id: 1).select_one
|
511
|
+
#=> { 'ipv4' => 1455869, 'user_id' => 1 }
|
455
512
|
````
|
456
513
|
|
514
|
+
## Using with RSpec
|
515
|
+
|
457
516
|
You can clear the data table before each test with RSpec
|
458
517
|
|
459
518
|
```ruby
|
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
|
@@ -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
|
@@ -3,6 +3,18 @@
|
|
3
3
|
module ClickHouse
|
4
4
|
module Extend
|
5
5
|
module ConnectionInserting
|
6
|
+
EMPTY_INSERT = true
|
7
|
+
|
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 }])
|
6
18
|
def insert(table, columns: [], values: [])
|
7
19
|
yield(values) if block_given?
|
8
20
|
|
@@ -12,6 +24,8 @@ module ClickHouse
|
|
12
24
|
values.map { |value_row| columns.zip(value_row).to_h.to_json }
|
13
25
|
end
|
14
26
|
|
27
|
+
return EMPTY_INSERT if values.empty?
|
28
|
+
|
15
29
|
execute("INSERT INTO #{table} FORMAT JSONEachRow", body.join("\n")).success?
|
16
30
|
end
|
17
31
|
end
|
@@ -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.
|
4
|
+
version: 1.3.0
|
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-09-23 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: []
|