click_house 1.3.8 → 1.3.9
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/CHANGELOG.md +4 -1
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/lib/click_house/extend/connection_altering.rb +27 -0
- 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: a840e675477999a80f7ceee3f2364df83fc0efcc4ee4d0e16212dba1bb495acf
|
4
|
+
data.tar.gz: 1d8ad01d6dc2e1720c0d499f2f7168cdf83018151bc24dbbe1f8a8244da1d5ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76172279bdf916f3b1ff68e55ad576a3e05a5651e47e22547a20b8d87159b7920edc72c5bb8b449833d50409c30738dc4374259df7096af53a99141e8d67c9d5
|
7
|
+
data.tar.gz: 5542180b24e7d7e7b747cfd09eca9a999371b26b0013d783ef1fa888623eb6854803e38286aa3f0fb3893b158ffed6977ea92aa089c91f25523f0882a99b514e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# 1.3.9
|
2
|
+
* add `ClickHouse.connection.add_index`, `ClickHouse.connection.drop_index`
|
3
|
+
|
1
4
|
# 1.3.8
|
2
5
|
* fix `DateTime` casting for queries like `ClickHouse.connection.select_value('select NOW()')`
|
3
6
|
* fix resulting set console inspection
|
@@ -9,7 +12,7 @@
|
|
9
12
|
* fix ruby 2.7 warning `maybe ** should be added to the call` on `ClickHouse.connection.databases`
|
10
13
|
|
11
14
|
# 1.3.5
|
12
|
-
* added `ClickHouse.
|
15
|
+
* added `ClickHouse.connection.explain("sql")`
|
13
16
|
|
14
17
|
# 1.3.4
|
15
18
|
* added `ClickHouse.type_names(nullable: false)`
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -104,6 +104,8 @@ ClickHouse.connection.truncate_tables(['table_1', 'table_2'], if_exists: true, c
|
|
104
104
|
ClickHouse.connection.truncate_tables # will truncate all tables in database
|
105
105
|
ClickHouse.connection.rename_table('old_name', 'new_name', cluster: nil)
|
106
106
|
ClickHouse.connection.rename_table(%w[table_1 table_2], %w[new_1 new_2], cluster: nil)
|
107
|
+
ClickHouse.connection.add_index('table', 'ix', 'has(b, a)', type: 'minmax', granularity: 2, cluster: nil)
|
108
|
+
ClickHouse.connection.drop_index('table', 'ix', cluster: nil)
|
107
109
|
|
108
110
|
ClickHouse.connection.select_all('SELECT * FROM visits')
|
109
111
|
ClickHouse.connection.select_one('SELECT * FROM visits LIMIT 1')
|
@@ -497,6 +499,10 @@ class ClickHouseRecord < ActiveRecord::Base
|
|
497
499
|
def select_all
|
498
500
|
agent.select_all(current_scope.to_sql)
|
499
501
|
end
|
502
|
+
|
503
|
+
def explain
|
504
|
+
agent.explain(current_scope.to_sql)
|
505
|
+
end
|
500
506
|
end
|
501
507
|
end
|
502
508
|
````
|
@@ -66,6 +66,33 @@ module ClickHouse
|
|
66
66
|
|
67
67
|
execute(format(template, pattern)).success?
|
68
68
|
end
|
69
|
+
|
70
|
+
def add_index(
|
71
|
+
table_name,
|
72
|
+
name,
|
73
|
+
expression,
|
74
|
+
type:,
|
75
|
+
granularity: nil,
|
76
|
+
after: nil,
|
77
|
+
cluster: nil
|
78
|
+
)
|
79
|
+
template = 'ADD INDEX %<name>s %<expression>s TYPE %<type>s GRANULARITY %<granularity>d %<after>s'
|
80
|
+
pattern = {
|
81
|
+
name: name,
|
82
|
+
expression: expression,
|
83
|
+
type: type,
|
84
|
+
granularity: granularity,
|
85
|
+
after: Util::Statement.ensure(after, "AFTER #{after}"),
|
86
|
+
}
|
87
|
+
|
88
|
+
alter_table(table_name, format(template, pattern), cluster: cluster)
|
89
|
+
end
|
90
|
+
|
91
|
+
def drop_index(table_name, name, cluster: nil)
|
92
|
+
alter_table(table_name, <<~SQL, cluster: cluster)
|
93
|
+
DROP INDEX #{name}
|
94
|
+
SQL
|
95
|
+
end
|
69
96
|
end
|
70
97
|
end
|
71
98
|
end
|
data/lib/click_house/version.rb
CHANGED