dwh 0.1.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 +7 -0
- data/.rubocop.yml +36 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE +21 -0
- data/README.md +130 -0
- data/Rakefile +42 -0
- data/docs/DWH/Adapters/Adapter.html +3053 -0
- data/docs/DWH/Adapters/Athena.html +1704 -0
- data/docs/DWH/Adapters/Boolean.html +121 -0
- data/docs/DWH/Adapters/Druid.html +1626 -0
- data/docs/DWH/Adapters/DuckDb.html +2012 -0
- data/docs/DWH/Adapters/MySql.html +1704 -0
- data/docs/DWH/Adapters/OpenAuthorizable/ClassMethods.html +265 -0
- data/docs/DWH/Adapters/OpenAuthorizable.html +1102 -0
- data/docs/DWH/Adapters/Postgres.html +2000 -0
- data/docs/DWH/Adapters/Snowflake.html +1662 -0
- data/docs/DWH/Adapters/SqlServer.html +2084 -0
- data/docs/DWH/Adapters/Trino.html +1835 -0
- data/docs/DWH/Adapters.html +129 -0
- data/docs/DWH/AuthenticationError.html +142 -0
- data/docs/DWH/Behaviors.html +767 -0
- data/docs/DWH/Capabilities.html +748 -0
- data/docs/DWH/Column.html +1115 -0
- data/docs/DWH/ConfigError.html +143 -0
- data/docs/DWH/ConnectionError.html +143 -0
- data/docs/DWH/DWHError.html +138 -0
- data/docs/DWH/ExecutionError.html +143 -0
- data/docs/DWH/Factory.html +1133 -0
- data/docs/DWH/Functions/Arrays.html +505 -0
- data/docs/DWH/Functions/Dates.html +1644 -0
- data/docs/DWH/Functions/ExtractDatePart.html +804 -0
- data/docs/DWH/Functions/Nulls.html +377 -0
- data/docs/DWH/Functions.html +846 -0
- data/docs/DWH/Logger.html +258 -0
- data/docs/DWH/OAuthError.html +138 -0
- data/docs/DWH/Settings.html +658 -0
- data/docs/DWH/StreamingStats.html +804 -0
- data/docs/DWH/Table.html +1260 -0
- data/docs/DWH/TableStats.html +583 -0
- data/docs/DWH/TokenExpiredError.html +142 -0
- data/docs/DWH/UnsupportedCapability.html +135 -0
- data/docs/DWH.html +220 -0
- data/docs/_index.html +471 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +503 -0
- data/docs/file.README.html +210 -0
- data/docs/file.adapters.html +514 -0
- data/docs/file.creating-adapters.html +497 -0
- data/docs/file.getting-started.html +288 -0
- data/docs/file.usage.html +446 -0
- data/docs/file_list.html +79 -0
- data/docs/frames.html +22 -0
- data/docs/guides/adapters.md +445 -0
- data/docs/guides/creating-adapters.md +430 -0
- data/docs/guides/getting-started.md +225 -0
- data/docs/guides/usage.md +378 -0
- data/docs/index.html +210 -0
- data/docs/js/app.js +344 -0
- data/docs/js/full_list.js +242 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +2038 -0
- data/docs/top-level-namespace.html +110 -0
- data/lib/dwh/adapters/athena.rb +359 -0
- data/lib/dwh/adapters/druid.rb +267 -0
- data/lib/dwh/adapters/duck_db.rb +235 -0
- data/lib/dwh/adapters/my_sql.rb +235 -0
- data/lib/dwh/adapters/open_authorizable.rb +215 -0
- data/lib/dwh/adapters/postgres.rb +250 -0
- data/lib/dwh/adapters/snowflake.rb +489 -0
- data/lib/dwh/adapters/sql_server.rb +257 -0
- data/lib/dwh/adapters/trino.rb +213 -0
- data/lib/dwh/adapters.rb +363 -0
- data/lib/dwh/behaviors.rb +67 -0
- data/lib/dwh/capabilities.rb +39 -0
- data/lib/dwh/column.rb +79 -0
- data/lib/dwh/errors.rb +29 -0
- data/lib/dwh/factory.rb +125 -0
- data/lib/dwh/functions/arrays.rb +42 -0
- data/lib/dwh/functions/dates.rb +162 -0
- data/lib/dwh/functions/extract_date_part.rb +70 -0
- data/lib/dwh/functions/nulls.rb +31 -0
- data/lib/dwh/functions.rb +86 -0
- data/lib/dwh/logger.rb +50 -0
- data/lib/dwh/settings/athena.yml +77 -0
- data/lib/dwh/settings/base.yml +81 -0
- data/lib/dwh/settings/databricks.yml +51 -0
- data/lib/dwh/settings/druid.yml +59 -0
- data/lib/dwh/settings/duckdb.yml +44 -0
- data/lib/dwh/settings/mysql.yml +67 -0
- data/lib/dwh/settings/postgres.yml +30 -0
- data/lib/dwh/settings/redshift.yml +52 -0
- data/lib/dwh/settings/snowflake.yml +45 -0
- data/lib/dwh/settings/sqlserver.yml +80 -0
- data/lib/dwh/settings/trino.yml +77 -0
- data/lib/dwh/settings.rb +79 -0
- data/lib/dwh/streaming_stats.rb +69 -0
- data/lib/dwh/table.rb +105 -0
- data/lib/dwh/table_stats.rb +51 -0
- data/lib/dwh/version.rb +5 -0
- data/lib/dwh.rb +54 -0
- data/sig/dwh.rbs +4 -0
- metadata +231 -0
@@ -0,0 +1,2084 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: DWH::Adapters::SqlServer
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.37
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "DWH::Adapters::SqlServer";
|
19
|
+
relpath = '../../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../../_index.html">Index (S)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../DWH.html" title="DWH (module)">DWH</a></span></span> » <span class='title'><span class='object_link'><a href="../Adapters.html" title="DWH::Adapters (module)">Adapters</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">SqlServer</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: DWH::Adapters::SqlServer
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName"><span class='object_link'><a href="Adapter.html" title="DWH::Adapters::Adapter (class)">Adapter</a></span></span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next"><span class='object_link'><a href="Adapter.html" title="DWH::Adapters::Adapter (class)">Adapter</a></span></li>
|
78
|
+
|
79
|
+
<li class="next">DWH::Adapters::SqlServer</li>
|
80
|
+
|
81
|
+
</ul>
|
82
|
+
<a href="#" class="inheritanceTree">show all</a>
|
83
|
+
|
84
|
+
</dd>
|
85
|
+
</dl>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<dl>
|
98
|
+
<dt>Defined in:</dt>
|
99
|
+
<dd>lib/dwh/adapters/sql_server.rb</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
<p>Microsoft SQL Server adapter. This adapter requires the <a href="https://github.com/rails-sqlserver/tiny_tds" target="_parent" title="tiny_tds">tiny_tds</a>
|
107
|
+
gem. For Mac OS and Linux, you will need to instal FreeTDS and most likely needs OpenSSL. Please follow the
|
108
|
+
the instructions there before using the adapter.</p>
|
109
|
+
|
110
|
+
<p>Create and adatper instance using <span class='object_link'><a href="../Factory.html#create-instance_method" title="DWH::Factory#create (method)">DWH.create</a></span>.</p>
|
111
|
+
|
112
|
+
|
113
|
+
</div>
|
114
|
+
</div>
|
115
|
+
<div class="tags">
|
116
|
+
|
117
|
+
<div class="examples">
|
118
|
+
<h4 class="tag_title">Examples:</h4>
|
119
|
+
|
120
|
+
|
121
|
+
<h5 class="example_title"><div class='inline'><p>Basic connection with required only options</p>
|
122
|
+
</div></h5>
|
123
|
+
|
124
|
+
<pre class="example code"><code><span class='const'><span class='object_link'><a href="../../DWH.html" title="DWH (module)">DWH</a></span></span><span class='period'>.</span><span class='id identifier rubyid_create'><span class='object_link'><a href="../Factory.html#create-instance_method" title="DWH::Factory#create (method)">create</a></span></span><span class='lparen'>(</span><span class='symbol'>:sqlserver</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='label'>host:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>localhost</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>database:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>my_db</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>username:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sa</span><span class='tstring_end'>'</span></span><span class='rbrace'>}</span><span class='rparen'>)</span></code></pre>
|
125
|
+
|
126
|
+
|
127
|
+
<h5 class="example_title"><div class='inline'><p>Connect to Azuer SQL Server</p>
|
128
|
+
</div></h5>
|
129
|
+
|
130
|
+
<pre class="example code"><code><span class='const'><span class='object_link'><a href="../../DWH.html" title="DWH (module)">DWH</a></span></span><span class='period'>.</span><span class='id identifier rubyid_create'><span class='object_link'><a href="../Factory.html#create-instance_method" title="DWH::Factory#create (method)">create</a></span></span><span class='lparen'>(</span><span class='symbol'>:sqlserver</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='label'>host:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>localhost</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>database:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>my_db</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>username:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sa</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>azure:</span> <span class='kw'>true</span><span class='rbrace'>}</span><span class='rparen'>)</span></code></pre>
|
131
|
+
|
132
|
+
|
133
|
+
<h5 class="example_title"><div class='inline'><p>Connection sending custom application name</p>
|
134
|
+
</div></h5>
|
135
|
+
|
136
|
+
<pre class="example code"><code><span class='const'><span class='object_link'><a href="../../DWH.html" title="DWH (module)">DWH</a></span></span><span class='period'>.</span><span class='id identifier rubyid_create'><span class='object_link'><a href="../Factory.html#create-instance_method" title="DWH::Factory#create (method)">create</a></span></span><span class='lparen'>(</span><span class='symbol'>:sqlserver</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='label'>host:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>localhost</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>database:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>my_db</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>username:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sa</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>client_name:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Strata CLI</span><span class='tstring_end'>'</span></span><span class='rbrace'>}</span><span class='rparen'>)</span></code></pre>
|
137
|
+
|
138
|
+
|
139
|
+
<h5 class="example_title"><div class='inline'><p>Pass extra connection params</p>
|
140
|
+
</div></h5>
|
141
|
+
|
142
|
+
<pre class="example code"><code>DWH.create(:sqlserver, {host: 'localhost', database: 'my_db',
|
143
|
+
username: 'sa', client_name: 'Strata CLI',
|
144
|
+
extra_connection_params: {
|
145
|
+
container: true,
|
146
|
+
use_utf16: false
|
147
|
+
})</code></pre>
|
148
|
+
|
149
|
+
|
150
|
+
<h5 class="example_title"><div class='inline'><p>fetch tables in database</p>
|
151
|
+
</div></h5>
|
152
|
+
|
153
|
+
<pre class="example code"><code><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_tables'>tables</span></code></pre>
|
154
|
+
|
155
|
+
|
156
|
+
<h5 class="example_title"><div class='inline'><p>fetch tables from another database</p>
|
157
|
+
</div></h5>
|
158
|
+
|
159
|
+
<pre class="example code"><code><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_tables'>tables</span><span class='lparen'>(</span><span class='label'>catalog:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>other_db</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span></code></pre>
|
160
|
+
|
161
|
+
|
162
|
+
<h5 class="example_title"><div class='inline'><p>get table metadata for table in another db</p>
|
163
|
+
</div></h5>
|
164
|
+
|
165
|
+
<pre class="example code"><code><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>other_db.dbo.my_table</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>or</span> <span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_metadata'>metadata</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>my_table</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>catalog:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>other_db</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span></code></pre>
|
166
|
+
|
167
|
+
</div>
|
168
|
+
|
169
|
+
|
170
|
+
</div>
|
171
|
+
|
172
|
+
|
173
|
+
<h2>Constant Summary</h2>
|
174
|
+
|
175
|
+
<h3 class="inherited">Constants included
|
176
|
+
from <span class='object_link'><a href="../Settings.html" title="DWH::Settings (module)">Settings</a></span></h3>
|
177
|
+
<p class="inherited"><span class='object_link'><a href="../Settings.html#BASE_SETTINGS_FILE-constant" title="DWH::Settings::BASE_SETTINGS_FILE (constant)">Settings::BASE_SETTINGS_FILE</a></span></p>
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<h3 class="inherited">Constants included
|
182
|
+
from <span class='object_link'><a href="../Functions/Dates.html" title="DWH::Functions::Dates (module)">Functions::Dates</a></span></h3>
|
183
|
+
<p class="inherited"><span class='object_link'><a href="../Functions/Dates.html#DATE_CLASSES-constant" title="DWH::Functions::Dates::DATE_CLASSES (constant)">Functions::Dates::DATE_CLASSES</a></span>, <span class='object_link'><a href="../Functions/Dates.html#TIMESTAMPABLE_UNITS-constant" title="DWH::Functions::Dates::TIMESTAMPABLE_UNITS (constant)">Functions::Dates::TIMESTAMPABLE_UNITS</a></span></p>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
<h2>Instance Attribute Summary</h2>
|
189
|
+
|
190
|
+
<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Adapter.html" title="DWH::Adapters::Adapter (class)">Adapter</a></span></h3>
|
191
|
+
<p class="inherited"><span class='object_link'><a href="Adapter.html#config-instance_method" title="DWH::Adapters::Adapter#config (method)">#config</a></span>, <span class='object_link'><a href="Adapter.html#settings-instance_method" title="DWH::Adapters::Adapter#settings (method)">#settings</a></span></p>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
<h3 class="inherited">Attributes included from <span class='object_link'><a href="../Settings.html" title="DWH::Settings (module)">Settings</a></span></h3>
|
196
|
+
<p class="inherited"><span class='object_link'><a href="../Settings.html#adapter_settings-instance_method" title="DWH::Settings#adapter_settings (method)">#adapter_settings</a></span></p>
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
<h2>
|
201
|
+
Instance Method Summary
|
202
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
203
|
+
</h2>
|
204
|
+
|
205
|
+
<ul class="summary">
|
206
|
+
|
207
|
+
<li class="public ">
|
208
|
+
<span class="summary_signature">
|
209
|
+
|
210
|
+
<a href="#change_current_database-instance_method" title="#change_current_database (instance method)">#<strong>change_current_database</strong>(catalog = nil) ⇒ Object </a>
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
</span>
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
<span class="summary_desc"><div class='inline'><p>Changes the default database to the one specified here.</p>
|
225
|
+
</div></span>
|
226
|
+
|
227
|
+
</li>
|
228
|
+
|
229
|
+
|
230
|
+
<li class="public ">
|
231
|
+
<span class="summary_signature">
|
232
|
+
|
233
|
+
<a href="#connection-instance_method" title="#connection (instance method)">#<strong>connection</strong> ⇒ Object </a>
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
</span>
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
<span class="summary_desc"><div class='inline'><p>Creates a connection to the target database and returns the connection object or self.</p>
|
248
|
+
</div></span>
|
249
|
+
|
250
|
+
</li>
|
251
|
+
|
252
|
+
|
253
|
+
<li class="public ">
|
254
|
+
<span class="summary_signature">
|
255
|
+
|
256
|
+
<a href="#execute-instance_method" title="#execute (instance method)">#<strong>execute</strong>(sql, format: :array, retries: 0) ⇒ Array<Array>, ... </a>
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
</span>
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
<span class="summary_desc"><div class='inline'><p>Execute sql on the target database.</p>
|
271
|
+
</div></span>
|
272
|
+
|
273
|
+
</li>
|
274
|
+
|
275
|
+
|
276
|
+
<li class="public ">
|
277
|
+
<span class="summary_signature">
|
278
|
+
|
279
|
+
<a href="#execute_stream-instance_method" title="#execute_stream (instance method)">#<strong>execute_stream</strong>(sql, io, stats: nil, retries: 0) ⇒ IO </a>
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
</span>
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
<span class="summary_desc"><div class='inline'><p>Execute sql and stream responses back.</p>
|
294
|
+
</div></span>
|
295
|
+
|
296
|
+
</li>
|
297
|
+
|
298
|
+
|
299
|
+
<li class="public ">
|
300
|
+
<span class="summary_signature">
|
301
|
+
|
302
|
+
<a href="#extract_day_name-instance_method" title="#extract_day_name (instance method)">#<strong>extract_day_name</strong>(exp, abbreviate: false) ⇒ Object </a>
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
</span>
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
<span class="summary_desc"><div class='inline'>
|
317
|
+
</div></span>
|
318
|
+
|
319
|
+
</li>
|
320
|
+
|
321
|
+
|
322
|
+
<li class="public ">
|
323
|
+
<span class="summary_signature">
|
324
|
+
|
325
|
+
<a href="#extract_month_name-instance_method" title="#extract_month_name (instance method)">#<strong>extract_month_name</strong>(exp, abbreviate: false) ⇒ Object </a>
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
</span>
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
<span class="summary_desc"><div class='inline'>
|
340
|
+
</div></span>
|
341
|
+
|
342
|
+
</li>
|
343
|
+
|
344
|
+
|
345
|
+
<li class="public ">
|
346
|
+
<span class="summary_signature">
|
347
|
+
|
348
|
+
<a href="#metadata-instance_method" title="#metadata (instance method)">#<strong>metadata</strong>(table, **qualifiers) ⇒ DWH::Table </a>
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
</span>
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
<span class="summary_desc"><div class='inline'><p>Get the schema structure of a given a given table_name.</p>
|
363
|
+
</div></span>
|
364
|
+
|
365
|
+
</li>
|
366
|
+
|
367
|
+
|
368
|
+
<li class="public ">
|
369
|
+
<span class="summary_signature">
|
370
|
+
|
371
|
+
<a href="#reset_current_database-instance_method" title="#reset_current_database (instance method)">#<strong>reset_current_database</strong> ⇒ Object </a>
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
</span>
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
<span class="summary_desc"><div class='inline'><p>Resets the default database to the configured one if it was changed.</p>
|
386
|
+
</div></span>
|
387
|
+
|
388
|
+
</li>
|
389
|
+
|
390
|
+
|
391
|
+
<li class="public ">
|
392
|
+
<span class="summary_signature">
|
393
|
+
|
394
|
+
<a href="#stats-instance_method" title="#stats (instance method)">#<strong>stats</strong>(table, date_column: nil, **qualifiers) ⇒ DWH::Table </a>
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
</span>
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
<span class="summary_desc"><div class='inline'><p>Returns basic stats of a given table.</p>
|
409
|
+
</div></span>
|
410
|
+
|
411
|
+
</li>
|
412
|
+
|
413
|
+
|
414
|
+
<li class="public ">
|
415
|
+
<span class="summary_signature">
|
416
|
+
|
417
|
+
<a href="#stream-instance_method" title="#stream (instance method)">#<strong>stream</strong>(sql) {|chunk| ... } ⇒ Object </a>
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
</span>
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
<span class="summary_desc"><div class='inline'><p>Executes the given sql and yields the streamed results to the given block.</p>
|
432
|
+
</div></span>
|
433
|
+
|
434
|
+
</li>
|
435
|
+
|
436
|
+
|
437
|
+
<li class="public ">
|
438
|
+
<span class="summary_signature">
|
439
|
+
|
440
|
+
<a href="#table%3F-instance_method" title="#table? (instance method)">#<strong>table?</strong>(table_name) ⇒ Boolean </a>
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
</span>
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
<span class="summary_desc"><div class='inline'><p>Check if table exists in remote db.</p>
|
455
|
+
</div></span>
|
456
|
+
|
457
|
+
</li>
|
458
|
+
|
459
|
+
|
460
|
+
<li class="public ">
|
461
|
+
<span class="summary_signature">
|
462
|
+
|
463
|
+
<a href="#tables-instance_method" title="#tables (instance method)">#<strong>tables</strong>(**qualifiers) ⇒ Array<String> </a>
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
</span>
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
<span class="summary_desc"><div class='inline'><p>Get all tables available in the target db.</p>
|
478
|
+
</div></span>
|
479
|
+
|
480
|
+
</li>
|
481
|
+
|
482
|
+
|
483
|
+
<li class="public ">
|
484
|
+
<span class="summary_signature">
|
485
|
+
|
486
|
+
<a href="#test_connection-instance_method" title="#test_connection (instance method)">#<strong>test_connection</strong>(raise_exception: false) ⇒ Boolean </a>
|
487
|
+
|
488
|
+
|
489
|
+
|
490
|
+
</span>
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
<span class="summary_desc"><div class='inline'><p>Tests the connection to the target database and returns true if successful, or raise Exception or false connection object or self.</p>
|
501
|
+
</div></span>
|
502
|
+
|
503
|
+
</li>
|
504
|
+
|
505
|
+
|
506
|
+
<li class="public ">
|
507
|
+
<span class="summary_signature">
|
508
|
+
|
509
|
+
<a href="#valid_config%3F-instance_method" title="#valid_config? (instance method)">#<strong>valid_config?</strong> ⇒ Boolean </a>
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
</span>
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
<span class="summary_desc"><div class='inline'>
|
524
|
+
</div></span>
|
525
|
+
|
526
|
+
</li>
|
527
|
+
|
528
|
+
|
529
|
+
</ul>
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="Adapter.html" title="DWH::Adapters::Adapter (class)">Adapter</a></span></h3>
|
542
|
+
<p class="inherited"><span class='object_link'><a href="Adapter.html#adapter_name-instance_method" title="DWH::Adapters::Adapter#adapter_name (method)">#adapter_name</a></span>, <span class='object_link'><a href="Adapter.html#alter_settings-instance_method" title="DWH::Adapters::Adapter#alter_settings (method)">#alter_settings</a></span>, <span class='object_link'><a href="Adapter.html#close-instance_method" title="DWH::Adapters::Adapter#close (method)">#close</a></span>, <span class='object_link'><a href="Adapter.html#config-class_method" title="DWH::Adapters::Adapter.config (method)">config</a></span>, <span class='object_link'><a href="Adapter.html#configuration-class_method" title="DWH::Adapters::Adapter.configuration (method)">configuration</a></span>, <span class='object_link'><a href="Adapter.html#connect!-instance_method" title="DWH::Adapters::Adapter#connect! (method)">#connect!</a></span>, <span class='object_link'><a href="Adapter.html#connect%3F-instance_method" title="DWH::Adapters::Adapter#connect? (method)">#connect?</a></span>, <span class='object_link'><a href="Adapter.html#extra_connection_params-instance_method" title="DWH::Adapters::Adapter#extra_connection_params (method)">#extra_connection_params</a></span>, <span class='object_link'><a href="Adapter.html#extra_query_params-instance_method" title="DWH::Adapters::Adapter#extra_query_params (method)">#extra_query_params</a></span>, <span class='object_link'><a href="Adapter.html#initialize-instance_method" title="DWH::Adapters::Adapter#initialize (method)">#initialize</a></span>, <span class='object_link'><a href="Adapter.html#reset_settings-instance_method" title="DWH::Adapters::Adapter#reset_settings (method)">#reset_settings</a></span>, <span class='object_link'><a href="Adapter.html#token_expired%3F-instance_method" title="DWH::Adapters::Adapter#token_expired? (method)">#token_expired?</a></span>, <span class='object_link'><a href="Adapter.html#with_debug-instance_method" title="DWH::Adapters::Adapter#with_debug (method)">#with_debug</a></span>, <span class='object_link'><a href="Adapter.html#with_retry-instance_method" title="DWH::Adapters::Adapter#with_retry (method)">#with_retry</a></span></p>
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Settings.html" title="DWH::Settings (module)">Settings</a></span></h3>
|
553
|
+
<p class="inherited"><span class='object_link'><a href="../Settings.html#adapter_name-instance_method" title="DWH::Settings#adapter_name (method)">#adapter_name</a></span>, <span class='object_link'><a href="../Settings.html#load_settings-instance_method" title="DWH::Settings#load_settings (method)">#load_settings</a></span>, <span class='object_link'><a href="../Settings.html#settings_file-instance_method" title="DWH::Settings#settings_file (method)">#settings_file</a></span>, <span class='object_link'><a href="../Settings.html#settings_file_path-instance_method" title="DWH::Settings#settings_file_path (method)">#settings_file_path</a></span>, <span class='object_link'><a href="../Settings.html#using_base_settings%3F-instance_method" title="DWH::Settings#using_base_settings? (method)">#using_base_settings?</a></span></p>
|
554
|
+
|
555
|
+
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Logger.html" title="DWH::Logger (module)">Logger</a></span></h3>
|
564
|
+
<p class="inherited"><span class='object_link'><a href="../Logger.html#logger-instance_method" title="DWH::Logger#logger (method)">#logger</a></span>, <span class='object_link'><a href="../Logger.html#logger-class_method" title="DWH::Logger.logger (method)">logger</a></span></p>
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
|
574
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Behaviors.html" title="DWH::Behaviors (module)">Behaviors</a></span></h3>
|
575
|
+
<p class="inherited"><span class='object_link'><a href="../Behaviors.html#apply_advanced_filtering_on_array_projections%3F-instance_method" title="DWH::Behaviors#apply_advanced_filtering_on_array_projections? (method)">#apply_advanced_filtering_on_array_projections?</a></span>, <span class='object_link'><a href="../Behaviors.html#cross_universe_measure_filtering_strategy-instance_method" title="DWH::Behaviors#cross_universe_measure_filtering_strategy (method)">#cross_universe_measure_filtering_strategy</a></span>, <span class='object_link'><a href="../Behaviors.html#extend_ending_date_to_last_hour_of_day%3F-instance_method" title="DWH::Behaviors#extend_ending_date_to_last_hour_of_day? (method)">#extend_ending_date_to_last_hour_of_day?</a></span>, <span class='object_link'><a href="../Behaviors.html#final_measure_filter%3F-instance_method" title="DWH::Behaviors#final_measure_filter? (method)">#final_measure_filter?</a></span>, <span class='object_link'><a href="../Behaviors.html#final_pass_measure_join_type-instance_method" title="DWH::Behaviors#final_pass_measure_join_type (method)">#final_pass_measure_join_type</a></span>, <span class='object_link'><a href="../Behaviors.html#greedy_apply_date_filters-instance_method" title="DWH::Behaviors#greedy_apply_date_filters (method)">#greedy_apply_date_filters</a></span>, <span class='object_link'><a href="../Behaviors.html#intermediate_measure_filter%3F-instance_method" title="DWH::Behaviors#intermediate_measure_filter? (method)">#intermediate_measure_filter?</a></span>, <span class='object_link'><a href="../Behaviors.html#temp_table_prefix-instance_method" title="DWH::Behaviors#temp_table_prefix (method)">#temp_table_prefix</a></span>, <span class='object_link'><a href="../Behaviors.html#temp_table_type-instance_method" title="DWH::Behaviors#temp_table_type (method)">#temp_table_type</a></span></p>
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Functions.html" title="DWH::Functions (module)">Functions</a></span></h3>
|
586
|
+
<p class="inherited"><span class='object_link'><a href="../Functions.html#cast-instance_method" title="DWH::Functions#cast (method)">#cast</a></span>, <span class='object_link'><a href="../Functions.html#cross_join-instance_method" title="DWH::Functions#cross_join (method)">#cross_join</a></span>, <span class='object_link'><a href="../Functions.html#gsk-instance_method" title="DWH::Functions#gsk (method)">#gsk</a></span>, <span class='object_link'><a href="../Functions.html#lower_case-instance_method" title="DWH::Functions#lower_case (method)">#lower_case</a></span>, <span class='object_link'><a href="../Functions.html#quote-instance_method" title="DWH::Functions#quote (method)">#quote</a></span>, <span class='object_link'><a href="../Functions.html#string_lit-instance_method" title="DWH::Functions#string_lit (method)">#string_lit</a></span>, <span class='object_link'><a href="../Functions.html#trim-instance_method" title="DWH::Functions#trim (method)">#trim</a></span>, <span class='object_link'><a href="../Functions.html#upper_case-instance_method" title="DWH::Functions#upper_case (method)">#upper_case</a></span></p>
|
587
|
+
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
|
594
|
+
|
595
|
+
|
596
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Functions/Arrays.html" title="DWH::Functions::Arrays (module)">Functions::Arrays</a></span></h3>
|
597
|
+
<p class="inherited"><span class='object_link'><a href="../Functions/Arrays.html#array_exclude_list-instance_method" title="DWH::Functions::Arrays#array_exclude_list (method)">#array_exclude_list</a></span>, <span class='object_link'><a href="../Functions/Arrays.html#array_in_list-instance_method" title="DWH::Functions::Arrays#array_in_list (method)">#array_in_list</a></span>, <span class='object_link'><a href="../Functions/Arrays.html#array_unnest_join-instance_method" title="DWH::Functions::Arrays#array_unnest_join (method)">#array_unnest_join</a></span></p>
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Functions/Nulls.html" title="DWH::Functions::Nulls (module)">Functions::Nulls</a></span></h3>
|
608
|
+
<p class="inherited"><span class='object_link'><a href="../Functions/Nulls.html#if_null-instance_method" title="DWH::Functions::Nulls#if_null (method)">#if_null</a></span>, <span class='object_link'><a href="../Functions/Nulls.html#null_if-instance_method" title="DWH::Functions::Nulls#null_if (method)">#null_if</a></span>, <span class='object_link'><a href="../Functions/Nulls.html#null_if_zero-instance_method" title="DWH::Functions::Nulls#null_if_zero (method)">#null_if_zero</a></span></p>
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
|
613
|
+
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
|
618
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Functions/ExtractDatePart.html" title="DWH::Functions::ExtractDatePart (module)">Functions::ExtractDatePart</a></span></h3>
|
619
|
+
<p class="inherited"><span class='object_link'><a href="../Functions/ExtractDatePart.html#extract_day_of_month-instance_method" title="DWH::Functions::ExtractDatePart#extract_day_of_month (method)">#extract_day_of_month</a></span>, <span class='object_link'><a href="../Functions/ExtractDatePart.html#extract_day_of_week-instance_method" title="DWH::Functions::ExtractDatePart#extract_day_of_week (method)">#extract_day_of_week</a></span>, <span class='object_link'><a href="../Functions/ExtractDatePart.html#extract_day_of_year-instance_method" title="DWH::Functions::ExtractDatePart#extract_day_of_year (method)">#extract_day_of_year</a></span>, <span class='object_link'><a href="../Functions/ExtractDatePart.html#extract_hour-instance_method" title="DWH::Functions::ExtractDatePart#extract_hour (method)">#extract_hour</a></span>, <span class='object_link'><a href="../Functions/ExtractDatePart.html#extract_minute-instance_method" title="DWH::Functions::ExtractDatePart#extract_minute (method)">#extract_minute</a></span>, <span class='object_link'><a href="../Functions/ExtractDatePart.html#extract_month-instance_method" title="DWH::Functions::ExtractDatePart#extract_month (method)">#extract_month</a></span>, <span class='object_link'><a href="../Functions/ExtractDatePart.html#extract_quarter-instance_method" title="DWH::Functions::ExtractDatePart#extract_quarter (method)">#extract_quarter</a></span>, <span class='object_link'><a href="../Functions/ExtractDatePart.html#extract_week_of_year-instance_method" title="DWH::Functions::ExtractDatePart#extract_week_of_year (method)">#extract_week_of_year</a></span>, <span class='object_link'><a href="../Functions/ExtractDatePart.html#extract_year-instance_method" title="DWH::Functions::ExtractDatePart#extract_year (method)">#extract_year</a></span>, <span class='object_link'><a href="../Functions/ExtractDatePart.html#extract_year_month-instance_method" title="DWH::Functions::ExtractDatePart#extract_year_month (method)">#extract_year_month</a></span></p>
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
|
625
|
+
|
626
|
+
|
627
|
+
|
628
|
+
|
629
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Functions/Dates.html" title="DWH::Functions::Dates (module)">Functions::Dates</a></span></h3>
|
630
|
+
<p class="inherited"><span class='object_link'><a href="../Functions/Dates.html#adjust_week_start_day-instance_method" title="DWH::Functions::Dates#adjust_week_start_day (method)">#adjust_week_start_day</a></span>, <span class='object_link'><a href="../Functions/Dates.html#adjust_week_start_day%3F-instance_method" title="DWH::Functions::Dates#adjust_week_start_day? (method)">#adjust_week_start_day?</a></span>, <span class='object_link'><a href="../Functions/Dates.html#current_date-instance_method" title="DWH::Functions::Dates#current_date (method)">#current_date</a></span>, <span class='object_link'><a href="../Functions/Dates.html#current_time-instance_method" title="DWH::Functions::Dates#current_time (method)">#current_time</a></span>, <span class='object_link'><a href="../Functions/Dates.html#current_timestamp-instance_method" title="DWH::Functions::Dates#current_timestamp (method)">#current_timestamp</a></span>, <span class='object_link'><a href="../Functions/Dates.html#date_add-instance_method" title="DWH::Functions::Dates#date_add (method)">#date_add</a></span>, <span class='object_link'><a href="../Functions/Dates.html#date_data_type-instance_method" title="DWH::Functions::Dates#date_data_type (method)">#date_data_type</a></span>, <span class='object_link'><a href="../Functions/Dates.html#date_diff-instance_method" title="DWH::Functions::Dates#date_diff (method)">#date_diff</a></span>, <span class='object_link'><a href="../Functions/Dates.html#date_format-instance_method" title="DWH::Functions::Dates#date_format (method)">#date_format</a></span>, <span class='object_link'><a href="../Functions/Dates.html#date_format_sql-instance_method" title="DWH::Functions::Dates#date_format_sql (method)">#date_format_sql</a></span>, <span class='object_link'><a href="../Functions/Dates.html#date_int%3F-instance_method" title="DWH::Functions::Dates#date_int? (method)">#date_int?</a></span>, <span class='object_link'><a href="../Functions/Dates.html#date_literal-instance_method" title="DWH::Functions::Dates#date_literal (method)">#date_literal</a></span>, <span class='object_link'><a href="../Functions/Dates.html#date_time_format-instance_method" title="DWH::Functions::Dates#date_time_format (method)">#date_time_format</a></span>, <span class='object_link'><a href="../Functions/Dates.html#date_time_literal-instance_method" title="DWH::Functions::Dates#date_time_literal (method)">#date_time_literal</a></span>, <span class='object_link'><a href="../Functions/Dates.html#date_time_tz_format-instance_method" title="DWH::Functions::Dates#date_time_tz_format (method)">#date_time_tz_format</a></span>, <span class='object_link'><a href="../Functions/Dates.html#default_week_start_day-instance_method" title="DWH::Functions::Dates#default_week_start_day (method)">#default_week_start_day</a></span>, <span class='object_link'><a href="../Functions/Dates.html#truncate_date-instance_method" title="DWH::Functions::Dates#truncate_date (method)">#truncate_date</a></span>, <span class='object_link'><a href="../Functions/Dates.html#week_start_day-instance_method" title="DWH::Functions::Dates#week_start_day (method)">#week_start_day</a></span>, <span class='object_link'><a href="../Functions/Dates.html#week_starts_on_sunday%3F-instance_method" title="DWH::Functions::Dates#week_starts_on_sunday? (method)">#week_starts_on_sunday?</a></span></p>
|
631
|
+
|
632
|
+
|
633
|
+
|
634
|
+
|
635
|
+
|
636
|
+
|
637
|
+
|
638
|
+
|
639
|
+
|
640
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Capabilities.html" title="DWH::Capabilities (module)">Capabilities</a></span></h3>
|
641
|
+
<p class="inherited"><span class='object_link'><a href="../Capabilities.html#supports_array_functions%3F-instance_method" title="DWH::Capabilities#supports_array_functions? (method)">#supports_array_functions?</a></span>, <span class='object_link'><a href="../Capabilities.html#supports_common_table_expressions%3F-instance_method" title="DWH::Capabilities#supports_common_table_expressions? (method)">#supports_common_table_expressions?</a></span>, <span class='object_link'><a href="../Capabilities.html#supports_cross_join%3F-instance_method" title="DWH::Capabilities#supports_cross_join? (method)">#supports_cross_join?</a></span>, <span class='object_link'><a href="../Capabilities.html#supports_full_join%3F-instance_method" title="DWH::Capabilities#supports_full_join? (method)">#supports_full_join?</a></span>, <span class='object_link'><a href="../Capabilities.html#supports_sub_queries%3F-instance_method" title="DWH::Capabilities#supports_sub_queries? (method)">#supports_sub_queries?</a></span>, <span class='object_link'><a href="../Capabilities.html#supports_table_join%3F-instance_method" title="DWH::Capabilities#supports_table_join? (method)">#supports_table_join?</a></span>, <span class='object_link'><a href="../Capabilities.html#supports_temp_tables%3F-instance_method" title="DWH::Capabilities#supports_temp_tables? (method)">#supports_temp_tables?</a></span>, <span class='object_link'><a href="../Capabilities.html#supports_window_functions%3F-instance_method" title="DWH::Capabilities#supports_window_functions? (method)">#supports_window_functions?</a></span></p>
|
642
|
+
<div id="constructor_details" class="method_details_list">
|
643
|
+
<h2>Constructor Details</h2>
|
644
|
+
|
645
|
+
<p class="notice">This class inherits a constructor from <span class='object_link'><a href="Adapter.html#initialize-instance_method" title="DWH::Adapters::Adapter#initialize (method)">DWH::Adapters::Adapter</a></span></p>
|
646
|
+
|
647
|
+
</div>
|
648
|
+
|
649
|
+
|
650
|
+
<div id="instance_method_details" class="method_details_list">
|
651
|
+
<h2>Instance Method Details</h2>
|
652
|
+
|
653
|
+
|
654
|
+
<div class="method_details first">
|
655
|
+
<h3 class="signature first" id="change_current_database-instance_method">
|
656
|
+
|
657
|
+
#<strong>change_current_database</strong>(catalog = nil) ⇒ <tt>Object</tt>
|
658
|
+
|
659
|
+
|
660
|
+
|
661
|
+
|
662
|
+
|
663
|
+
</h3><div class="docstring">
|
664
|
+
<div class="discussion">
|
665
|
+
<p>Changes the default database to the one specified here.
|
666
|
+
will store the default db in @current_database attr.</p>
|
667
|
+
|
668
|
+
|
669
|
+
</div>
|
670
|
+
</div>
|
671
|
+
<div class="tags">
|
672
|
+
<p class="tag_title">Parameters:</p>
|
673
|
+
<ul class="param">
|
674
|
+
|
675
|
+
<li>
|
676
|
+
|
677
|
+
<span class='name'>catalog</span>
|
678
|
+
|
679
|
+
|
680
|
+
<span class='type'>(<tt>String</tt>)</span>
|
681
|
+
|
682
|
+
|
683
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
684
|
+
|
685
|
+
|
686
|
+
—
|
687
|
+
<div class='inline'><p>new database to use</p>
|
688
|
+
</div>
|
689
|
+
|
690
|
+
</li>
|
691
|
+
|
692
|
+
</ul>
|
693
|
+
|
694
|
+
|
695
|
+
</div><table class="source_code">
|
696
|
+
<tr>
|
697
|
+
<td>
|
698
|
+
<pre class="lines">
|
699
|
+
|
700
|
+
|
701
|
+
97
|
702
|
+
98
|
703
|
+
99
|
704
|
+
100
|
705
|
+
101
|
706
|
+
102</pre>
|
707
|
+
</td>
|
708
|
+
<td>
|
709
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 97</span>
|
710
|
+
|
711
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_change_current_database'>change_current_database</span><span class='lparen'>(</span><span class='id identifier rubyid_catalog'>catalog</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
712
|
+
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_catalog'>catalog</span> <span class='op'>&&</span> <span class='id identifier rubyid_catalog'>catalog</span> <span class='op'>!=</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:database</span><span class='rbracket'>]</span>
|
713
|
+
|
714
|
+
<span class='ivar'>@current_database</span> <span class='op'>=</span> <span class='id identifier rubyid_catalog'>catalog</span>
|
715
|
+
<span class='id identifier rubyid_use'>use</span><span class='lparen'>(</span><span class='id identifier rubyid_catalog'>catalog</span><span class='rparen'>)</span>
|
716
|
+
<span class='kw'>end</span></pre>
|
717
|
+
</td>
|
718
|
+
</tr>
|
719
|
+
</table>
|
720
|
+
</div>
|
721
|
+
|
722
|
+
<div class="method_details ">
|
723
|
+
<h3 class="signature " id="connection-instance_method">
|
724
|
+
|
725
|
+
#<strong>connection</strong> ⇒ <tt>Object</tt>
|
726
|
+
|
727
|
+
|
728
|
+
|
729
|
+
|
730
|
+
|
731
|
+
</h3><div class="docstring">
|
732
|
+
<div class="discussion">
|
733
|
+
<p>Creates a connection to the target database and returns the
|
734
|
+
connection object or self</p>
|
735
|
+
|
736
|
+
|
737
|
+
</div>
|
738
|
+
</div>
|
739
|
+
<div class="tags">
|
740
|
+
|
741
|
+
|
742
|
+
</div><table class="source_code">
|
743
|
+
<tr>
|
744
|
+
<td>
|
745
|
+
<pre class="lines">
|
746
|
+
|
747
|
+
|
748
|
+
44
|
749
|
+
45
|
750
|
+
46
|
751
|
+
47
|
752
|
+
48
|
753
|
+
49
|
754
|
+
50
|
755
|
+
51
|
756
|
+
52
|
757
|
+
53
|
758
|
+
54
|
759
|
+
55
|
760
|
+
56
|
761
|
+
57
|
762
|
+
58
|
763
|
+
59
|
764
|
+
60
|
765
|
+
61
|
766
|
+
62
|
767
|
+
63</pre>
|
768
|
+
</td>
|
769
|
+
<td>
|
770
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 44</span>
|
771
|
+
|
772
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_connection'>connection</span>
|
773
|
+
<span class='kw'>return</span> <span class='ivar'>@connection</span> <span class='kw'>if</span> <span class='ivar'>@connection</span>
|
774
|
+
|
775
|
+
<span class='id identifier rubyid_properties'>properties</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
776
|
+
<span class='label'>host:</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:host</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
777
|
+
<span class='label'>port:</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:port</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
778
|
+
<span class='label'>database:</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:database</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
779
|
+
<span class='label'>username:</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:username</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
780
|
+
<span class='label'>password:</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:password</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
781
|
+
<span class='label'>appname:</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:client_name</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
782
|
+
<span class='label'>timeout:</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:query_timeout</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
783
|
+
<span class='label'>azure:</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:azure</span><span class='rbracket'>]</span>
|
784
|
+
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_extra_connection_params'>extra_connection_params</span><span class='rparen'>)</span>
|
785
|
+
|
786
|
+
<span class='ivar'>@connection</span> <span class='op'>=</span> <span class='const'>TinyTds</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_properties'>properties</span><span class='rparen'>)</span>
|
787
|
+
|
788
|
+
<span class='ivar'>@connection</span>
|
789
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
790
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../ConfigError.html" title="DWH::ConfigError (class)">ConfigError</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
|
791
|
+
<span class='kw'>end</span></pre>
|
792
|
+
</td>
|
793
|
+
</tr>
|
794
|
+
</table>
|
795
|
+
</div>
|
796
|
+
|
797
|
+
<div class="method_details ">
|
798
|
+
<h3 class="signature " id="execute-instance_method">
|
799
|
+
|
800
|
+
#<strong>execute</strong>(sql, format: :array, retries: 0) ⇒ <tt>Array<Array></tt>, ...
|
801
|
+
|
802
|
+
|
803
|
+
|
804
|
+
|
805
|
+
|
806
|
+
</h3><div class="docstring">
|
807
|
+
<div class="discussion">
|
808
|
+
<p>Execute sql on the target database.</p>
|
809
|
+
|
810
|
+
|
811
|
+
</div>
|
812
|
+
</div>
|
813
|
+
<div class="tags">
|
814
|
+
<p class="tag_title">Parameters:</p>
|
815
|
+
<ul class="param">
|
816
|
+
|
817
|
+
<li>
|
818
|
+
|
819
|
+
<span class='name'>sql</span>
|
820
|
+
|
821
|
+
|
822
|
+
<span class='type'>(<tt>String</tt>)</span>
|
823
|
+
|
824
|
+
|
825
|
+
|
826
|
+
—
|
827
|
+
<div class='inline'><p>actual sql</p>
|
828
|
+
</div>
|
829
|
+
|
830
|
+
</li>
|
831
|
+
|
832
|
+
<li>
|
833
|
+
|
834
|
+
<span class='name'>format</span>
|
835
|
+
|
836
|
+
|
837
|
+
<span class='type'>(<tt>Symbol</tt>, <tt>String</tt>)</span>
|
838
|
+
|
839
|
+
|
840
|
+
<em class="default">(defaults to: <tt>:array</tt>)</em>
|
841
|
+
|
842
|
+
|
843
|
+
—
|
844
|
+
<div class='inline'><p>return format type
|
845
|
+
- array returns array of array
|
846
|
+
- object returns array of Hashes
|
847
|
+
- csv returns as csv
|
848
|
+
- native returns the native result from any clients used
|
849
|
+
- For example: Postgres using pg client will return PG::Result
|
850
|
+
- Http clients will returns the HTTP response object</p>
|
851
|
+
</div>
|
852
|
+
|
853
|
+
</li>
|
854
|
+
|
855
|
+
<li>
|
856
|
+
|
857
|
+
<span class='name'>retries</span>
|
858
|
+
|
859
|
+
|
860
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
861
|
+
|
862
|
+
|
863
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
864
|
+
|
865
|
+
|
866
|
+
—
|
867
|
+
<div class='inline'><p>number of retries in case of failure. Default is 0</p>
|
868
|
+
</div>
|
869
|
+
|
870
|
+
</li>
|
871
|
+
|
872
|
+
</ul>
|
873
|
+
|
874
|
+
<p class="tag_title">Returns:</p>
|
875
|
+
<ul class="return">
|
876
|
+
|
877
|
+
<li>
|
878
|
+
|
879
|
+
|
880
|
+
<span class='type'>(<tt>Array<Array></tt>, <tt>Hash</tt>, <tt>CSV</tt>, <tt>Native</tt>)</span>
|
881
|
+
|
882
|
+
|
883
|
+
|
884
|
+
</li>
|
885
|
+
|
886
|
+
</ul>
|
887
|
+
<p class="tag_title">Raises:</p>
|
888
|
+
<ul class="raise">
|
889
|
+
|
890
|
+
<li>
|
891
|
+
|
892
|
+
|
893
|
+
<span class='type'>(<tt><span class='object_link'><a href="../ConnectionError.html" title="DWH::ConnectionError (class)">ConnectionError</a></span></tt>, <tt><span class='object_link'><a href="../ExecutionError.html" title="DWH::ExecutionError (class)">ExecutionError</a></span></tt>)</span>
|
894
|
+
|
895
|
+
|
896
|
+
|
897
|
+
</li>
|
898
|
+
|
899
|
+
</ul>
|
900
|
+
|
901
|
+
</div><table class="source_code">
|
902
|
+
<tr>
|
903
|
+
<td>
|
904
|
+
<pre class="lines">
|
905
|
+
|
906
|
+
|
907
|
+
170
|
908
|
+
171
|
909
|
+
172
|
910
|
+
173
|
911
|
+
174
|
912
|
+
175
|
913
|
+
176
|
914
|
+
177
|
915
|
+
178
|
916
|
+
179
|
917
|
+
180
|
918
|
+
181
|
919
|
+
182
|
920
|
+
183
|
921
|
+
184
|
922
|
+
185
|
923
|
+
186
|
924
|
+
187
|
925
|
+
188</pre>
|
926
|
+
</td>
|
927
|
+
<td>
|
928
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 170</span>
|
929
|
+
|
930
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='comma'>,</span> <span class='label'>format:</span> <span class='symbol'>:array</span><span class='comma'>,</span> <span class='label'>retries:</span> <span class='int'>0</span><span class='rparen'>)</span>
|
931
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_with_debug'>with_debug</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_with_retry'>with_retry</span><span class='lparen'>(</span><span class='id identifier rubyid_retries'>retries</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_connection'>connection</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
|
932
|
+
|
933
|
+
<span class='id identifier rubyid_format'>format</span> <span class='op'>=</span> <span class='id identifier rubyid_format'>format</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span> <span class='kw'>if</span> <span class='id identifier rubyid_format'>format</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
|
934
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_format'>format</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
|
935
|
+
<span class='kw'>when</span> <span class='symbol'>:array</span>
|
936
|
+
<span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span><span class='lparen'>(</span><span class='label'>as:</span> <span class='symbol'>:array</span><span class='comma'>,</span> <span class='label'>empty_sets:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>timezone:</span> <span class='symbol'>:utc</span><span class='rparen'>)</span>
|
937
|
+
<span class='kw'>when</span> <span class='symbol'>:object</span>
|
938
|
+
<span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span><span class='lparen'>(</span><span class='label'>as:</span> <span class='symbol'>:hash</span><span class='comma'>,</span> <span class='label'>empty_sets:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>timezone:</span> <span class='symbol'>:utc</span><span class='rparen'>)</span>
|
939
|
+
<span class='kw'>when</span> <span class='symbol'>:csv</span>
|
940
|
+
<span class='id identifier rubyid_result_to_csv'>result_to_csv</span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='rparen'>)</span>
|
941
|
+
<span class='kw'>when</span> <span class='symbol'>:native</span>
|
942
|
+
<span class='id identifier rubyid_result'>result</span>
|
943
|
+
<span class='kw'>else</span>
|
944
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../UnsupportedCapability.html" title="DWH::UnsupportedCapability (class)">UnsupportedCapability</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unsupported format: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_format'>format</span><span class='embexpr_end'>}</span><span class='tstring_content'> for this </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
945
|
+
<span class='kw'>end</span>
|
946
|
+
<span class='kw'>rescue</span> <span class='const'>TinyTds</span><span class='op'>::</span><span class='const'>Error</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
947
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../ExecutionError.html" title="DWH::ExecutionError (class)">ExecutionError</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
|
948
|
+
<span class='kw'>end</span></pre>
|
949
|
+
</td>
|
950
|
+
</tr>
|
951
|
+
</table>
|
952
|
+
</div>
|
953
|
+
|
954
|
+
<div class="method_details ">
|
955
|
+
<h3 class="signature " id="execute_stream-instance_method">
|
956
|
+
|
957
|
+
#<strong>execute_stream</strong>(sql, io, stats: nil, retries: 0) ⇒ <tt>IO</tt>
|
958
|
+
|
959
|
+
|
960
|
+
|
961
|
+
|
962
|
+
|
963
|
+
</h3><div class="docstring">
|
964
|
+
<div class="discussion">
|
965
|
+
<p>Execute sql and stream responses back. Data is writtent out in CSV format
|
966
|
+
to the provided IO object.</p>
|
967
|
+
|
968
|
+
|
969
|
+
</div>
|
970
|
+
</div>
|
971
|
+
<div class="tags">
|
972
|
+
<p class="tag_title">Parameters:</p>
|
973
|
+
<ul class="param">
|
974
|
+
|
975
|
+
<li>
|
976
|
+
|
977
|
+
<span class='name'>sql</span>
|
978
|
+
|
979
|
+
|
980
|
+
<span class='type'>(<tt>String</tt>)</span>
|
981
|
+
|
982
|
+
|
983
|
+
|
984
|
+
—
|
985
|
+
<div class='inline'><p>actual sql</p>
|
986
|
+
</div>
|
987
|
+
|
988
|
+
</li>
|
989
|
+
|
990
|
+
<li>
|
991
|
+
|
992
|
+
<span class='name'>io</span>
|
993
|
+
|
994
|
+
|
995
|
+
<span class='type'>(<tt>IO</tt>)</span>
|
996
|
+
|
997
|
+
|
998
|
+
|
999
|
+
—
|
1000
|
+
<div class='inline'><p>IO object to write records to</p>
|
1001
|
+
</div>
|
1002
|
+
|
1003
|
+
</li>
|
1004
|
+
|
1005
|
+
<li>
|
1006
|
+
|
1007
|
+
<span class='name'>stats</span>
|
1008
|
+
|
1009
|
+
|
1010
|
+
<span class='type'>(<tt><span class='object_link'><a href="../StreamingStats.html" title="DWH::StreamingStats (class)">StreamingStats</a></span></tt>)</span>
|
1011
|
+
|
1012
|
+
|
1013
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1014
|
+
|
1015
|
+
|
1016
|
+
—
|
1017
|
+
<div class='inline'><p>collect stats and preview data this is optional</p>
|
1018
|
+
</div>
|
1019
|
+
|
1020
|
+
</li>
|
1021
|
+
|
1022
|
+
<li>
|
1023
|
+
|
1024
|
+
<span class='name'>retries</span>
|
1025
|
+
|
1026
|
+
|
1027
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
1028
|
+
|
1029
|
+
|
1030
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
1031
|
+
|
1032
|
+
|
1033
|
+
—
|
1034
|
+
<div class='inline'><p>number of retries in case of failure</p>
|
1035
|
+
</div>
|
1036
|
+
|
1037
|
+
</li>
|
1038
|
+
|
1039
|
+
</ul>
|
1040
|
+
|
1041
|
+
<p class="tag_title">Returns:</p>
|
1042
|
+
<ul class="return">
|
1043
|
+
|
1044
|
+
<li>
|
1045
|
+
|
1046
|
+
|
1047
|
+
<span class='type'>(<tt>IO</tt>)</span>
|
1048
|
+
|
1049
|
+
|
1050
|
+
|
1051
|
+
</li>
|
1052
|
+
|
1053
|
+
</ul>
|
1054
|
+
<p class="tag_title">Raises:</p>
|
1055
|
+
<ul class="raise">
|
1056
|
+
|
1057
|
+
<li>
|
1058
|
+
|
1059
|
+
|
1060
|
+
<span class='type'>(<tt><span class='object_link'><a href="../ConnectionError.html" title="DWH::ConnectionError (class)">ConnectionError</a></span></tt>, <tt><span class='object_link'><a href="../ExecutionError.html" title="DWH::ExecutionError (class)">ExecutionError</a></span></tt>)</span>
|
1061
|
+
|
1062
|
+
|
1063
|
+
|
1064
|
+
</li>
|
1065
|
+
|
1066
|
+
</ul>
|
1067
|
+
|
1068
|
+
</div><table class="source_code">
|
1069
|
+
<tr>
|
1070
|
+
<td>
|
1071
|
+
<pre class="lines">
|
1072
|
+
|
1073
|
+
|
1074
|
+
191
|
1075
|
+
192
|
1076
|
+
193
|
1077
|
+
194
|
1078
|
+
195
|
1079
|
+
196
|
1080
|
+
197
|
1081
|
+
198
|
1082
|
+
199
|
1083
|
+
200
|
1084
|
+
201
|
1085
|
+
202
|
1086
|
+
203
|
1087
|
+
204
|
1088
|
+
205
|
1089
|
+
206
|
1090
|
+
207</pre>
|
1091
|
+
</td>
|
1092
|
+
<td>
|
1093
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 191</span>
|
1094
|
+
|
1095
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_execute_stream'>execute_stream</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='comma'>,</span> <span class='id identifier rubyid_io'>io</span><span class='comma'>,</span> <span class='label'>stats:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>retries:</span> <span class='int'>0</span><span class='rparen'>)</span>
|
1096
|
+
<span class='id identifier rubyid_with_debug'>with_debug</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
1097
|
+
<span class='id identifier rubyid_with_retry'>with_retry</span><span class='lparen'>(</span><span class='id identifier rubyid_retries'>retries</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
1098
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_connection'>connection</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span>
|
1099
|
+
<span class='id identifier rubyid_io'>io</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='const'>CSV</span><span class='period'>.</span><span class='id identifier rubyid_generate_line'>generate_line</span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_fields'>fields</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1100
|
+
<span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='label'>as:</span> <span class='symbol'>:array</span><span class='comma'>,</span> <span class='label'>empty_sets:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>cache_rows:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>timezone:</span> <span class='symbol'>:utc</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_row'>row</span><span class='op'>|</span>
|
1101
|
+
<span class='id identifier rubyid_stats'>stats</span> <span class='op'><<</span> <span class='id identifier rubyid_row'>row</span> <span class='kw'>unless</span> <span class='id identifier rubyid_stats'>stats</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
1102
|
+
<span class='id identifier rubyid_io'>io</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='const'>CSV</span><span class='period'>.</span><span class='id identifier rubyid_generate_line'>generate_line</span><span class='lparen'>(</span><span class='id identifier rubyid_row'>row</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1103
|
+
<span class='kw'>end</span>
|
1104
|
+
<span class='kw'>end</span>
|
1105
|
+
<span class='kw'>end</span>
|
1106
|
+
|
1107
|
+
<span class='id identifier rubyid_io'>io</span><span class='period'>.</span><span class='id identifier rubyid_rewind'>rewind</span>
|
1108
|
+
<span class='id identifier rubyid_io'>io</span>
|
1109
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
1110
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../ExecutionError.html" title="DWH::ExecutionError (class)">ExecutionError</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
|
1111
|
+
<span class='kw'>end</span></pre>
|
1112
|
+
</td>
|
1113
|
+
</tr>
|
1114
|
+
</table>
|
1115
|
+
</div>
|
1116
|
+
|
1117
|
+
<div class="method_details ">
|
1118
|
+
<h3 class="signature " id="extract_day_name-instance_method">
|
1119
|
+
|
1120
|
+
#<strong>extract_day_name</strong>(exp, abbreviate: false) ⇒ <tt>Object</tt>
|
1121
|
+
|
1122
|
+
|
1123
|
+
|
1124
|
+
|
1125
|
+
|
1126
|
+
</h3><table class="source_code">
|
1127
|
+
<tr>
|
1128
|
+
<td>
|
1129
|
+
<pre class="lines">
|
1130
|
+
|
1131
|
+
|
1132
|
+
219
|
1133
|
+
220
|
1134
|
+
221
|
1135
|
+
222</pre>
|
1136
|
+
</td>
|
1137
|
+
<td>
|
1138
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 219</span>
|
1139
|
+
|
1140
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_extract_day_name'>extract_day_name</span><span class='lparen'>(</span><span class='id identifier rubyid_exp'>exp</span><span class='comma'>,</span> <span class='label'>abbreviate:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1141
|
+
<span class='id identifier rubyid_exp'>exp</span> <span class='op'>=</span> <span class='id identifier rubyid_cast'>cast</span><span class='lparen'>(</span><span class='id identifier rubyid_exp'>exp</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>date</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_exp'>exp</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>cast</span><span class='regexp_end'>/i</span></span>
|
1142
|
+
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_exp'>exp</span><span class='comma'>,</span> <span class='label'>abbreviate:</span> <span class='id identifier rubyid_abbreviate'>abbreviate</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span>
|
1143
|
+
<span class='kw'>end</span></pre>
|
1144
|
+
</td>
|
1145
|
+
</tr>
|
1146
|
+
</table>
|
1147
|
+
</div>
|
1148
|
+
|
1149
|
+
<div class="method_details ">
|
1150
|
+
<h3 class="signature " id="extract_month_name-instance_method">
|
1151
|
+
|
1152
|
+
#<strong>extract_month_name</strong>(exp, abbreviate: false) ⇒ <tt>Object</tt>
|
1153
|
+
|
1154
|
+
|
1155
|
+
|
1156
|
+
|
1157
|
+
|
1158
|
+
</h3><table class="source_code">
|
1159
|
+
<tr>
|
1160
|
+
<td>
|
1161
|
+
<pre class="lines">
|
1162
|
+
|
1163
|
+
|
1164
|
+
224
|
1165
|
+
225
|
1166
|
+
226
|
1167
|
+
227
|
1168
|
+
228
|
1169
|
+
229
|
1170
|
+
230
|
1171
|
+
231</pre>
|
1172
|
+
</td>
|
1173
|
+
<td>
|
1174
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 224</span>
|
1175
|
+
|
1176
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_extract_month_name'>extract_month_name</span><span class='lparen'>(</span><span class='id identifier rubyid_exp'>exp</span><span class='comma'>,</span> <span class='label'>abbreviate:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1177
|
+
<span class='id identifier rubyid_exp'>exp</span> <span class='op'>=</span> <span class='id identifier rubyid_cast'>cast</span><span class='lparen'>(</span><span class='id identifier rubyid_exp'>exp</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>date</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_exp'>exp</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>cast</span><span class='regexp_end'>/i</span></span>
|
1178
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_abbreviate'>abbreviate</span>
|
1179
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>UPPER(LEFT(DATENAME(month, </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exp'>exp</span><span class='embexpr_end'>}</span><span class='tstring_content'>), 3))</span><span class='tstring_end'>"</span></span>
|
1180
|
+
<span class='kw'>else</span>
|
1181
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>UPPER(DATENAME(month, </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exp'>exp</span><span class='embexpr_end'>}</span><span class='tstring_content'>))</span><span class='tstring_end'>"</span></span>
|
1182
|
+
<span class='kw'>end</span>
|
1183
|
+
<span class='kw'>end</span></pre>
|
1184
|
+
</td>
|
1185
|
+
</tr>
|
1186
|
+
</table>
|
1187
|
+
</div>
|
1188
|
+
|
1189
|
+
<div class="method_details ">
|
1190
|
+
<h3 class="signature " id="metadata-instance_method">
|
1191
|
+
|
1192
|
+
#<strong>metadata</strong>(table, **qualifiers) ⇒ <tt><span class='object_link'><a href="../Table.html" title="DWH::Table (class)">DWH::Table</a></span></tt>
|
1193
|
+
|
1194
|
+
|
1195
|
+
|
1196
|
+
|
1197
|
+
|
1198
|
+
</h3><div class="docstring">
|
1199
|
+
<div class="discussion">
|
1200
|
+
<p>Get the schema structure of a given a given table_name.
|
1201
|
+
Pass in optional catalog and schema info.</p>
|
1202
|
+
|
1203
|
+
<p>Example:
|
1204
|
+
metadata(“public.big_table”)
|
1205
|
+
metadata(“big_table”)
|
1206
|
+
metadata(“big_table”,schema: “public”)</p>
|
1207
|
+
|
1208
|
+
|
1209
|
+
</div>
|
1210
|
+
</div>
|
1211
|
+
<div class="tags">
|
1212
|
+
<p class="tag_title">Parameters:</p>
|
1213
|
+
<ul class="param">
|
1214
|
+
|
1215
|
+
<li>
|
1216
|
+
|
1217
|
+
<span class='name'>table</span>
|
1218
|
+
|
1219
|
+
|
1220
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1221
|
+
|
1222
|
+
|
1223
|
+
|
1224
|
+
—
|
1225
|
+
<div class='inline'><ul>
|
1226
|
+
<li>table name</li>
|
1227
|
+
</ul>
|
1228
|
+
</div>
|
1229
|
+
|
1230
|
+
</li>
|
1231
|
+
|
1232
|
+
<li>
|
1233
|
+
|
1234
|
+
<span class='name'>qualifiers</span>
|
1235
|
+
|
1236
|
+
|
1237
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1238
|
+
|
1239
|
+
|
1240
|
+
|
1241
|
+
—
|
1242
|
+
<div class='inline'><p>a customizable set of options</p>
|
1243
|
+
</div>
|
1244
|
+
|
1245
|
+
</li>
|
1246
|
+
|
1247
|
+
</ul>
|
1248
|
+
|
1249
|
+
|
1250
|
+
|
1251
|
+
|
1252
|
+
|
1253
|
+
|
1254
|
+
<p class="tag_title">Options Hash (<tt>**qualifiers</tt>):</p>
|
1255
|
+
<ul class="option">
|
1256
|
+
|
1257
|
+
<li>
|
1258
|
+
<span class="name">:catalog</span>
|
1259
|
+
<span class="type">(<tt>String</tt>)</span>
|
1260
|
+
<span class="default">
|
1261
|
+
|
1262
|
+
</span>
|
1263
|
+
|
1264
|
+
— <div class='inline'><p>optional catalog or equivalent name space.
|
1265
|
+
will be ignored if the adapter doesn’t support</p>
|
1266
|
+
</div>
|
1267
|
+
|
1268
|
+
</li>
|
1269
|
+
|
1270
|
+
<li>
|
1271
|
+
<span class="name">:schema</span>
|
1272
|
+
<span class="type">(<tt>String</tt>)</span>
|
1273
|
+
<span class="default">
|
1274
|
+
|
1275
|
+
</span>
|
1276
|
+
|
1277
|
+
— <div class='inline'><p>optional schema to scope to.
|
1278
|
+
will be ignored if the adapter doesn’t support</p>
|
1279
|
+
</div>
|
1280
|
+
|
1281
|
+
</li>
|
1282
|
+
|
1283
|
+
</ul>
|
1284
|
+
|
1285
|
+
|
1286
|
+
<p class="tag_title">Returns:</p>
|
1287
|
+
<ul class="return">
|
1288
|
+
|
1289
|
+
<li>
|
1290
|
+
|
1291
|
+
|
1292
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Table.html" title="DWH::Table (class)">DWH::Table</a></span></tt>)</span>
|
1293
|
+
|
1294
|
+
|
1295
|
+
|
1296
|
+
</li>
|
1297
|
+
|
1298
|
+
</ul>
|
1299
|
+
|
1300
|
+
</div><table class="source_code">
|
1301
|
+
<tr>
|
1302
|
+
<td>
|
1303
|
+
<pre class="lines">
|
1304
|
+
|
1305
|
+
|
1306
|
+
140
|
1307
|
+
141
|
1308
|
+
142
|
1309
|
+
143
|
1310
|
+
144
|
1311
|
+
145
|
1312
|
+
146
|
1313
|
+
147
|
1314
|
+
148
|
1315
|
+
149
|
1316
|
+
150
|
1317
|
+
151
|
1318
|
+
152
|
1319
|
+
153
|
1320
|
+
154
|
1321
|
+
155
|
1322
|
+
156
|
1323
|
+
157
|
1324
|
+
158
|
1325
|
+
159
|
1326
|
+
160
|
1327
|
+
161
|
1328
|
+
162
|
1329
|
+
163
|
1330
|
+
164
|
1331
|
+
165
|
1332
|
+
166
|
1333
|
+
167</pre>
|
1334
|
+
</td>
|
1335
|
+
<td>
|
1336
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 140</span>
|
1337
|
+
|
1338
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='rparen'>)</span>
|
1339
|
+
<span class='id identifier rubyid_db_table'>db_table</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Table.html" title="DWH::Table (class)">Table</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Table.html#initialize-instance_method" title="DWH::Table#initialize (method)">new</a></span></span> <span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_qualifiers'>qualifiers</span>
|
1340
|
+
<span class='id identifier rubyid_change_current_database'>change_current_database</span><span class='lparen'>(</span><span class='id identifier rubyid_db_table'>db_table</span><span class='period'>.</span><span class='id identifier rubyid_catalog'>catalog</span><span class='rparen'>)</span>
|
1341
|
+
|
1342
|
+
<span class='id identifier rubyid_schema_where'>schema_where</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
1343
|
+
<span class='id identifier rubyid_schema_where'>schema_where</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>AND table_schema = '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_db_table'>db_table</span><span class='period'>.</span><span class='id identifier rubyid_schema'>schema</span><span class='embexpr_end'>}</span><span class='tstring_content'>'</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_db_table'>db_table</span><span class='period'>.</span><span class='id identifier rubyid_schema'>schema</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
1344
|
+
|
1345
|
+
<span class='id identifier rubyid_sql'>sql</span> <span class='op'>=</span> <span class='heredoc_beg'><<-SQL</span>
|
1346
|
+
<span class='tstring_content'> SELECT column_name, data_type, character_maximum_length, numeric_precision,numeric_scale
|
1347
|
+
FROM information_schema.columns
|
1348
|
+
WHERE table_name = '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_db_table'>db_table</span><span class='period'>.</span><span class='id identifier rubyid_physical_name'>physical_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>'
|
1349
|
+
</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_schema_where'>schema_where</span><span class='embexpr_end'>}</span><span class='tstring_content'>
|
1350
|
+
</span><span class='heredoc_end'> SQL
|
1351
|
+
</span> <span class='id identifier rubyid_cols'>cols</span> <span class='op'>=</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='comma'>,</span> <span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>object</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
1352
|
+
<span class='id identifier rubyid_cols'>cols</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_col'>col</span><span class='op'>|</span>
|
1353
|
+
<span class='id identifier rubyid_db_table'>db_table</span> <span class='op'><<</span> <span class='const'><span class='object_link'><a href="../Column.html" title="DWH::Column (class)">Column</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Column.html#initialize-instance_method" title="DWH::Column#initialize (method)">new</a></span></span><span class='lparen'>(</span>
|
1354
|
+
<span class='label'>name:</span> <span class='id identifier rubyid_col'>col</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>column_name</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
|
1355
|
+
<span class='label'>data_type:</span> <span class='id identifier rubyid_col'>col</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>data_type</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
|
1356
|
+
<span class='label'>precision:</span> <span class='id identifier rubyid_col'>col</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>numeric_precision</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
|
1357
|
+
<span class='label'>scale:</span> <span class='id identifier rubyid_col'>col</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>numeric_scale</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
|
1358
|
+
<span class='label'>max_char_length:</span> <span class='id identifier rubyid_col'>col</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>character_maximum_length</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
1359
|
+
<span class='rparen'>)</span>
|
1360
|
+
<span class='kw'>end</span>
|
1361
|
+
|
1362
|
+
<span class='id identifier rubyid_db_table'>db_table</span>
|
1363
|
+
<span class='kw'>ensure</span>
|
1364
|
+
<span class='id identifier rubyid_reset_current_database'>reset_current_database</span>
|
1365
|
+
<span class='kw'>end</span></pre>
|
1366
|
+
</td>
|
1367
|
+
</tr>
|
1368
|
+
</table>
|
1369
|
+
</div>
|
1370
|
+
|
1371
|
+
<div class="method_details ">
|
1372
|
+
<h3 class="signature " id="reset_current_database-instance_method">
|
1373
|
+
|
1374
|
+
#<strong>reset_current_database</strong> ⇒ <tt>Object</tt>
|
1375
|
+
|
1376
|
+
|
1377
|
+
|
1378
|
+
|
1379
|
+
|
1380
|
+
</h3><div class="docstring">
|
1381
|
+
<div class="discussion">
|
1382
|
+
<p>Resets the default database to the configured one
|
1383
|
+
if it was changed</p>
|
1384
|
+
|
1385
|
+
|
1386
|
+
</div>
|
1387
|
+
</div>
|
1388
|
+
<div class="tags">
|
1389
|
+
|
1390
|
+
|
1391
|
+
</div><table class="source_code">
|
1392
|
+
<tr>
|
1393
|
+
<td>
|
1394
|
+
<pre class="lines">
|
1395
|
+
|
1396
|
+
|
1397
|
+
106
|
1398
|
+
107
|
1399
|
+
108
|
1400
|
+
109
|
1401
|
+
110</pre>
|
1402
|
+
</td>
|
1403
|
+
<td>
|
1404
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 106</span>
|
1405
|
+
|
1406
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_reset_current_database'>reset_current_database</span>
|
1407
|
+
<span class='kw'>return</span> <span class='kw'>if</span> <span class='ivar'>@current_database</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='ivar'>@current_database</span> <span class='op'>==</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:database</span><span class='rbracket'>]</span>
|
1408
|
+
|
1409
|
+
<span class='id identifier rubyid_use'>use</span><span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:database</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
1410
|
+
<span class='kw'>end</span></pre>
|
1411
|
+
</td>
|
1412
|
+
</tr>
|
1413
|
+
</table>
|
1414
|
+
</div>
|
1415
|
+
|
1416
|
+
<div class="method_details ">
|
1417
|
+
<h3 class="signature " id="stats-instance_method">
|
1418
|
+
|
1419
|
+
#<strong>stats</strong>(table, date_column: nil, **qualifiers) ⇒ <tt><span class='object_link'><a href="../Table.html" title="DWH::Table (class)">DWH::Table</a></span></tt>
|
1420
|
+
|
1421
|
+
|
1422
|
+
|
1423
|
+
|
1424
|
+
|
1425
|
+
</h3><div class="docstring">
|
1426
|
+
<div class="discussion">
|
1427
|
+
<p>Returns basic stats of a given table. Will typically include row_count,
|
1428
|
+
date_start, and date_end.</p>
|
1429
|
+
|
1430
|
+
|
1431
|
+
</div>
|
1432
|
+
</div>
|
1433
|
+
<div class="tags">
|
1434
|
+
|
1435
|
+
<div class="examples">
|
1436
|
+
<h4 class="tag_title">Examples:</h4>
|
1437
|
+
|
1438
|
+
|
1439
|
+
<pre class="example code"><code><span class='id identifier rubyid_stats'>stats</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>public.big_table</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>date_column:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>fact_date</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1440
|
+
<span class='id identifier rubyid_stats'>stats</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>big_table</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1441
|
+
<span class='id identifier rubyid_stats'>stats</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>big_table</span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='label'>schema:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>public</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span></code></pre>
|
1442
|
+
|
1443
|
+
</div>
|
1444
|
+
<p class="tag_title">Parameters:</p>
|
1445
|
+
<ul class="param">
|
1446
|
+
|
1447
|
+
<li>
|
1448
|
+
|
1449
|
+
<span class='name'>table</span>
|
1450
|
+
|
1451
|
+
|
1452
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1453
|
+
|
1454
|
+
|
1455
|
+
|
1456
|
+
—
|
1457
|
+
<div class='inline'><p>table name</p>
|
1458
|
+
</div>
|
1459
|
+
|
1460
|
+
</li>
|
1461
|
+
|
1462
|
+
<li>
|
1463
|
+
|
1464
|
+
<span class='name'>date_column</span>
|
1465
|
+
|
1466
|
+
|
1467
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1468
|
+
|
1469
|
+
|
1470
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1471
|
+
|
1472
|
+
|
1473
|
+
—
|
1474
|
+
<div class='inline'><p>optional date column to use to find range</p>
|
1475
|
+
</div>
|
1476
|
+
|
1477
|
+
</li>
|
1478
|
+
|
1479
|
+
<li>
|
1480
|
+
|
1481
|
+
<span class='name'>qualifiers</span>
|
1482
|
+
|
1483
|
+
|
1484
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1485
|
+
|
1486
|
+
|
1487
|
+
|
1488
|
+
—
|
1489
|
+
<div class='inline'><p>a customizable set of options</p>
|
1490
|
+
</div>
|
1491
|
+
|
1492
|
+
</li>
|
1493
|
+
|
1494
|
+
</ul>
|
1495
|
+
|
1496
|
+
|
1497
|
+
|
1498
|
+
|
1499
|
+
|
1500
|
+
|
1501
|
+
|
1502
|
+
|
1503
|
+
<p class="tag_title">Options Hash (<tt>**qualifiers</tt>):</p>
|
1504
|
+
<ul class="option">
|
1505
|
+
|
1506
|
+
<li>
|
1507
|
+
<span class="name">:catalog</span>
|
1508
|
+
<span class="type">(<tt>String</tt>)</span>
|
1509
|
+
<span class="default">
|
1510
|
+
|
1511
|
+
</span>
|
1512
|
+
|
1513
|
+
— <div class='inline'><p>optional catalog or equivalent name space.
|
1514
|
+
will be ignored if the adapter doesn’t support</p>
|
1515
|
+
</div>
|
1516
|
+
|
1517
|
+
</li>
|
1518
|
+
|
1519
|
+
<li>
|
1520
|
+
<span class="name">:schema</span>
|
1521
|
+
<span class="type">(<tt>String</tt>)</span>
|
1522
|
+
<span class="default">
|
1523
|
+
|
1524
|
+
</span>
|
1525
|
+
|
1526
|
+
— <div class='inline'><p>optional schema to scope to.
|
1527
|
+
will be ignored if the adapter doesn’t support</p>
|
1528
|
+
</div>
|
1529
|
+
|
1530
|
+
</li>
|
1531
|
+
|
1532
|
+
</ul>
|
1533
|
+
|
1534
|
+
|
1535
|
+
<p class="tag_title">Returns:</p>
|
1536
|
+
<ul class="return">
|
1537
|
+
|
1538
|
+
<li>
|
1539
|
+
|
1540
|
+
|
1541
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Table.html" title="DWH::Table (class)">DWH::Table</a></span></tt>)</span>
|
1542
|
+
|
1543
|
+
|
1544
|
+
|
1545
|
+
</li>
|
1546
|
+
|
1547
|
+
</ul>
|
1548
|
+
<p class="tag_title">Raises:</p>
|
1549
|
+
<ul class="raise">
|
1550
|
+
|
1551
|
+
<li>
|
1552
|
+
|
1553
|
+
|
1554
|
+
<span class='type'>(<tt><span class='object_link'><a href="../ConnectionError.html" title="DWH::ConnectionError (class)">ConnectionError</a></span></tt>, <tt><span class='object_link'><a href="../ExecutionError.html" title="DWH::ExecutionError (class)">ExecutionError</a></span></tt>)</span>
|
1555
|
+
|
1556
|
+
|
1557
|
+
|
1558
|
+
</li>
|
1559
|
+
|
1560
|
+
</ul>
|
1561
|
+
|
1562
|
+
</div><table class="source_code">
|
1563
|
+
<tr>
|
1564
|
+
<td>
|
1565
|
+
<pre class="lines">
|
1566
|
+
|
1567
|
+
|
1568
|
+
118
|
1569
|
+
119
|
1570
|
+
120
|
1571
|
+
121
|
1572
|
+
122
|
1573
|
+
123
|
1574
|
+
124
|
1575
|
+
125
|
1576
|
+
126
|
1577
|
+
127
|
1578
|
+
128
|
1579
|
+
129
|
1580
|
+
130
|
1581
|
+
131
|
1582
|
+
132
|
1583
|
+
133
|
1584
|
+
134
|
1585
|
+
135
|
1586
|
+
136
|
1587
|
+
137</pre>
|
1588
|
+
</td>
|
1589
|
+
<td>
|
1590
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 118</span>
|
1591
|
+
|
1592
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_stats'>stats</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='label'>date_column:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='rparen'>)</span>
|
1593
|
+
<span class='id identifier rubyid_change_current_database'>change_current_database</span><span class='lparen'>(</span><span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='lbracket'>[</span><span class='symbol'>:catalog</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
1594
|
+
<span class='id identifier rubyid_table_name'>table_name</span> <span class='op'>=</span> <span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='lbracket'>[</span><span class='symbol'>:schema</span><span class='rbracket'>]</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='lbracket'>[</span><span class='symbol'>:schema</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_table'>table</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='id identifier rubyid_table'>table</span>
|
1595
|
+
<span class='id identifier rubyid_sql'>sql</span> <span class='op'>=</span> <span class='heredoc_beg'><<-SQL</span>
|
1596
|
+
<span class='tstring_content'> SELECT count(*) ROW_COUNT
|
1597
|
+
</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_date_column'>date_column</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='kw'>nil</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, min(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_date_column'>date_column</span><span class='embexpr_end'>}</span><span class='tstring_content'>) DATE_START</span><span class='tstring_end'>"</span></span><span class='embexpr_end'>}</span><span class='tstring_content'>
|
1598
|
+
</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_date_column'>date_column</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='kw'>nil</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, max(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_date_column'>date_column</span><span class='embexpr_end'>}</span><span class='tstring_content'>) DATE_END</span><span class='tstring_end'>"</span></span><span class='embexpr_end'>}</span><span class='tstring_content'>
|
1599
|
+
FROM </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_quote'>quote</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>
|
1600
|
+
</span><span class='heredoc_end'> SQL
|
1601
|
+
</span>
|
1602
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_connection'>connection</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span>
|
1603
|
+
<span class='id identifier rubyid_row'>row</span> <span class='op'>=</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span><span class='lparen'>(</span><span class='label'>empty_sets:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
1604
|
+
<span class='const'><span class='object_link'><a href="../TableStats.html" title="DWH::TableStats (class)">TableStats</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../TableStats.html#initialize-instance_method" title="DWH::TableStats#initialize (method)">new</a></span></span><span class='lparen'>(</span>
|
1605
|
+
<span class='label'>row_count:</span> <span class='id identifier rubyid_row'>row</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ROW_COUNT</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
|
1606
|
+
<span class='label'>date_start:</span> <span class='id identifier rubyid_row'>row</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>DATE_START</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
|
1607
|
+
<span class='label'>date_end:</span> <span class='id identifier rubyid_row'>row</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>DATE_END</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
1608
|
+
<span class='rparen'>)</span>
|
1609
|
+
<span class='kw'>ensure</span>
|
1610
|
+
<span class='id identifier rubyid_reset_current_database'>reset_current_database</span>
|
1611
|
+
<span class='kw'>end</span></pre>
|
1612
|
+
</td>
|
1613
|
+
</tr>
|
1614
|
+
</table>
|
1615
|
+
</div>
|
1616
|
+
|
1617
|
+
<div class="method_details ">
|
1618
|
+
<h3 class="signature " id="stream-instance_method">
|
1619
|
+
|
1620
|
+
#<strong>stream</strong>(sql) {|chunk| ... } ⇒ <tt>Object</tt>
|
1621
|
+
|
1622
|
+
|
1623
|
+
|
1624
|
+
|
1625
|
+
|
1626
|
+
</h3><div class="docstring">
|
1627
|
+
<div class="discussion">
|
1628
|
+
<p>Executes the given sql and yields the streamed results
|
1629
|
+
to the given block.</p>
|
1630
|
+
|
1631
|
+
|
1632
|
+
</div>
|
1633
|
+
</div>
|
1634
|
+
<div class="tags">
|
1635
|
+
<p class="tag_title">Parameters:</p>
|
1636
|
+
<ul class="param">
|
1637
|
+
|
1638
|
+
<li>
|
1639
|
+
|
1640
|
+
<span class='name'>sql</span>
|
1641
|
+
|
1642
|
+
|
1643
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1644
|
+
|
1645
|
+
|
1646
|
+
|
1647
|
+
—
|
1648
|
+
<div class='inline'><p>actual sql</p>
|
1649
|
+
</div>
|
1650
|
+
|
1651
|
+
</li>
|
1652
|
+
|
1653
|
+
</ul>
|
1654
|
+
|
1655
|
+
<p class="tag_title">Yields:</p>
|
1656
|
+
<ul class="yield">
|
1657
|
+
|
1658
|
+
<li>
|
1659
|
+
|
1660
|
+
|
1661
|
+
<span class='type'>(<tt>chunk</tt>)</span>
|
1662
|
+
|
1663
|
+
|
1664
|
+
|
1665
|
+
—
|
1666
|
+
<div class='inline'><p>Yields a streamed chunk as it streams in. The chunk type
|
1667
|
+
might vary depending on the target db and settings</p>
|
1668
|
+
</div>
|
1669
|
+
|
1670
|
+
</li>
|
1671
|
+
|
1672
|
+
</ul>
|
1673
|
+
<p class="tag_title">Raises:</p>
|
1674
|
+
<ul class="raise">
|
1675
|
+
|
1676
|
+
<li>
|
1677
|
+
|
1678
|
+
|
1679
|
+
<span class='type'>(<tt><span class='object_link'><a href="../ConnectionError.html" title="DWH::ConnectionError (class)">ConnectionError</a></span></tt>, <tt><span class='object_link'><a href="../ExecutionError.html" title="DWH::ExecutionError (class)">ExecutionError</a></span></tt>)</span>
|
1680
|
+
|
1681
|
+
|
1682
|
+
|
1683
|
+
</li>
|
1684
|
+
|
1685
|
+
</ul>
|
1686
|
+
|
1687
|
+
</div><table class="source_code">
|
1688
|
+
<tr>
|
1689
|
+
<td>
|
1690
|
+
<pre class="lines">
|
1691
|
+
|
1692
|
+
|
1693
|
+
210
|
1694
|
+
211
|
1695
|
+
212
|
1696
|
+
213
|
1697
|
+
214
|
1698
|
+
215
|
1699
|
+
216
|
1700
|
+
217</pre>
|
1701
|
+
</td>
|
1702
|
+
<td>
|
1703
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 210</span>
|
1704
|
+
|
1705
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_stream'>stream</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1706
|
+
<span class='id identifier rubyid_with_debug'>with_debug</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
1707
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_connection'>connection</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span>
|
1708
|
+
<span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='label'>empty_sets:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>cache_rows:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>timezone:</span> <span class='symbol'>:utc</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_row'>row</span><span class='op'>|</span>
|
1709
|
+
<span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_row'>row</span><span class='rparen'>)</span>
|
1710
|
+
<span class='kw'>end</span>
|
1711
|
+
<span class='kw'>end</span>
|
1712
|
+
<span class='kw'>end</span></pre>
|
1713
|
+
</td>
|
1714
|
+
</tr>
|
1715
|
+
</table>
|
1716
|
+
</div>
|
1717
|
+
|
1718
|
+
<div class="method_details ">
|
1719
|
+
<h3 class="signature " id="table?-instance_method">
|
1720
|
+
|
1721
|
+
#<strong>table?</strong>(table_name) ⇒ <tt><span class='object_link'><a href="Boolean.html" title="DWH::Adapters::Boolean (class)">Boolean</a></span></tt>
|
1722
|
+
|
1723
|
+
|
1724
|
+
|
1725
|
+
|
1726
|
+
|
1727
|
+
</h3><div class="docstring">
|
1728
|
+
<div class="discussion">
|
1729
|
+
<p>Check if table exists in remote db.</p>
|
1730
|
+
|
1731
|
+
|
1732
|
+
</div>
|
1733
|
+
</div>
|
1734
|
+
<div class="tags">
|
1735
|
+
<p class="tag_title">Parameters:</p>
|
1736
|
+
<ul class="param">
|
1737
|
+
|
1738
|
+
<li>
|
1739
|
+
|
1740
|
+
<span class='name'>qualifiers</span>
|
1741
|
+
|
1742
|
+
|
1743
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1744
|
+
|
1745
|
+
|
1746
|
+
|
1747
|
+
—
|
1748
|
+
<div class='inline'><p>a customizable set of options</p>
|
1749
|
+
</div>
|
1750
|
+
|
1751
|
+
</li>
|
1752
|
+
|
1753
|
+
</ul>
|
1754
|
+
|
1755
|
+
|
1756
|
+
|
1757
|
+
|
1758
|
+
|
1759
|
+
<p class="tag_title">Returns:</p>
|
1760
|
+
<ul class="return">
|
1761
|
+
|
1762
|
+
<li>
|
1763
|
+
|
1764
|
+
|
1765
|
+
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="DWH::Adapters::Boolean (class)">Boolean</a></span></tt>)</span>
|
1766
|
+
|
1767
|
+
|
1768
|
+
|
1769
|
+
</li>
|
1770
|
+
|
1771
|
+
</ul>
|
1772
|
+
|
1773
|
+
</div><table class="source_code">
|
1774
|
+
<tr>
|
1775
|
+
<td>
|
1776
|
+
<pre class="lines">
|
1777
|
+
|
1778
|
+
|
1779
|
+
113
|
1780
|
+
114
|
1781
|
+
115</pre>
|
1782
|
+
</td>
|
1783
|
+
<td>
|
1784
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 113</span>
|
1785
|
+
|
1786
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_table?'>table?</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
1787
|
+
<span class='id identifier rubyid_tables'>tables</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
1788
|
+
<span class='kw'>end</span></pre>
|
1789
|
+
</td>
|
1790
|
+
</tr>
|
1791
|
+
</table>
|
1792
|
+
</div>
|
1793
|
+
|
1794
|
+
<div class="method_details ">
|
1795
|
+
<h3 class="signature " id="tables-instance_method">
|
1796
|
+
|
1797
|
+
#<strong>tables</strong>(**qualifiers) ⇒ <tt>Array<String></tt>
|
1798
|
+
|
1799
|
+
|
1800
|
+
|
1801
|
+
|
1802
|
+
|
1803
|
+
</h3><div class="docstring">
|
1804
|
+
<div class="discussion">
|
1805
|
+
<p>Get all tables available in the
|
1806
|
+
target db. It will use the default catalog and schema
|
1807
|
+
config only specified here.</p>
|
1808
|
+
|
1809
|
+
|
1810
|
+
</div>
|
1811
|
+
</div>
|
1812
|
+
<div class="tags">
|
1813
|
+
<p class="tag_title">Parameters:</p>
|
1814
|
+
<ul class="param">
|
1815
|
+
|
1816
|
+
<li>
|
1817
|
+
|
1818
|
+
<span class='name'>qualifiers</span>
|
1819
|
+
|
1820
|
+
|
1821
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1822
|
+
|
1823
|
+
|
1824
|
+
|
1825
|
+
—
|
1826
|
+
<div class='inline'><p>a customizable set of options</p>
|
1827
|
+
</div>
|
1828
|
+
|
1829
|
+
</li>
|
1830
|
+
|
1831
|
+
</ul>
|
1832
|
+
|
1833
|
+
|
1834
|
+
|
1835
|
+
|
1836
|
+
<p class="tag_title">Options Hash (<tt>**qualifiers</tt>):</p>
|
1837
|
+
<ul class="option">
|
1838
|
+
|
1839
|
+
<li>
|
1840
|
+
<span class="name">:catalog</span>
|
1841
|
+
<span class="type">(<tt>String</tt>)</span>
|
1842
|
+
<span class="default">
|
1843
|
+
|
1844
|
+
</span>
|
1845
|
+
|
1846
|
+
— <div class='inline'><p>optional catalog or equivalent name space.
|
1847
|
+
will be ignored if the adapter doesn’t support</p>
|
1848
|
+
</div>
|
1849
|
+
|
1850
|
+
</li>
|
1851
|
+
|
1852
|
+
<li>
|
1853
|
+
<span class="name">:schema</span>
|
1854
|
+
<span class="type">(<tt>String</tt>)</span>
|
1855
|
+
<span class="default">
|
1856
|
+
|
1857
|
+
</span>
|
1858
|
+
|
1859
|
+
— <div class='inline'><p>optional schema to scope to.
|
1860
|
+
will be ignored if the adapter doesn’t support</p>
|
1861
|
+
</div>
|
1862
|
+
|
1863
|
+
</li>
|
1864
|
+
|
1865
|
+
</ul>
|
1866
|
+
|
1867
|
+
|
1868
|
+
<p class="tag_title">Returns:</p>
|
1869
|
+
<ul class="return">
|
1870
|
+
|
1871
|
+
<li>
|
1872
|
+
|
1873
|
+
|
1874
|
+
<span class='type'>(<tt>Array<String></tt>)</span>
|
1875
|
+
|
1876
|
+
|
1877
|
+
|
1878
|
+
</li>
|
1879
|
+
|
1880
|
+
</ul>
|
1881
|
+
|
1882
|
+
</div><table class="source_code">
|
1883
|
+
<tr>
|
1884
|
+
<td>
|
1885
|
+
<pre class="lines">
|
1886
|
+
|
1887
|
+
|
1888
|
+
76
|
1889
|
+
77
|
1890
|
+
78
|
1891
|
+
79
|
1892
|
+
80
|
1893
|
+
81
|
1894
|
+
82
|
1895
|
+
83
|
1896
|
+
84
|
1897
|
+
85
|
1898
|
+
86
|
1899
|
+
87
|
1900
|
+
88
|
1901
|
+
89
|
1902
|
+
90
|
1903
|
+
91
|
1904
|
+
92</pre>
|
1905
|
+
</td>
|
1906
|
+
<td>
|
1907
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 76</span>
|
1908
|
+
|
1909
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_tables'>tables</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='rparen'>)</span>
|
1910
|
+
<span class='id identifier rubyid_change_current_database'>change_current_database</span><span class='lparen'>(</span><span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='lbracket'>[</span><span class='symbol'>:catalog</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
1911
|
+
<span class='id identifier rubyid_table_catalog'>table_catalog</span> <span class='op'>=</span> <span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='lbracket'>[</span><span class='symbol'>:catalog</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:database</span><span class='rbracket'>]</span>
|
1912
|
+
<span class='id identifier rubyid_table_schema_where'>table_schema_where</span> <span class='op'>=</span> <span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='lbracket'>[</span><span class='symbol'>:schema</span><span class='rbracket'>]</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> AND table_schema = '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='lbracket'>[</span><span class='symbol'>:schema</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>'</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
1913
|
+
|
1914
|
+
<span class='id identifier rubyid_sql'>sql</span> <span class='op'>=</span> <span class='heredoc_beg'><<~SQL</span>
|
1915
|
+
<span class='tstring_content'> SELECT table_name
|
1916
|
+
</span><span class='tstring_content'> FROM information_schema.tables
|
1917
|
+
</span><span class='tstring_content'> WHERE table_catalog = '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_table_catalog'>table_catalog</span><span class='embexpr_end'>}</span><span class='tstring_content'>'
|
1918
|
+
</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_table_schema_where'>table_schema_where</span><span class='embexpr_end'>}</span><span class='tstring_content'>
|
1919
|
+
</span><span class='heredoc_end'> SQL
|
1920
|
+
</span>
|
1921
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span>
|
1922
|
+
<span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span>
|
1923
|
+
<span class='kw'>ensure</span>
|
1924
|
+
<span class='id identifier rubyid_reset_current_database'>reset_current_database</span>
|
1925
|
+
<span class='kw'>end</span></pre>
|
1926
|
+
</td>
|
1927
|
+
</tr>
|
1928
|
+
</table>
|
1929
|
+
</div>
|
1930
|
+
|
1931
|
+
<div class="method_details ">
|
1932
|
+
<h3 class="signature " id="test_connection-instance_method">
|
1933
|
+
|
1934
|
+
#<strong>test_connection</strong>(raise_exception: false) ⇒ <tt><span class='object_link'><a href="Boolean.html" title="DWH::Adapters::Boolean (class)">Boolean</a></span></tt>
|
1935
|
+
|
1936
|
+
|
1937
|
+
|
1938
|
+
|
1939
|
+
|
1940
|
+
</h3><div class="docstring">
|
1941
|
+
<div class="discussion">
|
1942
|
+
<p>Tests the connection to the target database and returns true
|
1943
|
+
if successful, or raise Exception or false
|
1944
|
+
connection object or self</p>
|
1945
|
+
|
1946
|
+
|
1947
|
+
</div>
|
1948
|
+
</div>
|
1949
|
+
<div class="tags">
|
1950
|
+
|
1951
|
+
<p class="tag_title">Returns:</p>
|
1952
|
+
<ul class="return">
|
1953
|
+
|
1954
|
+
<li>
|
1955
|
+
|
1956
|
+
|
1957
|
+
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="DWH::Adapters::Boolean (class)">Boolean</a></span></tt>)</span>
|
1958
|
+
|
1959
|
+
|
1960
|
+
|
1961
|
+
</li>
|
1962
|
+
|
1963
|
+
</ul>
|
1964
|
+
<p class="tag_title">Raises:</p>
|
1965
|
+
<ul class="raise">
|
1966
|
+
|
1967
|
+
<li>
|
1968
|
+
|
1969
|
+
|
1970
|
+
<span class='type'>(<tt><span class='object_link'><a href="../ConnectionError.html" title="DWH::ConnectionError (class)">ConnectionError</a></span></tt>)</span>
|
1971
|
+
|
1972
|
+
|
1973
|
+
|
1974
|
+
—
|
1975
|
+
<div class='inline'><p>when a connection cannot be made</p>
|
1976
|
+
</div>
|
1977
|
+
|
1978
|
+
</li>
|
1979
|
+
|
1980
|
+
</ul>
|
1981
|
+
|
1982
|
+
</div><table class="source_code">
|
1983
|
+
<tr>
|
1984
|
+
<td>
|
1985
|
+
<pre class="lines">
|
1986
|
+
|
1987
|
+
|
1988
|
+
66
|
1989
|
+
67
|
1990
|
+
68
|
1991
|
+
69
|
1992
|
+
70
|
1993
|
+
71
|
1994
|
+
72
|
1995
|
+
73</pre>
|
1996
|
+
</td>
|
1997
|
+
<td>
|
1998
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 66</span>
|
1999
|
+
|
2000
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_test_connection'>test_connection</span><span class='lparen'>(</span><span class='label'>raise_exception:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
2001
|
+
<span class='id identifier rubyid_connection'>connection</span>
|
2002
|
+
<span class='kw'>true</span>
|
2003
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
2004
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../ConnectionError.html" title="DWH::ConnectionError (class)">ConnectionError</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_exception'>raise_exception</span>
|
2005
|
+
|
2006
|
+
<span class='kw'>false</span>
|
2007
|
+
<span class='kw'>end</span></pre>
|
2008
|
+
</td>
|
2009
|
+
</tr>
|
2010
|
+
</table>
|
2011
|
+
</div>
|
2012
|
+
|
2013
|
+
<div class="method_details ">
|
2014
|
+
<h3 class="signature " id="valid_config?-instance_method">
|
2015
|
+
|
2016
|
+
#<strong>valid_config?</strong> ⇒ <tt><span class='object_link'><a href="Boolean.html" title="DWH::Adapters::Boolean (class)">Boolean</a></span></tt>
|
2017
|
+
|
2018
|
+
|
2019
|
+
|
2020
|
+
|
2021
|
+
|
2022
|
+
</h3><div class="docstring">
|
2023
|
+
<div class="discussion">
|
2024
|
+
|
2025
|
+
|
2026
|
+
|
2027
|
+
</div>
|
2028
|
+
</div>
|
2029
|
+
<div class="tags">
|
2030
|
+
|
2031
|
+
<p class="tag_title">Returns:</p>
|
2032
|
+
<ul class="return">
|
2033
|
+
|
2034
|
+
<li>
|
2035
|
+
|
2036
|
+
|
2037
|
+
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="DWH::Adapters::Boolean (class)">Boolean</a></span></tt>)</span>
|
2038
|
+
|
2039
|
+
|
2040
|
+
|
2041
|
+
</li>
|
2042
|
+
|
2043
|
+
</ul>
|
2044
|
+
|
2045
|
+
</div><table class="source_code">
|
2046
|
+
<tr>
|
2047
|
+
<td>
|
2048
|
+
<pre class="lines">
|
2049
|
+
|
2050
|
+
|
2051
|
+
233
|
2052
|
+
234
|
2053
|
+
235
|
2054
|
+
236
|
2055
|
+
237
|
2056
|
+
238</pre>
|
2057
|
+
</td>
|
2058
|
+
<td>
|
2059
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/sql_server.rb', line 233</span>
|
2060
|
+
|
2061
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_valid_config?'>valid_config?</span>
|
2062
|
+
<span class='kw'>super</span>
|
2063
|
+
<span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>tiny_tds</span><span class='tstring_end'>'</span></span>
|
2064
|
+
<span class='kw'>rescue</span> <span class='const'>LoadError</span>
|
2065
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../ConfigError.html" title="DWH::ConfigError (class)">ConfigError</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Required 'tiny_tds' gem missing. Please add it to your Gemfile.</span><span class='tstring_end'>"</span></span>
|
2066
|
+
<span class='kw'>end</span></pre>
|
2067
|
+
</td>
|
2068
|
+
</tr>
|
2069
|
+
</table>
|
2070
|
+
</div>
|
2071
|
+
|
2072
|
+
</div>
|
2073
|
+
|
2074
|
+
</div>
|
2075
|
+
|
2076
|
+
<div id="footer">
|
2077
|
+
Generated on Fri Aug 22 08:31:22 2025 by
|
2078
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2079
|
+
0.9.37 (ruby-3.4.4).
|
2080
|
+
</div>
|
2081
|
+
|
2082
|
+
</div>
|
2083
|
+
</body>
|
2084
|
+
</html>
|