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,1704 @@
|
|
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::MySql
|
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::MySql";
|
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 (M)</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">MySql</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::MySql
|
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::MySql</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/my_sql.rb</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
<p>MySql Adapter. To use this adapter make sure you have the
|
107
|
+
<a href="https://github.com/brianmario/mysql2" target="_parent" title="MySql2 Gem">MySql2 Gem</a> installed. You
|
108
|
+
can also pass additional connection properties via <span class='object_link'><a href="Adapter.html#extra_connection_params-instance_method" title="DWH::Adapters::Adapter#extra_connection_params (method)">Adapter#extra_connection_params</a></span>
|
109
|
+
config property.</p>
|
110
|
+
|
111
|
+
<p>MySql concept of database maps to schema in this adapter. This is only important
|
112
|
+
for the metadata methods where you want to pull up tables from a different
|
113
|
+
database (aka schema).</p>
|
114
|
+
|
115
|
+
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
<div class="tags">
|
119
|
+
|
120
|
+
<div class="examples">
|
121
|
+
<h4 class="tag_title">Examples:</h4>
|
122
|
+
|
123
|
+
|
124
|
+
<h5 class="example_title"><div class='inline'><p>Connecting to Localhost</p>
|
125
|
+
</div></h5>
|
126
|
+
|
127
|
+
<pre class="example code"><code>Please use 127.0.0.1 when using a local docker instance to run MySQl.
|
128
|
+
Otherwise the Gem will try to connect over unix socket.
|
129
|
+
|
130
|
+
DWH.create(:mysql, { host: '127.0.0.1', databse: 'mydb', username: 'me', password: 'mypwd', client_name: 'Strata CLI'})</code></pre>
|
131
|
+
|
132
|
+
|
133
|
+
<h5 class="example_title"><div class='inline'><p>Connecting with SSL</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'>:mysql</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'>127.0.0.1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>databse:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>mydb</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
137
|
+
<span class='label'>username:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>me</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>password:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>mypwd</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>ssl:</span> <span class='kw'>true</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='comment'># this will default ssl_mode to required</span></code></pre>
|
138
|
+
|
139
|
+
|
140
|
+
<h5 class="example_title"><div class='inline'><p>Modify the SSL mode. All extra ssl config can be passed this way.</p>
|
141
|
+
</div></h5>
|
142
|
+
|
143
|
+
<pre class="example code"><code>DWH.create(:mysql, { host: '127.0.0.1', databse: 'mydb',
|
144
|
+
username: 'me', password: 'mypwd', ssl: true,
|
145
|
+
extra_connection_params: {ssl_mode: "verify"})</code></pre>
|
146
|
+
|
147
|
+
</div>
|
148
|
+
|
149
|
+
|
150
|
+
</div>
|
151
|
+
|
152
|
+
|
153
|
+
<h2>Constant Summary</h2>
|
154
|
+
|
155
|
+
<h3 class="inherited">Constants included
|
156
|
+
from <span class='object_link'><a href="../Settings.html" title="DWH::Settings (module)">Settings</a></span></h3>
|
157
|
+
<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>
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<h3 class="inherited">Constants included
|
162
|
+
from <span class='object_link'><a href="../Functions/Dates.html" title="DWH::Functions::Dates (module)">Functions::Dates</a></span></h3>
|
163
|
+
<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>
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
<h2>Instance Attribute Summary</h2>
|
169
|
+
|
170
|
+
<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Adapter.html" title="DWH::Adapters::Adapter (class)">Adapter</a></span></h3>
|
171
|
+
<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>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<h3 class="inherited">Attributes included from <span class='object_link'><a href="../Settings.html" title="DWH::Settings (module)">Settings</a></span></h3>
|
176
|
+
<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>
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
<h2>
|
181
|
+
Instance Method Summary
|
182
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
183
|
+
</h2>
|
184
|
+
|
185
|
+
<ul class="summary">
|
186
|
+
|
187
|
+
<li class="public ">
|
188
|
+
<span class="summary_signature">
|
189
|
+
|
190
|
+
<a href="#connection-instance_method" title="#connection (instance method)">#<strong>connection</strong> ⇒ Object </a>
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
</span>
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
<span class="summary_desc"><div class='inline'><p>Creates a connection to the target database and returns the connection object or self.</p>
|
205
|
+
</div></span>
|
206
|
+
|
207
|
+
</li>
|
208
|
+
|
209
|
+
|
210
|
+
<li class="public ">
|
211
|
+
<span class="summary_signature">
|
212
|
+
|
213
|
+
<a href="#execute-instance_method" title="#execute (instance method)">#<strong>execute</strong>(sql, format: :array, retries: 0) ⇒ Array<Array>, ... </a>
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
</span>
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
<span class="summary_desc"><div class='inline'><p>Execute sql on the target database.</p>
|
228
|
+
</div></span>
|
229
|
+
|
230
|
+
</li>
|
231
|
+
|
232
|
+
|
233
|
+
<li class="public ">
|
234
|
+
<span class="summary_signature">
|
235
|
+
|
236
|
+
<a href="#execute_stream-instance_method" title="#execute_stream (instance method)">#<strong>execute_stream</strong>(sql, io, stats: nil, retries: 0) ⇒ IO </a>
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
</span>
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
<span class="summary_desc"><div class='inline'><p>Execute sql and stream responses back.</p>
|
251
|
+
</div></span>
|
252
|
+
|
253
|
+
</li>
|
254
|
+
|
255
|
+
|
256
|
+
<li class="public ">
|
257
|
+
<span class="summary_signature">
|
258
|
+
|
259
|
+
<a href="#metadata-instance_method" title="#metadata (instance method)">#<strong>metadata</strong>(table, **qualifiers) ⇒ DWH::Table </a>
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
</span>
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
<span class="summary_desc"><div class='inline'><p>Get the schema structure of a given a given table_name.</p>
|
274
|
+
</div></span>
|
275
|
+
|
276
|
+
</li>
|
277
|
+
|
278
|
+
|
279
|
+
<li class="public ">
|
280
|
+
<span class="summary_signature">
|
281
|
+
|
282
|
+
<a href="#stats-instance_method" title="#stats (instance method)">#<strong>stats</strong>(table, date_column: nil, **qualifiers) ⇒ DWH::Table </a>
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
</span>
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
<span class="summary_desc"><div class='inline'><p>Returns basic stats of a given table.</p>
|
297
|
+
</div></span>
|
298
|
+
|
299
|
+
</li>
|
300
|
+
|
301
|
+
|
302
|
+
<li class="public ">
|
303
|
+
<span class="summary_signature">
|
304
|
+
|
305
|
+
<a href="#stream-instance_method" title="#stream (instance method)">#<strong>stream</strong>(sql) {|chunk| ... } ⇒ Object </a>
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
</span>
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
<span class="summary_desc"><div class='inline'><p>Executes the given sql and yields the streamed results to the given block.</p>
|
320
|
+
</div></span>
|
321
|
+
|
322
|
+
</li>
|
323
|
+
|
324
|
+
|
325
|
+
<li class="public ">
|
326
|
+
<span class="summary_signature">
|
327
|
+
|
328
|
+
<a href="#tables-instance_method" title="#tables (instance method)">#<strong>tables</strong>(**qualifiers) ⇒ Array<String> </a>
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
</span>
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
<span class="summary_desc"><div class='inline'><p>Get all tables available in the target db.</p>
|
343
|
+
</div></span>
|
344
|
+
|
345
|
+
</li>
|
346
|
+
|
347
|
+
|
348
|
+
<li class="public ">
|
349
|
+
<span class="summary_signature">
|
350
|
+
|
351
|
+
<a href="#test_connection-instance_method" title="#test_connection (instance method)">#<strong>test_connection</strong>(raise_exception: false) ⇒ Boolean </a>
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
</span>
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
<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>
|
366
|
+
</div></span>
|
367
|
+
|
368
|
+
</li>
|
369
|
+
|
370
|
+
|
371
|
+
<li class="public ">
|
372
|
+
<span class="summary_signature">
|
373
|
+
|
374
|
+
<a href="#truncate_date-instance_method" title="#truncate_date (instance method)">#<strong>truncate_date</strong>(unit, exp) ⇒ Object </a>
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
</span>
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
<span class="summary_desc"><div class='inline'><p>Custom date truncation implementation.</p>
|
389
|
+
</div></span>
|
390
|
+
|
391
|
+
</li>
|
392
|
+
|
393
|
+
|
394
|
+
</ul>
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="Adapter.html" title="DWH::Adapters::Adapter (class)">Adapter</a></span></h3>
|
407
|
+
<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#table%3F-instance_method" title="DWH::Adapters::Adapter#table? (method)">#table?</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>
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Settings.html" title="DWH::Settings (module)">Settings</a></span></h3>
|
418
|
+
<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>
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Logger.html" title="DWH::Logger (module)">Logger</a></span></h3>
|
429
|
+
<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>
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Behaviors.html" title="DWH::Behaviors (module)">Behaviors</a></span></h3>
|
440
|
+
<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>
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Functions.html" title="DWH::Functions (module)">Functions</a></span></h3>
|
451
|
+
<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>
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
<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>
|
462
|
+
<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>
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
<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>
|
473
|
+
<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>
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
<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>
|
484
|
+
<p class="inherited"><span class='object_link'><a href="../Functions/ExtractDatePart.html#extract_day_name-instance_method" title="DWH::Functions::ExtractDatePart#extract_day_name (method)">#extract_day_name</a></span>, <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_month_name-instance_method" title="DWH::Functions::ExtractDatePart#extract_month_name (method)">#extract_month_name</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>
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
<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>
|
495
|
+
<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#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>
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Capabilities.html" title="DWH::Capabilities (module)">Capabilities</a></span></h3>
|
506
|
+
<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>
|
507
|
+
<div id="constructor_details" class="method_details_list">
|
508
|
+
<h2>Constructor Details</h2>
|
509
|
+
|
510
|
+
<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>
|
511
|
+
|
512
|
+
</div>
|
513
|
+
|
514
|
+
|
515
|
+
<div id="instance_method_details" class="method_details_list">
|
516
|
+
<h2>Instance Method Details</h2>
|
517
|
+
|
518
|
+
|
519
|
+
<div class="method_details first">
|
520
|
+
<h3 class="signature first" id="connection-instance_method">
|
521
|
+
|
522
|
+
#<strong>connection</strong> ⇒ <tt>Object</tt>
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
</h3><div class="docstring">
|
529
|
+
<div class="discussion">
|
530
|
+
<p>Creates a connection to the target database and returns the
|
531
|
+
connection object or self</p>
|
532
|
+
|
533
|
+
|
534
|
+
</div>
|
535
|
+
</div>
|
536
|
+
<div class="tags">
|
537
|
+
|
538
|
+
|
539
|
+
</div><table class="source_code">
|
540
|
+
<tr>
|
541
|
+
<td>
|
542
|
+
<pre class="lines">
|
543
|
+
|
544
|
+
|
545
|
+
37
|
546
|
+
38
|
547
|
+
39
|
548
|
+
40
|
549
|
+
41
|
550
|
+
42
|
551
|
+
43
|
552
|
+
44
|
553
|
+
45
|
554
|
+
46
|
555
|
+
47
|
556
|
+
48
|
557
|
+
49
|
558
|
+
50
|
559
|
+
51
|
560
|
+
52
|
561
|
+
53
|
562
|
+
54
|
563
|
+
55
|
564
|
+
56
|
565
|
+
57
|
566
|
+
58
|
567
|
+
59
|
568
|
+
60
|
569
|
+
61</pre>
|
570
|
+
</td>
|
571
|
+
<td>
|
572
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/my_sql.rb', line 37</span>
|
573
|
+
|
574
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_connection'>connection</span>
|
575
|
+
<span class='kw'>return</span> <span class='ivar'>@connection</span> <span class='kw'>if</span> <span class='ivar'>@connection</span>
|
576
|
+
|
577
|
+
<span class='id identifier rubyid_set_default_ssl_mode_if_needed'>set_default_ssl_mode_if_needed</span>
|
578
|
+
|
579
|
+
<span class='id identifier rubyid_properties'>properties</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
580
|
+
<span class='comment'># Connection Settings
|
581
|
+
</span> <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>
|
582
|
+
<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>
|
583
|
+
<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>
|
584
|
+
<span class='label'>port:</span> <span class='int'>3306</span><span class='comma'>,</span>
|
585
|
+
<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>
|
586
|
+
|
587
|
+
<span class='comment'># Timeout Settings
|
588
|
+
</span> <span class='label'>connect_timeout:</span> <span class='int'>10</span><span class='comma'>,</span>
|
589
|
+
<span class='label'>read_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>
|
590
|
+
<span class='label'>connect_attrs:</span> <span class='lbrace'>{</span>
|
591
|
+
<span class='label'>program:</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:client_name</span><span class='rbracket'>]</span>
|
592
|
+
<span class='rbrace'>}</span>
|
593
|
+
<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>
|
594
|
+
|
595
|
+
<span class='ivar'>@connection</span> <span class='op'>=</span> <span class='const'>Mysql2</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='id identifier rubyid_properties'>properties</span><span class='rparen'>)</span>
|
596
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
597
|
+
<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>
|
598
|
+
<span class='kw'>end</span></pre>
|
599
|
+
</td>
|
600
|
+
</tr>
|
601
|
+
</table>
|
602
|
+
</div>
|
603
|
+
|
604
|
+
<div class="method_details ">
|
605
|
+
<h3 class="signature " id="execute-instance_method">
|
606
|
+
|
607
|
+
#<strong>execute</strong>(sql, format: :array, retries: 0) ⇒ <tt>Array<Array></tt>, ...
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
|
613
|
+
</h3><div class="docstring">
|
614
|
+
<div class="discussion">
|
615
|
+
<p>Execute sql on the target database.</p>
|
616
|
+
|
617
|
+
|
618
|
+
</div>
|
619
|
+
</div>
|
620
|
+
<div class="tags">
|
621
|
+
<p class="tag_title">Parameters:</p>
|
622
|
+
<ul class="param">
|
623
|
+
|
624
|
+
<li>
|
625
|
+
|
626
|
+
<span class='name'>sql</span>
|
627
|
+
|
628
|
+
|
629
|
+
<span class='type'>(<tt>String</tt>)</span>
|
630
|
+
|
631
|
+
|
632
|
+
|
633
|
+
—
|
634
|
+
<div class='inline'><p>actual sql</p>
|
635
|
+
</div>
|
636
|
+
|
637
|
+
</li>
|
638
|
+
|
639
|
+
<li>
|
640
|
+
|
641
|
+
<span class='name'>format</span>
|
642
|
+
|
643
|
+
|
644
|
+
<span class='type'>(<tt>Symbol</tt>, <tt>String</tt>)</span>
|
645
|
+
|
646
|
+
|
647
|
+
<em class="default">(defaults to: <tt>:array</tt>)</em>
|
648
|
+
|
649
|
+
|
650
|
+
—
|
651
|
+
<div class='inline'><p>return format type
|
652
|
+
- array returns array of array
|
653
|
+
- object returns array of Hashes
|
654
|
+
- csv returns as csv
|
655
|
+
- native returns the native result from any clients used
|
656
|
+
- For example: Postgres using pg client will return PG::Result
|
657
|
+
- Http clients will returns the HTTP response object</p>
|
658
|
+
</div>
|
659
|
+
|
660
|
+
</li>
|
661
|
+
|
662
|
+
<li>
|
663
|
+
|
664
|
+
<span class='name'>retries</span>
|
665
|
+
|
666
|
+
|
667
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
668
|
+
|
669
|
+
|
670
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
671
|
+
|
672
|
+
|
673
|
+
—
|
674
|
+
<div class='inline'><p>number of retries in case of failure. Default is 0</p>
|
675
|
+
</div>
|
676
|
+
|
677
|
+
</li>
|
678
|
+
|
679
|
+
</ul>
|
680
|
+
|
681
|
+
<p class="tag_title">Returns:</p>
|
682
|
+
<ul class="return">
|
683
|
+
|
684
|
+
<li>
|
685
|
+
|
686
|
+
|
687
|
+
<span class='type'>(<tt>Array<Array></tt>, <tt>Hash</tt>, <tt>CSV</tt>, <tt>Native</tt>)</span>
|
688
|
+
|
689
|
+
|
690
|
+
|
691
|
+
</li>
|
692
|
+
|
693
|
+
</ul>
|
694
|
+
<p class="tag_title">Raises:</p>
|
695
|
+
<ul class="raise">
|
696
|
+
|
697
|
+
<li>
|
698
|
+
|
699
|
+
|
700
|
+
<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>
|
701
|
+
|
702
|
+
|
703
|
+
|
704
|
+
</li>
|
705
|
+
|
706
|
+
</ul>
|
707
|
+
|
708
|
+
</div><table class="source_code">
|
709
|
+
<tr>
|
710
|
+
<td>
|
711
|
+
<pre class="lines">
|
712
|
+
|
713
|
+
|
714
|
+
134
|
715
|
+
135
|
716
|
+
136
|
717
|
+
137
|
718
|
+
138
|
719
|
+
139
|
720
|
+
140
|
721
|
+
141
|
722
|
+
142
|
723
|
+
143
|
724
|
+
144
|
725
|
+
145
|
726
|
+
146
|
727
|
+
147
|
728
|
+
148
|
729
|
+
149
|
730
|
+
150
|
731
|
+
151
|
732
|
+
152
|
733
|
+
153</pre>
|
734
|
+
</td>
|
735
|
+
<td>
|
736
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/my_sql.rb', line 134</span>
|
737
|
+
|
738
|
+
<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>
|
739
|
+
<span class='kw'>begin</span>
|
740
|
+
<span class='id identifier rubyid_as_param'>as_param</span> <span class='op'>=</span> <span class='qsymbols_beg'>%i[</span><span class='tstring_content'>array</span><span class='words_sep'> </span><span class='tstring_content'>object</span><span class='tstring_end'>]</span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_format'>format</span> <span class='op'>:</span> <span class='symbol'>:array</span>
|
741
|
+
<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_query'>query</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='comma'>,</span> <span class='label'>as:</span> <span class='id identifier rubyid_as_param'>as_param</span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
|
742
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
743
|
+
<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>
|
744
|
+
<span class='kw'>end</span>
|
745
|
+
|
746
|
+
<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>
|
747
|
+
<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>
|
748
|
+
<span class='kw'>when</span> <span class='symbol'>:array</span><span class='comma'>,</span> <span class='symbol'>:object</span>
|
749
|
+
<span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
|
750
|
+
<span class='kw'>when</span> <span class='symbol'>:csv</span>
|
751
|
+
<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>
|
752
|
+
<span class='kw'>when</span> <span class='symbol'>:native</span>
|
753
|
+
<span class='id identifier rubyid_result'>result</span>
|
754
|
+
<span class='kw'>else</span>
|
755
|
+
<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>
|
756
|
+
<span class='kw'>end</span>
|
757
|
+
<span class='kw'>end</span></pre>
|
758
|
+
</td>
|
759
|
+
</tr>
|
760
|
+
</table>
|
761
|
+
</div>
|
762
|
+
|
763
|
+
<div class="method_details ">
|
764
|
+
<h3 class="signature " id="execute_stream-instance_method">
|
765
|
+
|
766
|
+
#<strong>execute_stream</strong>(sql, io, stats: nil, retries: 0) ⇒ <tt>IO</tt>
|
767
|
+
|
768
|
+
|
769
|
+
|
770
|
+
|
771
|
+
|
772
|
+
</h3><div class="docstring">
|
773
|
+
<div class="discussion">
|
774
|
+
<p>Execute sql and stream responses back. Data is writtent out in CSV format
|
775
|
+
to the provided IO object.</p>
|
776
|
+
|
777
|
+
|
778
|
+
</div>
|
779
|
+
</div>
|
780
|
+
<div class="tags">
|
781
|
+
<p class="tag_title">Parameters:</p>
|
782
|
+
<ul class="param">
|
783
|
+
|
784
|
+
<li>
|
785
|
+
|
786
|
+
<span class='name'>sql</span>
|
787
|
+
|
788
|
+
|
789
|
+
<span class='type'>(<tt>String</tt>)</span>
|
790
|
+
|
791
|
+
|
792
|
+
|
793
|
+
—
|
794
|
+
<div class='inline'><p>actual sql</p>
|
795
|
+
</div>
|
796
|
+
|
797
|
+
</li>
|
798
|
+
|
799
|
+
<li>
|
800
|
+
|
801
|
+
<span class='name'>io</span>
|
802
|
+
|
803
|
+
|
804
|
+
<span class='type'>(<tt>IO</tt>)</span>
|
805
|
+
|
806
|
+
|
807
|
+
|
808
|
+
—
|
809
|
+
<div class='inline'><p>IO object to write records to</p>
|
810
|
+
</div>
|
811
|
+
|
812
|
+
</li>
|
813
|
+
|
814
|
+
<li>
|
815
|
+
|
816
|
+
<span class='name'>stats</span>
|
817
|
+
|
818
|
+
|
819
|
+
<span class='type'>(<tt><span class='object_link'><a href="../StreamingStats.html" title="DWH::StreamingStats (class)">StreamingStats</a></span></tt>)</span>
|
820
|
+
|
821
|
+
|
822
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
823
|
+
|
824
|
+
|
825
|
+
—
|
826
|
+
<div class='inline'><p>collect stats and preview data this is optional</p>
|
827
|
+
</div>
|
828
|
+
|
829
|
+
</li>
|
830
|
+
|
831
|
+
<li>
|
832
|
+
|
833
|
+
<span class='name'>retries</span>
|
834
|
+
|
835
|
+
|
836
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
837
|
+
|
838
|
+
|
839
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
840
|
+
|
841
|
+
|
842
|
+
—
|
843
|
+
<div class='inline'><p>number of retries in case of failure</p>
|
844
|
+
</div>
|
845
|
+
|
846
|
+
</li>
|
847
|
+
|
848
|
+
</ul>
|
849
|
+
|
850
|
+
<p class="tag_title">Returns:</p>
|
851
|
+
<ul class="return">
|
852
|
+
|
853
|
+
<li>
|
854
|
+
|
855
|
+
|
856
|
+
<span class='type'>(<tt>IO</tt>)</span>
|
857
|
+
|
858
|
+
|
859
|
+
|
860
|
+
</li>
|
861
|
+
|
862
|
+
</ul>
|
863
|
+
<p class="tag_title">Raises:</p>
|
864
|
+
<ul class="raise">
|
865
|
+
|
866
|
+
<li>
|
867
|
+
|
868
|
+
|
869
|
+
<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>
|
870
|
+
|
871
|
+
|
872
|
+
|
873
|
+
</li>
|
874
|
+
|
875
|
+
</ul>
|
876
|
+
|
877
|
+
</div><table class="source_code">
|
878
|
+
<tr>
|
879
|
+
<td>
|
880
|
+
<pre class="lines">
|
881
|
+
|
882
|
+
|
883
|
+
156
|
884
|
+
157
|
885
|
+
158
|
886
|
+
159
|
887
|
+
160
|
888
|
+
161
|
889
|
+
162
|
890
|
+
163
|
891
|
+
164
|
892
|
+
165
|
893
|
+
166
|
894
|
+
167
|
895
|
+
168
|
896
|
+
169
|
897
|
+
170
|
898
|
+
171
|
899
|
+
172</pre>
|
900
|
+
</td>
|
901
|
+
<td>
|
902
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/my_sql.rb', line 156</span>
|
903
|
+
|
904
|
+
<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>
|
905
|
+
<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>
|
906
|
+
<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>
|
907
|
+
<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_query'>query</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='comma'>,</span> <span class='label'>stream:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>as:</span> <span class='symbol'>:array</span><span class='comma'>,</span> <span class='label'>cache_rows:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
908
|
+
<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>
|
909
|
+
<span class='id identifier rubyid_result'>result</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_row'>row</span><span class='op'>|</span>
|
910
|
+
<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>
|
911
|
+
<span class='id identifier rubyid_stats'>stats</span> <span class='op'><<</span> <span class='id identifier rubyid_row'>row</span> <span class='kw'>if</span> <span class='id identifier rubyid_stats'>stats</span>
|
912
|
+
<span class='kw'>end</span>
|
913
|
+
<span class='kw'>end</span>
|
914
|
+
<span class='kw'>end</span>
|
915
|
+
|
916
|
+
<span class='id identifier rubyid_io'>io</span><span class='period'>.</span><span class='id identifier rubyid_rewind'>rewind</span>
|
917
|
+
<span class='id identifier rubyid_io'>io</span>
|
918
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
919
|
+
<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>
|
920
|
+
<span class='kw'>end</span></pre>
|
921
|
+
</td>
|
922
|
+
</tr>
|
923
|
+
</table>
|
924
|
+
</div>
|
925
|
+
|
926
|
+
<div class="method_details ">
|
927
|
+
<h3 class="signature " id="metadata-instance_method">
|
928
|
+
|
929
|
+
#<strong>metadata</strong>(table, **qualifiers) ⇒ <tt><span class='object_link'><a href="../Table.html" title="DWH::Table (class)">DWH::Table</a></span></tt>
|
930
|
+
|
931
|
+
|
932
|
+
|
933
|
+
|
934
|
+
|
935
|
+
</h3><div class="docstring">
|
936
|
+
<div class="discussion">
|
937
|
+
<p>Get the schema structure of a given a given table_name.
|
938
|
+
Pass in optional catalog and schema info.</p>
|
939
|
+
|
940
|
+
<p>Example:
|
941
|
+
metadata(“public.big_table”)
|
942
|
+
metadata(“big_table”)
|
943
|
+
metadata(“big_table”,schema: “public”)</p>
|
944
|
+
|
945
|
+
|
946
|
+
</div>
|
947
|
+
</div>
|
948
|
+
<div class="tags">
|
949
|
+
<p class="tag_title">Parameters:</p>
|
950
|
+
<ul class="param">
|
951
|
+
|
952
|
+
<li>
|
953
|
+
|
954
|
+
<span class='name'>table</span>
|
955
|
+
|
956
|
+
|
957
|
+
<span class='type'>(<tt>String</tt>)</span>
|
958
|
+
|
959
|
+
|
960
|
+
|
961
|
+
—
|
962
|
+
<div class='inline'><ul>
|
963
|
+
<li>table name</li>
|
964
|
+
</ul>
|
965
|
+
</div>
|
966
|
+
|
967
|
+
</li>
|
968
|
+
|
969
|
+
<li>
|
970
|
+
|
971
|
+
<span class='name'>qualifiers</span>
|
972
|
+
|
973
|
+
|
974
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
975
|
+
|
976
|
+
|
977
|
+
|
978
|
+
—
|
979
|
+
<div class='inline'><p>a customizable set of options</p>
|
980
|
+
</div>
|
981
|
+
|
982
|
+
</li>
|
983
|
+
|
984
|
+
</ul>
|
985
|
+
|
986
|
+
|
987
|
+
|
988
|
+
|
989
|
+
|
990
|
+
|
991
|
+
<p class="tag_title">Options Hash (<tt>**qualifiers</tt>):</p>
|
992
|
+
<ul class="option">
|
993
|
+
|
994
|
+
<li>
|
995
|
+
<span class="name">:catalog</span>
|
996
|
+
<span class="type">(<tt>String</tt>)</span>
|
997
|
+
<span class="default">
|
998
|
+
|
999
|
+
</span>
|
1000
|
+
|
1001
|
+
— <div class='inline'><p>optional catalog or equivalent name space.
|
1002
|
+
will be ignored if the adapter doesn’t support</p>
|
1003
|
+
</div>
|
1004
|
+
|
1005
|
+
</li>
|
1006
|
+
|
1007
|
+
<li>
|
1008
|
+
<span class="name">:schema</span>
|
1009
|
+
<span class="type">(<tt>String</tt>)</span>
|
1010
|
+
<span class="default">
|
1011
|
+
|
1012
|
+
</span>
|
1013
|
+
|
1014
|
+
— <div class='inline'><p>optional schema to scope to.
|
1015
|
+
will be ignored if the adapter doesn’t support</p>
|
1016
|
+
</div>
|
1017
|
+
|
1018
|
+
</li>
|
1019
|
+
|
1020
|
+
</ul>
|
1021
|
+
|
1022
|
+
|
1023
|
+
<p class="tag_title">Returns:</p>
|
1024
|
+
<ul class="return">
|
1025
|
+
|
1026
|
+
<li>
|
1027
|
+
|
1028
|
+
|
1029
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Table.html" title="DWH::Table (class)">DWH::Table</a></span></tt>)</span>
|
1030
|
+
|
1031
|
+
|
1032
|
+
|
1033
|
+
</li>
|
1034
|
+
|
1035
|
+
</ul>
|
1036
|
+
|
1037
|
+
</div><table class="source_code">
|
1038
|
+
<tr>
|
1039
|
+
<td>
|
1040
|
+
<pre class="lines">
|
1041
|
+
|
1042
|
+
|
1043
|
+
108
|
1044
|
+
109
|
1045
|
+
110
|
1046
|
+
111
|
1047
|
+
112
|
1048
|
+
113
|
1049
|
+
114
|
1050
|
+
115
|
1051
|
+
116
|
1052
|
+
117
|
1053
|
+
118
|
1054
|
+
119
|
1055
|
+
120
|
1056
|
+
121
|
1057
|
+
122
|
1058
|
+
123
|
1059
|
+
124
|
1060
|
+
125
|
1061
|
+
126
|
1062
|
+
127
|
1063
|
+
128
|
1064
|
+
129
|
1065
|
+
130
|
1066
|
+
131</pre>
|
1067
|
+
</td>
|
1068
|
+
<td>
|
1069
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/my_sql.rb', line 108</span>
|
1070
|
+
|
1071
|
+
<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>
|
1072
|
+
<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='label'>schema:</span> <span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='lbracket'>[</span><span class='symbol'>:schema</span><span class='rbracket'>]</span>
|
1073
|
+
<span class='id identifier rubyid_schema_where'>schema_where</span> <span class='op'>=</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='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='op'>:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
1074
|
+
|
1075
|
+
<span class='id identifier rubyid_sql'>sql</span> <span class='op'>=</span> <span class='heredoc_beg'><<-SQL</span>
|
1076
|
+
<span class='tstring_content'> SELECT column_name, data_type, character_maximum_length, numeric_precision,numeric_scale
|
1077
|
+
FROM information_schema.columns
|
1078
|
+
WHERE lower(table_name) = lower('</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'>')
|
1079
|
+
</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'>
|
1080
|
+
</span><span class='heredoc_end'> SQL
|
1081
|
+
</span>
|
1082
|
+
<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='symbol'>:object</span><span class='rparen'>)</span>
|
1083
|
+
<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>
|
1084
|
+
<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>
|
1085
|
+
<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>
|
1086
|
+
<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>
|
1087
|
+
<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>
|
1088
|
+
<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>
|
1089
|
+
<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>
|
1090
|
+
<span class='rparen'>)</span>
|
1091
|
+
<span class='kw'>end</span>
|
1092
|
+
|
1093
|
+
<span class='id identifier rubyid_db_table'>db_table</span>
|
1094
|
+
<span class='kw'>end</span></pre>
|
1095
|
+
</td>
|
1096
|
+
</tr>
|
1097
|
+
</table>
|
1098
|
+
</div>
|
1099
|
+
|
1100
|
+
<div class="method_details ">
|
1101
|
+
<h3 class="signature " id="stats-instance_method">
|
1102
|
+
|
1103
|
+
#<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>
|
1104
|
+
|
1105
|
+
|
1106
|
+
|
1107
|
+
|
1108
|
+
|
1109
|
+
</h3><div class="docstring">
|
1110
|
+
<div class="discussion">
|
1111
|
+
<p>Returns basic stats of a given table. Will typically include row_count,
|
1112
|
+
date_start, and date_end.</p>
|
1113
|
+
|
1114
|
+
|
1115
|
+
</div>
|
1116
|
+
</div>
|
1117
|
+
<div class="tags">
|
1118
|
+
|
1119
|
+
<div class="examples">
|
1120
|
+
<h4 class="tag_title">Examples:</h4>
|
1121
|
+
|
1122
|
+
|
1123
|
+
<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>
|
1124
|
+
<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>
|
1125
|
+
<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>
|
1126
|
+
|
1127
|
+
</div>
|
1128
|
+
<p class="tag_title">Parameters:</p>
|
1129
|
+
<ul class="param">
|
1130
|
+
|
1131
|
+
<li>
|
1132
|
+
|
1133
|
+
<span class='name'>table</span>
|
1134
|
+
|
1135
|
+
|
1136
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1137
|
+
|
1138
|
+
|
1139
|
+
|
1140
|
+
—
|
1141
|
+
<div class='inline'><p>table name</p>
|
1142
|
+
</div>
|
1143
|
+
|
1144
|
+
</li>
|
1145
|
+
|
1146
|
+
<li>
|
1147
|
+
|
1148
|
+
<span class='name'>date_column</span>
|
1149
|
+
|
1150
|
+
|
1151
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1152
|
+
|
1153
|
+
|
1154
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1155
|
+
|
1156
|
+
|
1157
|
+
—
|
1158
|
+
<div class='inline'><p>optional date column to use to find range</p>
|
1159
|
+
</div>
|
1160
|
+
|
1161
|
+
</li>
|
1162
|
+
|
1163
|
+
<li>
|
1164
|
+
|
1165
|
+
<span class='name'>qualifiers</span>
|
1166
|
+
|
1167
|
+
|
1168
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1169
|
+
|
1170
|
+
|
1171
|
+
|
1172
|
+
—
|
1173
|
+
<div class='inline'><p>a customizable set of options</p>
|
1174
|
+
</div>
|
1175
|
+
|
1176
|
+
</li>
|
1177
|
+
|
1178
|
+
</ul>
|
1179
|
+
|
1180
|
+
|
1181
|
+
|
1182
|
+
|
1183
|
+
|
1184
|
+
|
1185
|
+
|
1186
|
+
|
1187
|
+
<p class="tag_title">Options Hash (<tt>**qualifiers</tt>):</p>
|
1188
|
+
<ul class="option">
|
1189
|
+
|
1190
|
+
<li>
|
1191
|
+
<span class="name">:catalog</span>
|
1192
|
+
<span class="type">(<tt>String</tt>)</span>
|
1193
|
+
<span class="default">
|
1194
|
+
|
1195
|
+
</span>
|
1196
|
+
|
1197
|
+
— <div class='inline'><p>optional catalog or equivalent name space.
|
1198
|
+
will be ignored if the adapter doesn’t support</p>
|
1199
|
+
</div>
|
1200
|
+
|
1201
|
+
</li>
|
1202
|
+
|
1203
|
+
<li>
|
1204
|
+
<span class="name">:schema</span>
|
1205
|
+
<span class="type">(<tt>String</tt>)</span>
|
1206
|
+
<span class="default">
|
1207
|
+
|
1208
|
+
</span>
|
1209
|
+
|
1210
|
+
— <div class='inline'><p>optional schema to scope to.
|
1211
|
+
will be ignored if the adapter doesn’t support</p>
|
1212
|
+
</div>
|
1213
|
+
|
1214
|
+
</li>
|
1215
|
+
|
1216
|
+
</ul>
|
1217
|
+
|
1218
|
+
|
1219
|
+
<p class="tag_title">Returns:</p>
|
1220
|
+
<ul class="return">
|
1221
|
+
|
1222
|
+
<li>
|
1223
|
+
|
1224
|
+
|
1225
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Table.html" title="DWH::Table (class)">DWH::Table</a></span></tt>)</span>
|
1226
|
+
|
1227
|
+
|
1228
|
+
|
1229
|
+
</li>
|
1230
|
+
|
1231
|
+
</ul>
|
1232
|
+
<p class="tag_title">Raises:</p>
|
1233
|
+
<ul class="raise">
|
1234
|
+
|
1235
|
+
<li>
|
1236
|
+
|
1237
|
+
|
1238
|
+
<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>
|
1239
|
+
|
1240
|
+
|
1241
|
+
|
1242
|
+
</li>
|
1243
|
+
|
1244
|
+
</ul>
|
1245
|
+
|
1246
|
+
</div><table class="source_code">
|
1247
|
+
<tr>
|
1248
|
+
<td>
|
1249
|
+
<pre class="lines">
|
1250
|
+
|
1251
|
+
|
1252
|
+
89
|
1253
|
+
90
|
1254
|
+
91
|
1255
|
+
92
|
1256
|
+
93
|
1257
|
+
94
|
1258
|
+
95
|
1259
|
+
96
|
1260
|
+
97
|
1261
|
+
98
|
1262
|
+
99
|
1263
|
+
100
|
1264
|
+
101
|
1265
|
+
102
|
1266
|
+
103
|
1267
|
+
104
|
1268
|
+
105</pre>
|
1269
|
+
</td>
|
1270
|
+
<td>
|
1271
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/my_sql.rb', line 89</span>
|
1272
|
+
|
1273
|
+
<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>
|
1274
|
+
<span class='id identifier rubyid_table'>table</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='kw'>if</span> <span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='lbracket'>[</span><span class='symbol'>:schema</span><span class='rbracket'>]</span>
|
1275
|
+
<span class='id identifier rubyid_sql'>sql</span> <span class='op'>=</span> <span class='heredoc_beg'><<-SQL</span>
|
1276
|
+
<span class='tstring_content'> SELECT count(*) row_count
|
1277
|
+
</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'>
|
1278
|
+
</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'>
|
1279
|
+
FROM </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_table'>table</span><span class='embexpr_end'>}</span><span class='tstring_content'>
|
1280
|
+
</span><span class='heredoc_end'> SQL
|
1281
|
+
</span>
|
1282
|
+
<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_query'>query</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span>
|
1283
|
+
|
1284
|
+
<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>
|
1285
|
+
<span class='label'>row_count:</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</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>
|
1286
|
+
<span class='label'>date_start:</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</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>
|
1287
|
+
<span class='label'>date_end:</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</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>
|
1288
|
+
<span class='rparen'>)</span>
|
1289
|
+
<span class='kw'>end</span></pre>
|
1290
|
+
</td>
|
1291
|
+
</tr>
|
1292
|
+
</table>
|
1293
|
+
</div>
|
1294
|
+
|
1295
|
+
<div class="method_details ">
|
1296
|
+
<h3 class="signature " id="stream-instance_method">
|
1297
|
+
|
1298
|
+
#<strong>stream</strong>(sql) {|chunk| ... } ⇒ <tt>Object</tt>
|
1299
|
+
|
1300
|
+
|
1301
|
+
|
1302
|
+
|
1303
|
+
|
1304
|
+
</h3><div class="docstring">
|
1305
|
+
<div class="discussion">
|
1306
|
+
<p>Executes the given sql and yields the streamed results
|
1307
|
+
to the given block.</p>
|
1308
|
+
|
1309
|
+
|
1310
|
+
</div>
|
1311
|
+
</div>
|
1312
|
+
<div class="tags">
|
1313
|
+
<p class="tag_title">Parameters:</p>
|
1314
|
+
<ul class="param">
|
1315
|
+
|
1316
|
+
<li>
|
1317
|
+
|
1318
|
+
<span class='name'>sql</span>
|
1319
|
+
|
1320
|
+
|
1321
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1322
|
+
|
1323
|
+
|
1324
|
+
|
1325
|
+
—
|
1326
|
+
<div class='inline'><p>actual sql</p>
|
1327
|
+
</div>
|
1328
|
+
|
1329
|
+
</li>
|
1330
|
+
|
1331
|
+
</ul>
|
1332
|
+
|
1333
|
+
<p class="tag_title">Yields:</p>
|
1334
|
+
<ul class="yield">
|
1335
|
+
|
1336
|
+
<li>
|
1337
|
+
|
1338
|
+
|
1339
|
+
<span class='type'>(<tt>chunk</tt>)</span>
|
1340
|
+
|
1341
|
+
|
1342
|
+
|
1343
|
+
—
|
1344
|
+
<div class='inline'><p>Yields a streamed chunk as it streams in. The chunk type
|
1345
|
+
might vary depending on the target db and settings</p>
|
1346
|
+
</div>
|
1347
|
+
|
1348
|
+
</li>
|
1349
|
+
|
1350
|
+
</ul>
|
1351
|
+
<p class="tag_title">Raises:</p>
|
1352
|
+
<ul class="raise">
|
1353
|
+
|
1354
|
+
<li>
|
1355
|
+
|
1356
|
+
|
1357
|
+
<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>
|
1358
|
+
|
1359
|
+
|
1360
|
+
|
1361
|
+
</li>
|
1362
|
+
|
1363
|
+
</ul>
|
1364
|
+
|
1365
|
+
</div><table class="source_code">
|
1366
|
+
<tr>
|
1367
|
+
<td>
|
1368
|
+
<pre class="lines">
|
1369
|
+
|
1370
|
+
|
1371
|
+
175
|
1372
|
+
176
|
1373
|
+
177
|
1374
|
+
178
|
1375
|
+
179
|
1376
|
+
180
|
1377
|
+
181
|
1378
|
+
182</pre>
|
1379
|
+
</td>
|
1380
|
+
<td>
|
1381
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/my_sql.rb', line 175</span>
|
1382
|
+
|
1383
|
+
<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>
|
1384
|
+
<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>
|
1385
|
+
<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_query'>query</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='comma'>,</span> <span class='label'>as:</span> <span class='symbol'>:array</span><span class='comma'>,</span> <span class='label'>cache_rows:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1386
|
+
<span class='id identifier rubyid_result'>result</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_row'>row</span><span class='op'>|</span>
|
1387
|
+
<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>
|
1388
|
+
<span class='kw'>end</span>
|
1389
|
+
<span class='kw'>end</span>
|
1390
|
+
<span class='kw'>end</span></pre>
|
1391
|
+
</td>
|
1392
|
+
</tr>
|
1393
|
+
</table>
|
1394
|
+
</div>
|
1395
|
+
|
1396
|
+
<div class="method_details ">
|
1397
|
+
<h3 class="signature " id="tables-instance_method">
|
1398
|
+
|
1399
|
+
#<strong>tables</strong>(**qualifiers) ⇒ <tt>Array<String></tt>
|
1400
|
+
|
1401
|
+
|
1402
|
+
|
1403
|
+
|
1404
|
+
|
1405
|
+
</h3><div class="docstring">
|
1406
|
+
<div class="discussion">
|
1407
|
+
<p>Get all tables available in the
|
1408
|
+
target db. It will use the default catalog and schema
|
1409
|
+
config only specified here.</p>
|
1410
|
+
|
1411
|
+
|
1412
|
+
</div>
|
1413
|
+
</div>
|
1414
|
+
<div class="tags">
|
1415
|
+
<p class="tag_title">Parameters:</p>
|
1416
|
+
<ul class="param">
|
1417
|
+
|
1418
|
+
<li>
|
1419
|
+
|
1420
|
+
<span class='name'>qualifiers</span>
|
1421
|
+
|
1422
|
+
|
1423
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1424
|
+
|
1425
|
+
|
1426
|
+
|
1427
|
+
—
|
1428
|
+
<div class='inline'><p>a customizable set of options</p>
|
1429
|
+
</div>
|
1430
|
+
|
1431
|
+
</li>
|
1432
|
+
|
1433
|
+
</ul>
|
1434
|
+
|
1435
|
+
|
1436
|
+
|
1437
|
+
|
1438
|
+
<p class="tag_title">Options Hash (<tt>**qualifiers</tt>):</p>
|
1439
|
+
<ul class="option">
|
1440
|
+
|
1441
|
+
<li>
|
1442
|
+
<span class="name">:catalog</span>
|
1443
|
+
<span class="type">(<tt>String</tt>)</span>
|
1444
|
+
<span class="default">
|
1445
|
+
|
1446
|
+
</span>
|
1447
|
+
|
1448
|
+
— <div class='inline'><p>optional catalog or equivalent name space.
|
1449
|
+
will be ignored if the adapter doesn’t support</p>
|
1450
|
+
</div>
|
1451
|
+
|
1452
|
+
</li>
|
1453
|
+
|
1454
|
+
<li>
|
1455
|
+
<span class="name">:schema</span>
|
1456
|
+
<span class="type">(<tt>String</tt>)</span>
|
1457
|
+
<span class="default">
|
1458
|
+
|
1459
|
+
</span>
|
1460
|
+
|
1461
|
+
— <div class='inline'><p>optional schema to scope to.
|
1462
|
+
will be ignored if the adapter doesn’t support</p>
|
1463
|
+
</div>
|
1464
|
+
|
1465
|
+
</li>
|
1466
|
+
|
1467
|
+
</ul>
|
1468
|
+
|
1469
|
+
|
1470
|
+
<p class="tag_title">Returns:</p>
|
1471
|
+
<ul class="return">
|
1472
|
+
|
1473
|
+
<li>
|
1474
|
+
|
1475
|
+
|
1476
|
+
<span class='type'>(<tt>Array<String></tt>)</span>
|
1477
|
+
|
1478
|
+
|
1479
|
+
|
1480
|
+
</li>
|
1481
|
+
|
1482
|
+
</ul>
|
1483
|
+
|
1484
|
+
</div><table class="source_code">
|
1485
|
+
<tr>
|
1486
|
+
<td>
|
1487
|
+
<pre class="lines">
|
1488
|
+
|
1489
|
+
|
1490
|
+
74
|
1491
|
+
75
|
1492
|
+
76
|
1493
|
+
77
|
1494
|
+
78
|
1495
|
+
79
|
1496
|
+
80
|
1497
|
+
81
|
1498
|
+
82
|
1499
|
+
83
|
1500
|
+
84
|
1501
|
+
85
|
1502
|
+
86</pre>
|
1503
|
+
</td>
|
1504
|
+
<td>
|
1505
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/my_sql.rb', line 74</span>
|
1506
|
+
|
1507
|
+
<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>
|
1508
|
+
<span class='id identifier rubyid_schema'>schema</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='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:database</span><span class='rbracket'>]</span>
|
1509
|
+
<span class='id identifier rubyid_query'>query</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>
|
1510
|
+
SELECT
|
1511
|
+
t.table_name
|
1512
|
+
FROM information_schema.tables t
|
1513
|
+
WHERE t.table_schema = '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_schema'>schema</span><span class='embexpr_end'>}</span><span class='tstring_content'>'
|
1514
|
+
ORDER BY t.table_name
|
1515
|
+
</span><span class='tstring_end'>"</span></span>
|
1516
|
+
|
1517
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_connection'>connection</span><span class='period'>.</span><span class='id identifier rubyid_query'>query</span><span class='lparen'>(</span><span class='id identifier rubyid_query'>query</span><span class='comma'>,</span> <span class='label'>as:</span> <span class='symbol'>:array</span><span class='rparen'>)</span>
|
1518
|
+
<span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span>
|
1519
|
+
<span class='kw'>end</span></pre>
|
1520
|
+
</td>
|
1521
|
+
</tr>
|
1522
|
+
</table>
|
1523
|
+
</div>
|
1524
|
+
|
1525
|
+
<div class="method_details ">
|
1526
|
+
<h3 class="signature " id="test_connection-instance_method">
|
1527
|
+
|
1528
|
+
#<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>
|
1529
|
+
|
1530
|
+
|
1531
|
+
|
1532
|
+
|
1533
|
+
|
1534
|
+
</h3><div class="docstring">
|
1535
|
+
<div class="discussion">
|
1536
|
+
<p>Tests the connection to the target database and returns true
|
1537
|
+
if successful, or raise Exception or false
|
1538
|
+
connection object or self</p>
|
1539
|
+
|
1540
|
+
|
1541
|
+
</div>
|
1542
|
+
</div>
|
1543
|
+
<div class="tags">
|
1544
|
+
|
1545
|
+
<p class="tag_title">Returns:</p>
|
1546
|
+
<ul class="return">
|
1547
|
+
|
1548
|
+
<li>
|
1549
|
+
|
1550
|
+
|
1551
|
+
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="DWH::Adapters::Boolean (class)">Boolean</a></span></tt>)</span>
|
1552
|
+
|
1553
|
+
|
1554
|
+
|
1555
|
+
</li>
|
1556
|
+
|
1557
|
+
</ul>
|
1558
|
+
<p class="tag_title">Raises:</p>
|
1559
|
+
<ul class="raise">
|
1560
|
+
|
1561
|
+
<li>
|
1562
|
+
|
1563
|
+
|
1564
|
+
<span class='type'>(<tt><span class='object_link'><a href="../ConnectionError.html" title="DWH::ConnectionError (class)">ConnectionError</a></span></tt>)</span>
|
1565
|
+
|
1566
|
+
|
1567
|
+
|
1568
|
+
—
|
1569
|
+
<div class='inline'><p>when a connection cannot be made</p>
|
1570
|
+
</div>
|
1571
|
+
|
1572
|
+
</li>
|
1573
|
+
|
1574
|
+
</ul>
|
1575
|
+
|
1576
|
+
</div><table class="source_code">
|
1577
|
+
<tr>
|
1578
|
+
<td>
|
1579
|
+
<pre class="lines">
|
1580
|
+
|
1581
|
+
|
1582
|
+
64
|
1583
|
+
65
|
1584
|
+
66
|
1585
|
+
67
|
1586
|
+
68
|
1587
|
+
69
|
1588
|
+
70
|
1589
|
+
71</pre>
|
1590
|
+
</td>
|
1591
|
+
<td>
|
1592
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/my_sql.rb', line 64</span>
|
1593
|
+
|
1594
|
+
<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>
|
1595
|
+
<span class='id identifier rubyid_connection'>connection</span>
|
1596
|
+
<span class='kw'>true</span>
|
1597
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
1598
|
+
<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>
|
1599
|
+
|
1600
|
+
<span class='kw'>false</span>
|
1601
|
+
<span class='kw'>end</span></pre>
|
1602
|
+
</td>
|
1603
|
+
</tr>
|
1604
|
+
</table>
|
1605
|
+
</div>
|
1606
|
+
|
1607
|
+
<div class="method_details ">
|
1608
|
+
<h3 class="signature " id="truncate_date-instance_method">
|
1609
|
+
|
1610
|
+
#<strong>truncate_date</strong>(unit, exp) ⇒ <tt>Object</tt>
|
1611
|
+
|
1612
|
+
|
1613
|
+
|
1614
|
+
|
1615
|
+
|
1616
|
+
</h3><div class="docstring">
|
1617
|
+
<div class="discussion">
|
1618
|
+
<p>Custom date truncation implementation. MySql doesn’t offer
|
1619
|
+
a native function. We basially have to format it and convert back
|
1620
|
+
to date object.</p>
|
1621
|
+
|
1622
|
+
|
1623
|
+
</div>
|
1624
|
+
</div>
|
1625
|
+
<div class="tags">
|
1626
|
+
|
1627
|
+
|
1628
|
+
<p class="tag_title">See Also:</p>
|
1629
|
+
<ul class="see">
|
1630
|
+
|
1631
|
+
<li><span class='object_link'><a href="../Functions/Dates.html#truncate_date-instance_method" title="DWH::Functions::Dates#truncate_date (method)">Functions::Dates#truncate_date</a></span></li>
|
1632
|
+
|
1633
|
+
</ul>
|
1634
|
+
|
1635
|
+
</div><table class="source_code">
|
1636
|
+
<tr>
|
1637
|
+
<td>
|
1638
|
+
<pre class="lines">
|
1639
|
+
|
1640
|
+
|
1641
|
+
188
|
1642
|
+
189
|
1643
|
+
190
|
1644
|
+
191
|
1645
|
+
192
|
1646
|
+
193
|
1647
|
+
194
|
1648
|
+
195
|
1649
|
+
196
|
1650
|
+
197
|
1651
|
+
198
|
1652
|
+
199
|
1653
|
+
200
|
1654
|
+
201
|
1655
|
+
202
|
1656
|
+
203
|
1657
|
+
204
|
1658
|
+
205
|
1659
|
+
206
|
1660
|
+
207
|
1661
|
+
208</pre>
|
1662
|
+
</td>
|
1663
|
+
<td>
|
1664
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/my_sql.rb', line 188</span>
|
1665
|
+
|
1666
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_truncate_date'>truncate_date</span><span class='lparen'>(</span><span class='id identifier rubyid_unit'>unit</span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
|
1667
|
+
<span class='id identifier rubyid_unit'>unit</span> <span class='op'>=</span> <span class='id identifier rubyid_unit'>unit</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span>
|
1668
|
+
|
1669
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_unit'>unit</span>
|
1670
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>year</span><span class='tstring_end'>'</span></span>
|
1671
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>DATE(DATE_FORMAT(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exp'>exp</span><span class='embexpr_end'>}</span><span class='tstring_content'>, '%Y-01-01'))</span><span class='tstring_end'>"</span></span>
|
1672
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>quarter</span><span class='tstring_end'>'</span></span>
|
1673
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>DATE(DATE_ADD(DATE_FORMAT(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exp'>exp</span><span class='embexpr_end'>}</span><span class='tstring_content'>, '%Y-01-01'), INTERVAL (QUARTER(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exp'>exp</span><span class='embexpr_end'>}</span><span class='tstring_content'>) - 1) * 3 MONTH))</span><span class='tstring_end'>"</span></span>
|
1674
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>month</span><span class='tstring_end'>'</span></span>
|
1675
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>DATE(DATE_FORMAT(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exp'>exp</span><span class='embexpr_end'>}</span><span class='tstring_content'>, '%Y-%m-01'))</span><span class='tstring_end'>"</span></span>
|
1676
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>week</span><span class='tstring_end'>'</span></span>
|
1677
|
+
<span class='id identifier rubyid_gsk'>gsk</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_settings'>settings</span><span class='lbracket'>[</span><span class='symbol'>:week_start_day</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='embexpr_end'>}</span><span class='tstring_content'>_week_start_day</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1678
|
+
<span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@exp</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
|
1679
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>day</span><span class='tstring_end'>'</span></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>
|
1680
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>DATE(</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>
|
1681
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>hour</span><span class='tstring_end'>'</span></span>
|
1682
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TIMESTAMP(DATE_FORMAT(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exp'>exp</span><span class='embexpr_end'>}</span><span class='tstring_content'>, '%Y-%m-%d %H:00:00'))</span><span class='tstring_end'>"</span></span>
|
1683
|
+
<span class='kw'>else</span>
|
1684
|
+
<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'>Currently not supporting truncation at </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_unit'>unit</span><span class='embexpr_end'>}</span><span class='tstring_content'> level</span><span class='tstring_end'>"</span></span>
|
1685
|
+
<span class='kw'>end</span>
|
1686
|
+
<span class='kw'>end</span></pre>
|
1687
|
+
</td>
|
1688
|
+
</tr>
|
1689
|
+
</table>
|
1690
|
+
</div>
|
1691
|
+
|
1692
|
+
</div>
|
1693
|
+
|
1694
|
+
</div>
|
1695
|
+
|
1696
|
+
<div id="footer">
|
1697
|
+
Generated on Fri Aug 22 08:31:22 2025 by
|
1698
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1699
|
+
0.9.37 (ruby-3.4.4).
|
1700
|
+
</div>
|
1701
|
+
|
1702
|
+
</div>
|
1703
|
+
</body>
|
1704
|
+
</html>
|