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