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