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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/click_house/extend/connection_altering.rb +26 -1
- data/lib/click_house/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09e50ef7cb07967ea5914134a09e8d58a10db772e6a1394d71d913a86303132f'
|
4
|
+
data.tar.gz: 0b2682492f1c6bf22be9f430111a700860bd69a140372761d60040c9a9e159f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e69ef08b15d94c9318e2c936d3be7b0a0a3ffc106ab10153d55bdd7267272a64672179be9ecfa630e96f1f3e23208df7fa639bfbeeb190019365cb4f677ce6d4
|
7
|
+
data.tar.gz: 12e5c562f99d4bbde45b10d78539a2c008f26a0373240273d644be83ee8772b6ad7031417b3cea9df1a286d69b23c33ee1594e8f0eb3f7ba282780d5cb183962
|
data/Gemfile.lock
CHANGED
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:
|
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?
|
data/lib/click_house/version.rb
CHANGED