click_house 1.3.1 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +68 -0
- data/.rubocop.yml +75 -3
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +27 -24
- data/README.md +13 -3
- data/docker-compose.yml +1 -1
- data/lib/click_house.rb +2 -10
- data/lib/click_house/config.rb +1 -5
- data/lib/click_house/connection.rb +1 -0
- data/lib/click_house/definition/column_set.rb +1 -11
- data/lib/click_house/extend.rb +1 -0
- data/lib/click_house/extend/connection_explaining.rb +15 -0
- data/lib/click_house/extend/type_definition.rb +10 -1
- data/lib/click_house/middleware/logging.rb +1 -1
- data/lib/click_house/middleware/parse_csv.rb +1 -1
- data/lib/click_house/response/result_set.rb +2 -1
- data/lib/click_house/util/statement.rb +2 -1
- data/lib/click_house/version.rb +1 -1
- metadata +4 -3
- data/.travis.yml +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c142ebfe52364b3762dbd35faf1e2d9bff6b84debda46e87334ce63a7bfeee42
|
4
|
+
data.tar.gz: b54a1894aeac9b28abcadb5a92c2430e897f39fe6434be1eed7c7521b3145976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37847807690dc35d21089b5bdda28ca6090411d84456df59704af3a4f924b87d04bb863dec4505c5c832f18a69d44440705ba57b18894706c2ef8cc6ac1b758a
|
7
|
+
data.tar.gz: 1f5a6ab57d06afee3c20beeb7b91335ba380efc7266cba548d4c9fa1d62bd0ff85a1a57fb9ee760d5bd24b988fe46512b66e8520f1f9d5e3972930f1ff377a67
|
@@ -0,0 +1,68 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
rspec:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
services:
|
10
|
+
clickhouse:
|
11
|
+
image: yandex/clickhouse-server:20.12.3.3
|
12
|
+
ports:
|
13
|
+
- 8123:8123
|
14
|
+
|
15
|
+
strategy:
|
16
|
+
matrix:
|
17
|
+
ruby-version: [2.7, 2.6, 2.5]
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2
|
21
|
+
|
22
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.ruby-version }}
|
26
|
+
|
27
|
+
- name: Cache gems
|
28
|
+
uses: actions/cache@v1
|
29
|
+
with:
|
30
|
+
path: vendor/bundle
|
31
|
+
key: ${{ runner.os }}-${{ matrix.ruby-version }}-bundler-${{ hashFiles('**/Gemfile.lock') }}
|
32
|
+
restore-keys: |
|
33
|
+
${{ runner.os }}-${{ matrix.ruby-version }}-bundler-
|
34
|
+
|
35
|
+
- name: Install gems
|
36
|
+
run: |
|
37
|
+
bundle config path vendor/bundle
|
38
|
+
bundle install --jobs 4 --retry 3
|
39
|
+
|
40
|
+
- name: Run tests
|
41
|
+
run: bundle exec rspec
|
42
|
+
|
43
|
+
rubocop:
|
44
|
+
runs-on: ubuntu-latest
|
45
|
+
|
46
|
+
steps:
|
47
|
+
- uses: actions/checkout@v2
|
48
|
+
|
49
|
+
- name: Set up Ruby 2.7
|
50
|
+
uses: ruby/setup-ruby@v1
|
51
|
+
with:
|
52
|
+
ruby-version: 2.7
|
53
|
+
|
54
|
+
- name: Cache gems
|
55
|
+
uses: actions/cache@v1
|
56
|
+
with:
|
57
|
+
path: vendor/bundle
|
58
|
+
key: ${{ runner.os }}-bundler-${{ hashFiles('**/Gemfile.lock') }}
|
59
|
+
restore-keys: |
|
60
|
+
${{ runner.os }}-bundler-
|
61
|
+
|
62
|
+
- name: Install gems
|
63
|
+
run: |
|
64
|
+
bundle config path vendor/bundle
|
65
|
+
bundle install --jobs 4 --retry 3
|
66
|
+
|
67
|
+
- name: Run Rubocop
|
68
|
+
run: bundle exec rubocop
|
data/.rubocop.yml
CHANGED
@@ -3,13 +3,13 @@ require:
|
|
3
3
|
|
4
4
|
AllCops:
|
5
5
|
AutoCorrect: false
|
6
|
+
SuggestExtensions: false
|
6
7
|
Exclude:
|
7
8
|
- 'click_house.gemspec'
|
8
9
|
- 'bin/*'
|
9
10
|
- 'spec/**/*'
|
10
11
|
- 'vendor/**/*'
|
11
12
|
TargetRubyVersion: 2.7
|
12
|
-
|
13
13
|
Bundler/OrderedGems:
|
14
14
|
Enabled: false
|
15
15
|
|
@@ -34,6 +34,18 @@ Performance/Squeeze:
|
|
34
34
|
Enabled: true
|
35
35
|
Performance/StringInclude:
|
36
36
|
Enabled: true
|
37
|
+
Performance/Sum:
|
38
|
+
Enabled: true
|
39
|
+
Performance/ArraySemiInfiniteRangeSlice:
|
40
|
+
Enabled: true
|
41
|
+
Performance/BlockGivenWithExplicitBlock:
|
42
|
+
Enabled: true
|
43
|
+
Performance/CollectionLiteralInLoop:
|
44
|
+
Enabled: true
|
45
|
+
Performance/ConstantRegexp:
|
46
|
+
Enabled: true
|
47
|
+
Performance/MethodObjectAsBlock:
|
48
|
+
Enabled: false
|
37
49
|
|
38
50
|
# ============================== Metrics ============================
|
39
51
|
Metrics/ClassLength:
|
@@ -42,8 +54,6 @@ Metrics/BlockLength:
|
|
42
54
|
Enabled: true
|
43
55
|
Metrics/MethodLength:
|
44
56
|
Max: 25
|
45
|
-
Metrics/LineLength:
|
46
|
-
Max: 140
|
47
57
|
Metrics/AbcSize:
|
48
58
|
Max: 40
|
49
59
|
|
@@ -61,6 +71,8 @@ Naming/AccessorMethodName:
|
|
61
71
|
Enabled: false
|
62
72
|
|
63
73
|
# ============================== Layout =============================
|
74
|
+
Layout/LineLength:
|
75
|
+
Max: 140
|
64
76
|
Layout/HashAlignment:
|
65
77
|
EnforcedHashRocketStyle: key
|
66
78
|
EnforcedColonStyle: key
|
@@ -181,6 +193,30 @@ Style/SingleArgumentDig:
|
|
181
193
|
Enabled: true
|
182
194
|
Style/StringConcatenation:
|
183
195
|
Enabled: true
|
196
|
+
Style/ClassEqualityComparison:
|
197
|
+
Enabled: true
|
198
|
+
Style/CombinableLoops:
|
199
|
+
Enabled: true
|
200
|
+
Style/KeywordParametersOrder:
|
201
|
+
Enabled: false
|
202
|
+
Style/RedundantSelfAssignment:
|
203
|
+
Enabled: true
|
204
|
+
Style/SoleNestedConditional:
|
205
|
+
Enabled: true
|
206
|
+
Style/ArgumentsForwarding:
|
207
|
+
Enabled: true
|
208
|
+
Style/CollectionCompact:
|
209
|
+
Enabled: true
|
210
|
+
Style/DocumentDynamicEvalDefinition:
|
211
|
+
Enabled: false
|
212
|
+
Style/NegatedIfElseCondition:
|
213
|
+
Enabled: true
|
214
|
+
Style/NilLambda:
|
215
|
+
Enabled: true
|
216
|
+
Style/SwapValues:
|
217
|
+
Enabled: true
|
218
|
+
Style/RedundantArgument:
|
219
|
+
Enabled: true
|
184
220
|
|
185
221
|
# ============================== Lint ==============================
|
186
222
|
Lint/DuplicateMethods:
|
@@ -215,3 +251,39 @@ Lint/TopLevelReturnWithArgument:
|
|
215
251
|
Enabled: true
|
216
252
|
Lint/UnreachableLoop:
|
217
253
|
Enabled: true
|
254
|
+
Layout/BeginEndAlignment:
|
255
|
+
Enabled: true
|
256
|
+
Lint/ConstantDefinitionInBlock:
|
257
|
+
Enabled: true
|
258
|
+
Lint/DuplicateRequire:
|
259
|
+
Enabled: true
|
260
|
+
Lint/EmptyFile:
|
261
|
+
Enabled: true
|
262
|
+
Lint/HashCompareByIdentity:
|
263
|
+
Enabled: true
|
264
|
+
Lint/IdentityComparison:
|
265
|
+
Enabled: true
|
266
|
+
Lint/RedundantSafeNavigation:
|
267
|
+
Enabled: true
|
268
|
+
Lint/TrailingCommaInAttributeDeclaration:
|
269
|
+
Enabled: true
|
270
|
+
Lint/UselessMethodDefinition:
|
271
|
+
Enabled: true
|
272
|
+
Lint/UselessTimes:
|
273
|
+
Enabled: true
|
274
|
+
Lint/DuplicateBranch:
|
275
|
+
Enabled: true
|
276
|
+
Lint/DuplicateRegexpCharacterClassElement:
|
277
|
+
Enabled: true
|
278
|
+
Lint/EmptyBlock:
|
279
|
+
Enabled: true
|
280
|
+
Lint/EmptyClass:
|
281
|
+
Enabled: true
|
282
|
+
Lint/NoReturnInBeginEndBlocks:
|
283
|
+
Enabled: true
|
284
|
+
Lint/ToEnumArguments:
|
285
|
+
Enabled: true
|
286
|
+
Lint/UnmodifiedReduceAccumulator:
|
287
|
+
Enabled: true
|
288
|
+
Lint/UnexpectedBlockArity:
|
289
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# 1.3.6
|
2
|
+
* fix ruby 2.7 warning `maybe ** should be added to the call` on `ClickHouse.connection.databases`
|
3
|
+
|
4
|
+
# 1.3.5
|
5
|
+
* added `ClickHouse.connexction.explain("sql")`
|
6
|
+
|
7
|
+
# 1.3.4
|
8
|
+
* added `ClickHouse.type_names(nullable: false)`
|
9
|
+
* fixed `connection#create_table` column definitions
|
10
|
+
* `ClickHouse.add_type` now handles Nullable types automatically
|
11
|
+
|
12
|
+
# 1.3.3
|
13
|
+
* fix logger typo
|
14
|
+
|
15
|
+
# 1.3.2
|
16
|
+
* fix null logger for windows users
|
17
|
+
|
1
18
|
# 1.3.1
|
2
19
|
* added request [headers](https://github.com/shlima/click_house/pull/8) support
|
3
20
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
click_house (1.3.
|
4
|
+
click_house (1.3.6)
|
5
5
|
faraday
|
6
6
|
faraday_middleware
|
7
7
|
|
@@ -11,49 +11,52 @@ GEM
|
|
11
11
|
ast (2.4.1)
|
12
12
|
coderay (1.1.3)
|
13
13
|
diff-lcs (1.4.4)
|
14
|
-
faraday (1.0
|
14
|
+
faraday (1.1.0)
|
15
15
|
multipart-post (>= 1.2, < 3)
|
16
|
+
ruby2_keywords
|
16
17
|
faraday_middleware (1.0.0)
|
17
18
|
faraday (~> 1.0)
|
18
19
|
method_source (1.0.0)
|
19
20
|
multipart-post (2.1.1)
|
20
|
-
parallel (1.
|
21
|
-
parser (2.7.
|
21
|
+
parallel (1.20.1)
|
22
|
+
parser (2.7.2.0)
|
22
23
|
ast (~> 2.4.1)
|
23
24
|
pry (0.13.1)
|
24
25
|
coderay (~> 1.1)
|
25
26
|
method_source (~> 1.0)
|
26
27
|
rainbow (3.0.0)
|
27
28
|
rake (13.0.1)
|
28
|
-
regexp_parser (
|
29
|
+
regexp_parser (2.0.0)
|
29
30
|
rexml (3.2.4)
|
30
|
-
rspec (3.
|
31
|
-
rspec-core (~> 3.
|
32
|
-
rspec-expectations (~> 3.
|
33
|
-
rspec-mocks (~> 3.
|
34
|
-
rspec-core (3.
|
35
|
-
rspec-support (~> 3.
|
36
|
-
rspec-expectations (3.
|
31
|
+
rspec (3.10.0)
|
32
|
+
rspec-core (~> 3.10.0)
|
33
|
+
rspec-expectations (~> 3.10.0)
|
34
|
+
rspec-mocks (~> 3.10.0)
|
35
|
+
rspec-core (3.10.0)
|
36
|
+
rspec-support (~> 3.10.0)
|
37
|
+
rspec-expectations (3.10.0)
|
37
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-mocks (3.
|
39
|
+
rspec-support (~> 3.10.0)
|
40
|
+
rspec-mocks (3.10.0)
|
40
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.
|
42
|
-
rspec-support (3.
|
43
|
-
rubocop (
|
42
|
+
rspec-support (~> 3.10.0)
|
43
|
+
rspec-support (3.10.0)
|
44
|
+
rubocop (1.5.2)
|
44
45
|
parallel (~> 1.10)
|
45
|
-
parser (>= 2.7.1.
|
46
|
+
parser (>= 2.7.1.5)
|
46
47
|
rainbow (>= 2.2.2, < 4.0)
|
47
|
-
regexp_parser (>= 1.
|
48
|
+
regexp_parser (>= 1.8, < 3.0)
|
48
49
|
rexml
|
49
|
-
rubocop-ast (>=
|
50
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
50
51
|
ruby-progressbar (~> 1.7)
|
51
52
|
unicode-display_width (>= 1.4.0, < 2.0)
|
52
|
-
rubocop-ast (
|
53
|
-
parser (>= 2.7.1.
|
54
|
-
rubocop-performance (1.
|
55
|
-
rubocop (>= 0.
|
53
|
+
rubocop-ast (1.3.0)
|
54
|
+
parser (>= 2.7.1.5)
|
55
|
+
rubocop-performance (1.9.1)
|
56
|
+
rubocop (>= 0.90.0, < 2.0)
|
57
|
+
rubocop-ast (>= 0.4.0)
|
56
58
|
ruby-progressbar (1.10.1)
|
59
|
+
ruby2_keywords (0.0.2)
|
57
60
|
unicode-display_width (1.7.0)
|
58
61
|
|
59
62
|
PLATFORMS
|
data/README.md
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
# ClickHouse Ruby driver
|
4
4
|
|
5
|
-
|
5
|
+
![CI](https://github.com/shlima/click_house/workflows/CI/badge.svg)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/shlima/click_house/badges/gpa.svg)](https://codeclimate.com/github/shlima/click_house)
|
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
|
10
|
+
# Requires Ruby >= 2.5
|
11
11
|
gem install click_house
|
12
12
|
```
|
13
13
|
|
@@ -105,6 +105,11 @@ ClickHouse.connection.truncate_tables(['table_1', 'table_2'], if_exists: true, c
|
|
105
105
|
ClickHouse.connection.truncate_tables # will truncate all tables in database
|
106
106
|
ClickHouse.connection.rename_table('old_name', 'new_name', cluster: nil)
|
107
107
|
ClickHouse.connection.rename_table(%w[table_1 table_2], %w[new_1 new_2], cluster: nil)
|
108
|
+
|
109
|
+
ClickHouse.connection.select_all('SELECT * FROM visits')
|
110
|
+
ClickHouse.connection.select_one('SELECT * FROM visits LIMIT 1')
|
111
|
+
ClickHouse.connection.select_value('SELECT ip FROM visits LIMIT 1')
|
112
|
+
ClickHouse.connection.explain('SELECT * FROM visits CROSS JOIN visits')
|
108
113
|
```
|
109
114
|
|
110
115
|
## Queries
|
@@ -346,7 +351,8 @@ data = @records.map do |record|
|
|
346
351
|
end
|
347
352
|
```
|
348
353
|
|
349
|
-
If native type supports arguments, define type with `%s`
|
354
|
+
If native type supports arguments, define *String* type with `%s`
|
355
|
+
argument and *Numeric* type with `%d` argument:
|
350
356
|
|
351
357
|
```ruby
|
352
358
|
class DateTimeType
|
@@ -398,6 +404,10 @@ development:
|
|
398
404
|
test:
|
399
405
|
database: ecliptic_test
|
400
406
|
<<: *default
|
407
|
+
|
408
|
+
production:
|
409
|
+
<<: *default
|
410
|
+
database: ecliptic_production
|
401
411
|
```
|
402
412
|
|
403
413
|
```ruby
|
data/docker-compose.yml
CHANGED
data/lib/click_house.rb
CHANGED
@@ -28,41 +28,33 @@ module ClickHouse
|
|
28
28
|
|
29
29
|
%w[Date].each do |column|
|
30
30
|
add_type column, Type::DateType.new
|
31
|
-
add_type "Nullable(#{column})", Type::NullableType.new(Type::DateType.new)
|
32
31
|
end
|
33
32
|
|
34
|
-
%w[String].each do |column|
|
33
|
+
%w[String FixedString(%d) UUID].each do |column|
|
35
34
|
add_type column, Type::StringType.new
|
36
|
-
add_type "Nullable(#{column})", Type::NullableType.new(Type::StringType.new)
|
37
35
|
end
|
38
36
|
|
39
37
|
['DateTime(%s)'].each do |column|
|
40
38
|
add_type column, Type::DateTimeType.new
|
41
|
-
add_type "Nullable(#{column})", Type::NullableType.new(Type::DateTimeType.new)
|
42
39
|
end
|
43
40
|
|
44
41
|
['DateTime64(%d, %s)'].each do |column|
|
45
42
|
add_type column, Type::DateTime64Type.new
|
46
|
-
add_type "Nullable(#{column})", Type::NullableType.new(Type::DateTime64Type.new)
|
47
43
|
end
|
48
44
|
|
49
|
-
['Decimal(%
|
45
|
+
['Decimal(%d, %d)', 'Decimal32(%d)', 'Decimal64(%d)', 'Decimal128(%d)'].each do |column|
|
50
46
|
add_type column, Type::DecimalType.new
|
51
|
-
add_type "Nullable(#{column})", Type::NullableType.new(Type::DecimalType.new)
|
52
47
|
end
|
53
48
|
|
54
49
|
%w[UInt8 UInt16 UInt32 UInt64 Int8 Int16 Int32 Int64].each do |column|
|
55
50
|
add_type column, Type::IntegerType.new
|
56
|
-
add_type "Nullable(#{column})", Type::NullableType.new(Type::IntegerType.new)
|
57
51
|
end
|
58
52
|
|
59
53
|
%w[Float32 Float64].each do |column|
|
60
54
|
add_type column, Type::FloatType.new
|
61
|
-
add_type "Nullable(#{column})", Type::NullableType.new(Type::IntegerType.new)
|
62
55
|
end
|
63
56
|
|
64
57
|
%w[IPv4 IPv6].each do |column|
|
65
58
|
add_type column, Type::IPType.new
|
66
|
-
add_type "Nullable(#{column})", Type::NullableType.new(Type::IPType.new)
|
67
59
|
end
|
68
60
|
end
|
data/lib/click_house/config.rb
CHANGED
@@ -2,10 +2,6 @@
|
|
2
2
|
|
3
3
|
module ClickHouse
|
4
4
|
class Config
|
5
|
-
DEFAULT_SCHEME = 'http'
|
6
|
-
DEFAULT_HOST = 'localhost'
|
7
|
-
DEFAULT_PORT = '8123'
|
8
|
-
|
9
5
|
DEFAULTS = {
|
10
6
|
adapter: Faraday.default_adapter,
|
11
7
|
url: nil,
|
@@ -53,7 +49,7 @@ module ClickHouse
|
|
53
49
|
end
|
54
50
|
|
55
51
|
def logger!
|
56
|
-
@logger || Logger.new(
|
52
|
+
@logger || Logger.new(IO::NULL)
|
57
53
|
end
|
58
54
|
|
59
55
|
def url!
|
@@ -3,17 +3,7 @@
|
|
3
3
|
module ClickHouse
|
4
4
|
module Definition
|
5
5
|
class ColumnSet
|
6
|
-
TYPES =
|
7
|
-
'UInt8', 'UInt16', 'UInt32', 'UInt64', 'Int8', 'Int16', 'Int32', 'Int64',
|
8
|
-
'Float32', 'Float64',
|
9
|
-
'Decimal(%d, %d)', 'Decimal32(%d)', 'Decimal64(%d)', 'Decimal128(%d)',
|
10
|
-
'String',
|
11
|
-
'FixedString(%d)',
|
12
|
-
'UUID',
|
13
|
-
'Date',
|
14
|
-
'IPv4', 'IPv6',
|
15
|
-
"DateTime('%s')", "DateTime64(%d, '%s')"
|
16
|
-
].freeze
|
6
|
+
TYPES = ClickHouse.type_names(nullable: false).map { |s| s.sub('%s', "'%s'") }.freeze
|
17
7
|
|
18
8
|
class << self
|
19
9
|
# @input "DateTime('%s')"
|
data/lib/click_house/extend.rb
CHANGED
@@ -11,5 +11,6 @@ module ClickHouse
|
|
11
11
|
autoload :ConnectionSelective, 'click_house/extend/connection_selective'
|
12
12
|
autoload :ConnectionInserting, 'click_house/extend/connection_inserting'
|
13
13
|
autoload :ConnectionAltering, 'click_house/extend/connection_altering'
|
14
|
+
autoload :ConnectionExplaining, 'click_house/extend/connection_explaining'
|
14
15
|
end
|
15
16
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ClickHouse
|
4
|
+
module Extend
|
5
|
+
module ConnectionExplaining
|
6
|
+
EXPLAIN = 'EXPLAIN'
|
7
|
+
EXPLAIN_RE = /\A(\s*#{EXPLAIN})/io.freeze
|
8
|
+
|
9
|
+
def explain(sql, io: $stdout)
|
10
|
+
res = execute("#{EXPLAIN} #{sql.gsub(EXPLAIN_RE, '')}")
|
11
|
+
io << res.body
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -3,12 +3,21 @@
|
|
3
3
|
module ClickHouse
|
4
4
|
module Extend
|
5
5
|
module TypeDefinition
|
6
|
+
NULLABLE = 'Nullable'
|
7
|
+
NULLABLE_RE = /#{NULLABLE}/i.freeze
|
8
|
+
|
6
9
|
def types
|
7
10
|
@types ||= Hash.new(Type::UndefinedType.new)
|
8
11
|
end
|
9
12
|
|
10
|
-
def add_type(type, klass)
|
13
|
+
def add_type(type, klass, nullable: true)
|
11
14
|
types[type] = klass
|
15
|
+
types["#{NULLABLE}(#{type})"] = Type::NullableType.new(klass) if nullable
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Enum<String>]
|
19
|
+
def type_names(nullable:)
|
20
|
+
nullable ? types.keys : types.keys.grep_v(NULLABLE_RE)
|
12
21
|
end
|
13
22
|
end
|
14
23
|
end
|
@@ -34,7 +34,7 @@ module ClickHouse
|
|
34
34
|
|
35
35
|
logger.info("\e[1m[35mSQL (#{Util::Pretty.measure(elapsed)})\e[0m #{query};")
|
36
36
|
logger.debug(body) if body
|
37
|
-
logger.info("\e[1m[36mRead: #{summary.fetch(:read_rows)} rows, #{summary.fetch(:read_bytes)}. Written: #{summary.fetch(:written_rows)}
|
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
39
|
# rubocop:enable Layout/LineLength
|
40
40
|
|
@@ -8,6 +8,7 @@ module ClickHouse
|
|
8
8
|
|
9
9
|
TYPE_ARGV_DELIM = ','
|
10
10
|
NULLABLE = 'Nullable'
|
11
|
+
NULLABLE_TYPE_RE = /#{NULLABLE}\((.+)\)/i.freeze
|
11
12
|
|
12
13
|
def_delegators :to_a,
|
13
14
|
:each, :fetch, :length, :count, :size, :first, :last, :[], :to_h
|
@@ -28,7 +29,7 @@ module ClickHouse
|
|
28
29
|
# @input "Decimal(10, 5)"
|
29
30
|
# @output "Decimal(%s, %s)"
|
30
31
|
def extract_type_info(type)
|
31
|
-
type = type.gsub(
|
32
|
+
type = type.gsub(NULLABLE_TYPE_RE, '\1')
|
32
33
|
nullable = Regexp.last_match(1)
|
33
34
|
argv = []
|
34
35
|
|
@@ -4,6 +4,7 @@ module ClickHouse
|
|
4
4
|
module Util
|
5
5
|
module Statement
|
6
6
|
END_OF_STATEMENT = ';'
|
7
|
+
END_OF_STATEMENT_RE = /#{END_OF_STATEMENT}(\s+|\Z)/.freeze
|
7
8
|
|
8
9
|
module_function
|
9
10
|
|
@@ -14,7 +15,7 @@ module ClickHouse
|
|
14
15
|
def format(sql, format)
|
15
16
|
return sql if sql.match?(/FORMAT/i)
|
16
17
|
|
17
|
-
"#{sql.sub(
|
18
|
+
"#{sql.sub(END_OF_STATEMENT_RE, '')} FORMAT #{format};"
|
18
19
|
end
|
19
20
|
end
|
20
21
|
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.3.
|
4
|
+
version: 1.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aliaksandr Shylau
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10
|
11
|
+
date: 2020-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -129,10 +129,10 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".github/workflows/main.yml"
|
132
133
|
- ".gitignore"
|
133
134
|
- ".rspec"
|
134
135
|
- ".rubocop.yml"
|
135
|
-
- ".travis.yml"
|
136
136
|
- CHANGELOG.md
|
137
137
|
- Gemfile
|
138
138
|
- Gemfile.lock
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/click_house/extend/connectible.rb
|
159
159
|
- lib/click_house/extend/connection_altering.rb
|
160
160
|
- lib/click_house/extend/connection_database.rb
|
161
|
+
- lib/click_house/extend/connection_explaining.rb
|
161
162
|
- lib/click_house/extend/connection_healthy.rb
|
162
163
|
- lib/click_house/extend/connection_inserting.rb
|
163
164
|
- lib/click_house/extend/connection_selective.rb
|
data/.travis.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
rvm:
|
4
|
-
- 2.6.5
|
5
|
-
|
6
|
-
services:
|
7
|
-
- docker
|
8
|
-
|
9
|
-
before_install:
|
10
|
-
- docker pull yandex/clickhouse-server
|
11
|
-
- docker run -d -p 127.0.0.1:8123:8123 yandex/clickhouse-server
|
12
|
-
- bundle install
|
13
|
-
|
14
|
-
script:
|
15
|
-
- bundle exec rubocop
|
16
|
-
- bundle exec rspec
|