click_house 1.3.3 → 1.3.4

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: 2862b65661584d94d5a12bf10f0f308081e05a8a0cccbb6d79f42d93756bf086
4
- data.tar.gz: 4790a4d30017a52878f959e8675979d18d53bed6f9ae0e009679939aca2058a9
3
+ metadata.gz: 55de5fd75c50aca5227537365eca6c1042bdff12833c8803f66b1022b6bbefd4
4
+ data.tar.gz: 101d57eeb3a903a9b95a9955a0ac093c80796ef5fc6163837d49fc7fc64464b2
5
5
  SHA512:
6
- metadata.gz: 6e80ec8a830930a620616c60a57b2b55117da9dc63e6fca248734d5511005fe1e794b3baf82ccaea96ec43e1112164909645cc836554b9a59d0ab4cbcf4fe60a
7
- data.tar.gz: 5ed0f070acb487f96fec663efd05576eb0a4d540a2efbbcf36d90c96b1be9dae9de2c1b73c32f27ee255064839726714ac6cc3d2a47563155651155fca8e87fb
6
+ metadata.gz: 860b3f17e95893e7cdd0d43c37ca42557492b7e44b8e0c61d326a8d83c9211a942775131d5a4705d53b6cdab3dc8acd716b5c2d629e7f95f9f95c74b9310398f
7
+ data.tar.gz: dc0fd575a9b1c22ae571fda8edb639a8d16df3ddb6497b97b63b3886933b8904e9d94a97f0f8b17619b4c4dca987282265a3002833c3318775e74d201c6f23fa
@@ -1,3 +1,7 @@
1
+ # 1.3.4
2
+ * added `ClickHouse.type_names(nullable: false)`
3
+ * fixed `connection#create_table` column definitions
4
+
1
5
  # 1.3.3
2
6
  * fix logger typo
3
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- click_house (1.3.3)
4
+ click_house (1.3.4)
5
5
  faraday
6
6
  faraday_middleware
7
7
 
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 20.9.3.45
10
+ # Requires Ruby >= 2.5
11
11
  gem install click_house
12
12
  ```
13
13
 
@@ -346,7 +346,8 @@ data = @records.map do |record|
346
346
  end
347
347
  ```
348
348
 
349
- If native type supports arguments, define type with `%s` argument:
349
+ If native type supports arguments, define *String* type with `%s`
350
+ argument and *Numeric* type with `%d` argument:
350
351
 
351
352
  ```ruby
352
353
  class DateTimeType
@@ -2,7 +2,7 @@ version: '3.5'
2
2
 
3
3
  services:
4
4
  clickhouse:
5
- image: yandex/clickhouse-server:20.9.3.45
5
+ image: yandex/clickhouse-server:20.10.3.30
6
6
  ports:
7
7
  - "8123:8123"
8
8
  - "9000:9000"
@@ -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(%s, %s)', 'Decimal32(%s)', 'Decimal64(%s)', 'Decimal128(%s)'].each do |column|
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
@@ -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')"
@@ -3,12 +3,20 @@
3
3
  module ClickHouse
4
4
  module Extend
5
5
  module TypeDefinition
6
+ NULLABLE = 'Nullable'
7
+
6
8
  def types
7
9
  @types ||= Hash.new(Type::UndefinedType.new)
8
10
  end
9
11
 
10
- def add_type(type, klass)
12
+ def add_type(type, klass, nullable: true)
11
13
  types[type] = klass
14
+ types["#{NULLABLE}(#{type})"] = Type::NullableType.new(klass) if nullable
15
+ end
16
+
17
+ # @return [Enum<String>]
18
+ def type_names(nullable:)
19
+ nullable ? types.keys : types.keys.grep_v(/#{NULLABLE}/i)
12
20
  end
13
21
  end
14
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClickHouse
4
- VERSION = '1.3.3'
4
+ VERSION = '1.3.4'
5
5
  end
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.3
4
+ version: 1.3.4
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-19 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday