click_house 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e21fcc0831f8f6612fac22c8e64eebb78b6e6f5d5d371c6db57dbfc0556610fd
4
- data.tar.gz: 792ac875a51e3f545b9b49b55618a4161183056b82cad7e213d05ef46974d69c
3
+ metadata.gz: '09e50ef7cb07967ea5914134a09e8d58a10db772e6a1394d71d913a86303132f'
4
+ data.tar.gz: 0b2682492f1c6bf22be9f430111a700860bd69a140372761d60040c9a9e159f4
5
5
  SHA512:
6
- metadata.gz: bca7f416a90d0d92046c8ac171511110fe2c02329e67260279b36a475bf2b59a0c65051c3f25f1f12f5ceb26bdabc659a94a75fea499fa0de65a9d3473d85156
7
- data.tar.gz: 5eee878068a827c4875a65a4435b44c87adc2fbe83b824bbb143e9086dc6ae2aad5fe4a07d43efc3fcb5bf8c2cc56003d7ca56d7fc9a4cf17db717bff90caa41
6
+ metadata.gz: e69ef08b15d94c9318e2c936d3be7b0a0a3ffc106ab10153d55bdd7267272a64672179be9ecfa630e96f1f3e23208df7fa639bfbeeb190019365cb4f677ce6d4
7
+ data.tar.gz: 12e5c562f99d4bbde45b10d78539a2c008f26a0373240273d644be83ee8772b6ad7031417b3cea9df1a286d69b23c33ee1594e8f0eb3f7ba282780d5cb183962
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- click_house (1.0.0)
4
+ click_house (1.1.0)
5
5
  faraday
6
6
  faraday_middleware
7
7
 
data/README.md CHANGED
@@ -281,8 +281,10 @@ SQL
281
281
  ## Alter table
282
282
  ### Alter table with DSL
283
283
  ```ruby
284
- ClickHouse.connection.add_column('table', 'column_name', :UInt64, default: nil, after: nil, cluster: nil)
284
+ ClickHouse.connection.add_column('table', 'column_name', :UInt64, default: nil, if_not_exists: nil, after: nil, cluster: nil)
285
285
  ClickHouse.connection.drop_column('table', 'column_name', if_exists: nil, cluster: nil)
286
+ ClickHouse.connection.clear_column('table', 'column_name', partition: 'partition_name', if_exists: nil, cluster: nil)
287
+ ClickHouse.connection.modify_column('table', 'column_name', type: :UInt64, default: nil, if_exists: false, cluster: nil)
286
288
  ```
287
289
 
288
290
  ### Alter table with SQL
@@ -10,7 +10,7 @@ module ClickHouse
10
10
  pattern = {
11
11
  name: name,
12
12
  exists: Util::Statement.ensure(if_not_exists, 'IF NOT EXISTS'),
13
- type: Util::Statement.ensure(type, type),
13
+ type: type,
14
14
  default: Util::Statement.ensure(default, "DEFAULT #{default}"),
15
15
  after: Util::Statement.ensure(after, "AFTER #{after}")
16
16
  }
@@ -29,6 +29,31 @@ module ClickHouse
29
29
  alter_table(table, format(sql, pattern), cluster: cluster)
30
30
  end
31
31
 
32
+ def clear_column(table, name, partition:, if_exists: false, cluster: nil)
33
+ sql = 'CLEAR COLUMN %<exists>s %<name>s %<partition>s'
34
+
35
+ pattern = {
36
+ name: name,
37
+ exists: Util::Statement.ensure(if_exists, 'IF EXISTS'),
38
+ partition: "IN PARTITION #{partition}"
39
+ }
40
+
41
+ alter_table(table, format(sql, pattern), cluster: cluster)
42
+ end
43
+
44
+ def modify_column(table, name, type: nil, default: nil, if_exists: false, cluster: nil)
45
+ sql = 'MODIFY COLUMN %<exists>s %<name>s %<type>s %<default>s'
46
+
47
+ pattern = {
48
+ name: name,
49
+ type: type,
50
+ exists: Util::Statement.ensure(if_exists, 'IF EXISTS'),
51
+ default: Util::Statement.ensure(default, "DEFAULT #{default}")
52
+ }
53
+
54
+ alter_table(table, format(sql, pattern), cluster: cluster)
55
+ end
56
+
32
57
  def alter_table(name, sql = nil, cluster: nil)
33
58
  template = 'ALTER TABLE %<name>s %<cluster>s %<sql>s'
34
59
  sql = yield(sql) if sql.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClickHouse
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: click_house
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aliaksandr Shylau