click_house 1.3.8 → 1.3.9

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: 5c4ca9cca59d1e59aaf5e86ef624928def03e276492c775a15dbf48938716180
4
- data.tar.gz: 671a7c265806735bd8ce5dec00d7dcc1b8057179a2a74b3e771ff6b7792d2864
3
+ metadata.gz: a840e675477999a80f7ceee3f2364df83fc0efcc4ee4d0e16212dba1bb495acf
4
+ data.tar.gz: 1d8ad01d6dc2e1720c0d499f2f7168cdf83018151bc24dbbe1f8a8244da1d5ee
5
5
  SHA512:
6
- metadata.gz: 8c191e44fd27d8b08bbb2be2cca11057421557526596ca05cc8086182bbbb8a31897ccc92c3475221fdcd7a3c8fc6caeab312f4ffbbb7a313a2014d461542c16
7
- data.tar.gz: cfed5341b0320d362b05023ce48de8400a5078337f52d9adde990eb53465e9e1a15f388ae72ebf3a7335e4a3f1762cbc6c3a0197d3fb00c4f2e42def6a1157f0
6
+ metadata.gz: 76172279bdf916f3b1ff68e55ad576a3e05a5651e47e22547a20b8d87159b7920edc72c5bb8b449833d50409c30738dc4374259df7096af53a99141e8d67c9d5
7
+ data.tar.gz: 5542180b24e7d7e7b747cfd09eca9a999371b26b0013d783ef1fa888623eb6854803e38286aa3f0fb3893b158ffed6977ea92aa089c91f25523f0882a99b514e
@@ -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.connexction.explain("sql")`
15
+ * added `ClickHouse.connection.explain("sql")`
13
16
 
14
17
  # 1.3.4
15
18
  * added `ClickHouse.type_names(nullable: false)`
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- click_house (1.3.8)
4
+ click_house (1.3.9)
5
5
  faraday
6
6
  faraday_middleware
7
7
 
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClickHouse
4
- VERSION = '1.3.8'
4
+ VERSION = '1.3.9'
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.3.8
4
+ version: 1.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aliaksandr Shylau