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,1662 @@
|
|
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::Snowflake
|
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::Snowflake";
|
19
|
+
relpath = '../../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../../_index.html">Index (S)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../DWH.html" title="DWH (module)">DWH</a></span></span> » <span class='title'><span class='object_link'><a href="../Adapters.html" title="DWH::Adapters (module)">Adapters</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Snowflake</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::Snowflake
|
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::Snowflake</li>
|
80
|
+
|
81
|
+
</ul>
|
82
|
+
<a href="#" class="inheritanceTree">show all</a>
|
83
|
+
|
84
|
+
</dd>
|
85
|
+
</dl>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
<dl>
|
93
|
+
<dt>Includes:</dt>
|
94
|
+
<dd><span class='object_link'><a href="OpenAuthorizable.html" title="DWH::Adapters::OpenAuthorizable (module)">OpenAuthorizable</a></span></dd>
|
95
|
+
</dl>
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
<dl>
|
103
|
+
<dt>Defined in:</dt>
|
104
|
+
<dd>lib/dwh/adapters/snowflake.rb</dd>
|
105
|
+
</dl>
|
106
|
+
|
107
|
+
</div>
|
108
|
+
|
109
|
+
<h2>Overview</h2><div class="docstring">
|
110
|
+
<div class="discussion">
|
111
|
+
<p>Snowflake adapter for executing SQL queries against Snowflake databases.</p>
|
112
|
+
|
113
|
+
<p>Supports two authentication modes:
|
114
|
+
- Personal Access Token (pat)
|
115
|
+
- Key Pair Authentication (kp)
|
116
|
+
- OAuth 2.0 (oauth)</p>
|
117
|
+
|
118
|
+
|
119
|
+
</div>
|
120
|
+
</div>
|
121
|
+
<div class="tags">
|
122
|
+
|
123
|
+
<div class="examples">
|
124
|
+
<h4 class="tag_title">Examples:</h4>
|
125
|
+
|
126
|
+
|
127
|
+
<h5 class="example_title"><div class='inline'><p>Basic connection with Personal Access Token</p>
|
128
|
+
</div></h5>
|
129
|
+
|
130
|
+
<pre class="example code"><code><span class='const'><span class='object_link'><a href="../../DWH.html" title="DWH (module)">DWH</a></span></span><span class='period'>.</span><span class='id identifier rubyid_create'><span class='object_link'><a href="../Factory.html#create-instance_method" title="DWH::Factory#create (method)">create</a></span></span><span class='lparen'>(</span><span class='symbol'>:snowflake</span><span class='comma'>,</span> <span class='lbrace'>{</span>
|
131
|
+
<span class='label'>auth_mode:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>pat</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
132
|
+
<span class='label'>account_identifier:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>myorg-myaccount</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
133
|
+
<span class='label'>personal_access_token:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>your-token-here</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
134
|
+
<span class='label'>warehouse:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>COMPUTE_WH</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
135
|
+
<span class='label'>database:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ANALYTICS</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
136
|
+
<span class='label'>schema:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>PUBLIC</span><span class='tstring_end'>'</span></span>
|
137
|
+
<span class='rbrace'>}</span><span class='rparen'>)</span></code></pre>
|
138
|
+
|
139
|
+
|
140
|
+
<h5 class="example_title"><div class='inline'><p>Connection with Key Pair Authentication</p>
|
141
|
+
</div></h5>
|
142
|
+
|
143
|
+
<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'>:snowflake</span><span class='comma'>,</span> <span class='lbrace'>{</span>
|
144
|
+
<span class='label'>auth_mode:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>kp</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
145
|
+
<span class='label'>account_identifier:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>myorg-myaccount.us-east-1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
146
|
+
<span class='label'>username:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>john_doe</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
147
|
+
<span class='label'>private_key:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/path/to/private_key.pem</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
148
|
+
<span class='label'>warehouse:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>COMPUTE_WH</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
149
|
+
<span class='label'>database:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ANALYTICS</span><span class='tstring_end'>'</span></span>
|
150
|
+
<span class='rbrace'>}</span><span class='rparen'>)</span></code></pre>
|
151
|
+
|
152
|
+
|
153
|
+
<h5 class="example_title"><div class='inline'><p>Connecting with OAuth</p>
|
154
|
+
</div></h5>
|
155
|
+
|
156
|
+
<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'>:snowflake</span><span class='comma'>,</span> <span class='lbrace'>{</span>
|
157
|
+
<span class='label'>auth_mode:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>oauth</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
158
|
+
<span class='label'>account_identifier:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>myorg-myaccount.us-east-1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
159
|
+
<span class='label'>oauth_client_id:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'><YOUR_CLIENT_ID></span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
160
|
+
<span class='label'>oauth_client_secret:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'><YOUR_CLIENT_SECRET></span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
161
|
+
<span class='label'>oauth_redirect_url:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>https://localhost:3030/some/path</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
162
|
+
<span class='label'>database:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ANALYTICS</span><span class='tstring_end'>'</span></span>
|
163
|
+
<span class='rbrace'>}</span><span class='rparen'>)</span>
|
164
|
+
|
165
|
+
<span class='comment'># This sill only work if you setup an OAuth security integration
|
166
|
+
</span><span class='comment'># and grant it to the correct users.
|
167
|
+
</span>
|
168
|
+
<span class='comment'># Use this url to get auth code
|
169
|
+
</span><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_authorization_url'>authorization_url</span>
|
170
|
+
|
171
|
+
<span class='comment'># Pass the code to generate oauth tokens
|
172
|
+
</span><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_generate_oauth_tokens'>generate_oauth_tokens</span><span class='lparen'>(</span><span class='id identifier rubyid_authorization_code'>authorization_code</span><span class='rparen'>)</span>
|
173
|
+
|
174
|
+
<span class='comment'># Apply previously created tokens for new connections
|
175
|
+
</span><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_apply_oauth_tokens'>apply_oauth_tokens</span><span class='lparen'>(</span><span class='label'>access_token:</span> <span class='id identifier rubyid_token'>token</span><span class='comma'>,</span> <span class='label'>refresh_token:</span> <span class='id identifier rubyid_token'>token</span><span class='comma'>,</span> <span class='label'>expires_at:</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='rparen'>)</span></code></pre>
|
176
|
+
|
177
|
+
</div>
|
178
|
+
|
179
|
+
|
180
|
+
</div>
|
181
|
+
|
182
|
+
<h2>
|
183
|
+
Constant Summary
|
184
|
+
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
|
185
|
+
</h2>
|
186
|
+
|
187
|
+
<dl class="constants">
|
188
|
+
|
189
|
+
<dt id="AUTH_TOKEN_TYPES-constant" class="">AUTH_TOKEN_TYPES =
|
190
|
+
<div class="docstring">
|
191
|
+
<div class="discussion">
|
192
|
+
<p>Constants</p>
|
193
|
+
|
194
|
+
|
195
|
+
</div>
|
196
|
+
</div>
|
197
|
+
<div class="tags">
|
198
|
+
|
199
|
+
|
200
|
+
</div>
|
201
|
+
</dt>
|
202
|
+
<dd><pre class="code"><span class='lbrace'>{</span>
|
203
|
+
<span class='label'>pat:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>PROGRAMMATIC_ACCESS_TOKEN</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
204
|
+
<span class='label'>kp:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>KEYPAIR_JWT</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
205
|
+
<span class='label'>oauth:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>OAUTH</span><span class='tstring_end'>'</span></span>
|
206
|
+
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
207
|
+
|
208
|
+
<dt id="API_ENDPOINTS-constant" class="">API_ENDPOINTS =
|
209
|
+
|
210
|
+
</dt>
|
211
|
+
<dd><pre class="code"><span class='lbrace'>{</span>
|
212
|
+
<span class='label'>statements:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/api/v2/statements</span><span class='tstring_end'>'</span></span>
|
213
|
+
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
214
|
+
|
215
|
+
<dt id="DEFAULT_PARAMETERS-constant" class="">DEFAULT_PARAMETERS =
|
216
|
+
|
217
|
+
</dt>
|
218
|
+
<dd><pre class="code"><span class='lbrace'>{</span>
|
219
|
+
<span class='label'>DATE_OUTPUT_FORMAT:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>YYYY-MM-DD</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
220
|
+
<span class='label'>TIMESTAMP_OUTPUT_FORMAT:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>YYYY-MM-DD HH24:MI:SS</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
221
|
+
<span class='label'>TIMESTAMP_TZ_OUTPUT_FORMAT:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>YYYY-MM-DD HH24:MI:SS TZH</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
222
|
+
<span class='label'>TIMESTAMP_NTZ_OUTPUT_FORMAT:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>YYYY-MM-DD HH24:MI:SS</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
223
|
+
<span class='label'>TIMESTAMP_LTZ_OUTPUT_FORMAT:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>YYYY-MM-DD HH24:MI:SS TZH</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
224
|
+
<span class='label'>TIME_OUTPUT_FORMAT:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>HH24:MI:SS</span><span class='tstring_end'>'</span></span>
|
225
|
+
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
226
|
+
|
227
|
+
<dt id="DEFAULT_POLL_INTERVAL-constant" class="">DEFAULT_POLL_INTERVAL =
|
228
|
+
|
229
|
+
</dt>
|
230
|
+
<dd><pre class="code"><span class='float'>0.25</span></pre></dd>
|
231
|
+
|
232
|
+
<dt id="MAX_POLL_INTERVAL-constant" class="">MAX_POLL_INTERVAL =
|
233
|
+
|
234
|
+
</dt>
|
235
|
+
<dd><pre class="code"><span class='int'>30</span></pre></dd>
|
236
|
+
|
237
|
+
<dt id="TOKEN_VALIDITY_SECONDS-constant" class="">TOKEN_VALIDITY_SECONDS =
|
238
|
+
|
239
|
+
</dt>
|
240
|
+
<dd><pre class="code"><span class='int'>3600</span></pre></dd>
|
241
|
+
|
242
|
+
</dl>
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
<h3 class="inherited">Constants included
|
250
|
+
from <span class='object_link'><a href="../Settings.html" title="DWH::Settings (module)">Settings</a></span></h3>
|
251
|
+
<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>
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
<h3 class="inherited">Constants included
|
256
|
+
from <span class='object_link'><a href="../Functions/Dates.html" title="DWH::Functions::Dates (module)">Functions::Dates</a></span></h3>
|
257
|
+
<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>
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
<h2>Instance Attribute Summary</h2>
|
263
|
+
|
264
|
+
<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Adapter.html" title="DWH::Adapters::Adapter (class)">Adapter</a></span></h3>
|
265
|
+
<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>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
<h3 class="inherited">Attributes included from <span class='object_link'><a href="../Settings.html" title="DWH::Settings (module)">Settings</a></span></h3>
|
270
|
+
<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>
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
<h2>
|
275
|
+
Instance Method Summary
|
276
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
277
|
+
</h2>
|
278
|
+
|
279
|
+
<ul class="summary">
|
280
|
+
|
281
|
+
<li class="public ">
|
282
|
+
<span class="summary_signature">
|
283
|
+
|
284
|
+
<a href="#connection-instance_method" title="#connection (instance method)">#<strong>connection</strong> ⇒ Object </a>
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
</span>
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
<span class="summary_desc"><div class='inline'><p>Creates a connection to the target database and returns the connection object or self.</p>
|
299
|
+
</div></span>
|
300
|
+
|
301
|
+
</li>
|
302
|
+
|
303
|
+
|
304
|
+
<li class="public ">
|
305
|
+
<span class="summary_signature">
|
306
|
+
|
307
|
+
<a href="#execute-instance_method" title="#execute (instance method)">#<strong>execute</strong>(sql, format: :array, retries: 0) ⇒ Array<Array>, ... </a>
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
</span>
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
<span class="summary_desc"><div class='inline'><p>Execute sql on the target database.</p>
|
322
|
+
</div></span>
|
323
|
+
|
324
|
+
</li>
|
325
|
+
|
326
|
+
|
327
|
+
<li class="public ">
|
328
|
+
<span class="summary_signature">
|
329
|
+
|
330
|
+
<a href="#execute_stream-instance_method" title="#execute_stream (instance method)">#<strong>execute_stream</strong>(sql, io, stats: nil, retries: 0) ⇒ Array<Array>, ... </a>
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
</span>
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
<span class="summary_desc"><div class='inline'><p>Execute sql on the target database.</p>
|
345
|
+
</div></span>
|
346
|
+
|
347
|
+
</li>
|
348
|
+
|
349
|
+
|
350
|
+
<li class="public ">
|
351
|
+
<span class="summary_signature">
|
352
|
+
|
353
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(config) ⇒ Snowflake </a>
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
</span>
|
358
|
+
|
359
|
+
|
360
|
+
<span class="note title constructor">constructor</span>
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
<span class="summary_desc"><div class='inline'><p>A new instance of Snowflake.</p>
|
370
|
+
</div></span>
|
371
|
+
|
372
|
+
</li>
|
373
|
+
|
374
|
+
|
375
|
+
<li class="public ">
|
376
|
+
<span class="summary_signature">
|
377
|
+
|
378
|
+
<a href="#metadata-instance_method" title="#metadata (instance method)">#<strong>metadata</strong>(table, **qualifiers) ⇒ Array<String> </a>
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
</span>
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
<span class="summary_desc"><div class='inline'><p>Get all tables available in the target db.</p>
|
393
|
+
</div></span>
|
394
|
+
|
395
|
+
</li>
|
396
|
+
|
397
|
+
|
398
|
+
<li class="public ">
|
399
|
+
<span class="summary_signature">
|
400
|
+
|
401
|
+
<a href="#stats-instance_method" title="#stats (instance method)">#<strong>stats</strong>(table, date_column: nil) ⇒ DWH::Table </a>
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
</span>
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
<span class="summary_desc"><div class='inline'><p>Returns basic stats of a given table.</p>
|
416
|
+
</div></span>
|
417
|
+
|
418
|
+
</li>
|
419
|
+
|
420
|
+
|
421
|
+
<li class="public ">
|
422
|
+
<span class="summary_signature">
|
423
|
+
|
424
|
+
<a href="#stream-instance_method" title="#stream (instance method)">#<strong>stream</strong>(sql) {|chunk| ... } ⇒ Object </a>
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
</span>
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
<span class="summary_desc"><div class='inline'><p>Execute SQL query and yield streamed results.</p>
|
439
|
+
</div></span>
|
440
|
+
|
441
|
+
</li>
|
442
|
+
|
443
|
+
|
444
|
+
<li class="public ">
|
445
|
+
<span class="summary_signature">
|
446
|
+
|
447
|
+
<a href="#tables-instance_method" title="#tables (instance method)">#<strong>tables</strong>(**qualifiers) ⇒ Array<String> </a>
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
</span>
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
<span class="summary_desc"><div class='inline'><p>Get all tables available in the target db.</p>
|
462
|
+
</div></span>
|
463
|
+
|
464
|
+
</li>
|
465
|
+
|
466
|
+
|
467
|
+
<li class="public ">
|
468
|
+
<span class="summary_signature">
|
469
|
+
|
470
|
+
<a href="#test_connection-instance_method" title="#test_connection (instance method)">#<strong>test_connection</strong>(raise_exception: false) ⇒ Boolean </a>
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
</span>
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
<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>
|
485
|
+
</div></span>
|
486
|
+
|
487
|
+
</li>
|
488
|
+
|
489
|
+
|
490
|
+
</ul>
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="OpenAuthorizable.html" title="DWH::Adapters::OpenAuthorizable (module)">OpenAuthorizable</a></span></h3>
|
503
|
+
<p class="inherited"><span class='object_link'><a href="OpenAuthorizable.html#apply_oauth_tokens-instance_method" title="DWH::Adapters::OpenAuthorizable#apply_oauth_tokens (method)">#apply_oauth_tokens</a></span>, <span class='object_link'><a href="OpenAuthorizable.html#authorization_url-instance_method" title="DWH::Adapters::OpenAuthorizable#authorization_url (method)">#authorization_url</a></span>, <span class='object_link'><a href="OpenAuthorizable.html#generate_oauth_tokens-instance_method" title="DWH::Adapters::OpenAuthorizable#generate_oauth_tokens (method)">#generate_oauth_tokens</a></span>, <span class='object_link'><a href="OpenAuthorizable.html#included-class_method" title="DWH::Adapters::OpenAuthorizable.included (method)">included</a></span>, <span class='object_link'><a href="OpenAuthorizable.html#oauth_access_token-instance_method" title="DWH::Adapters::OpenAuthorizable#oauth_access_token (method)">#oauth_access_token</a></span>, <span class='object_link'><a href="OpenAuthorizable.html#oauth_authenticated%3F-instance_method" title="DWH::Adapters::OpenAuthorizable#oauth_authenticated? (method)">#oauth_authenticated?</a></span>, <span class='object_link'><a href="OpenAuthorizable.html#oauth_settings-instance_method" title="DWH::Adapters::OpenAuthorizable#oauth_settings (method)">#oauth_settings</a></span>, <span class='object_link'><a href="OpenAuthorizable.html#oauth_token_info-instance_method" title="DWH::Adapters::OpenAuthorizable#oauth_token_info (method)">#oauth_token_info</a></span>, <span class='object_link'><a href="OpenAuthorizable.html#oauth_tokenization_url-instance_method" title="DWH::Adapters::OpenAuthorizable#oauth_tokenization_url (method)">#oauth_tokenization_url</a></span>, <span class='object_link'><a href="OpenAuthorizable.html#refresh_access_token-instance_method" title="DWH::Adapters::OpenAuthorizable#refresh_access_token (method)">#refresh_access_token</a></span>, <span class='object_link'><a href="OpenAuthorizable.html#validate_oauth_config-instance_method" title="DWH::Adapters::OpenAuthorizable#validate_oauth_config (method)">#validate_oauth_config</a></span></p>
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="Adapter.html" title="DWH::Adapters::Adapter (class)">Adapter</a></span></h3>
|
514
|
+
<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#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>
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Settings.html" title="DWH::Settings (module)">Settings</a></span></h3>
|
525
|
+
<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>
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
|
534
|
+
|
535
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Logger.html" title="DWH::Logger (module)">Logger</a></span></h3>
|
536
|
+
<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>
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Behaviors.html" title="DWH::Behaviors (module)">Behaviors</a></span></h3>
|
547
|
+
<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>
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
|
556
|
+
|
557
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Functions.html" title="DWH::Functions (module)">Functions</a></span></h3>
|
558
|
+
<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>
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
<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>
|
569
|
+
<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>
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
<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>
|
580
|
+
<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>
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
|
590
|
+
<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>
|
591
|
+
<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>
|
592
|
+
|
593
|
+
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
<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>
|
602
|
+
<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>
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Capabilities.html" title="DWH::Capabilities (module)">Capabilities</a></span></h3>
|
613
|
+
<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>
|
614
|
+
<div id="constructor_details" class="method_details_list">
|
615
|
+
<h2>Constructor Details</h2>
|
616
|
+
|
617
|
+
<div class="method_details first">
|
618
|
+
<h3 class="signature first" id="initialize-instance_method">
|
619
|
+
|
620
|
+
#<strong>initialize</strong>(config) ⇒ <tt><span class='object_link'><a href="" title="DWH::Adapters::Snowflake (class)">Snowflake</a></span></tt>
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
|
625
|
+
|
626
|
+
</h3><div class="docstring">
|
627
|
+
<div class="discussion">
|
628
|
+
<p>Returns a new instance of Snowflake.</p>
|
629
|
+
|
630
|
+
|
631
|
+
</div>
|
632
|
+
</div>
|
633
|
+
<div class="tags">
|
634
|
+
|
635
|
+
|
636
|
+
</div><table class="source_code">
|
637
|
+
<tr>
|
638
|
+
<td>
|
639
|
+
<pre class="lines">
|
640
|
+
|
641
|
+
|
642
|
+
130
|
643
|
+
131
|
644
|
+
132
|
645
|
+
133</pre>
|
646
|
+
</td>
|
647
|
+
<td>
|
648
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/snowflake.rb', line 130</span>
|
649
|
+
|
650
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span>
|
651
|
+
<span class='kw'>super</span>
|
652
|
+
<span class='id identifier rubyid_validate_auth_config'>validate_auth_config</span>
|
653
|
+
<span class='kw'>end</span></pre>
|
654
|
+
</td>
|
655
|
+
</tr>
|
656
|
+
</table>
|
657
|
+
</div>
|
658
|
+
|
659
|
+
</div>
|
660
|
+
|
661
|
+
|
662
|
+
<div id="instance_method_details" class="method_details_list">
|
663
|
+
<h2>Instance Method Details</h2>
|
664
|
+
|
665
|
+
|
666
|
+
<div class="method_details first">
|
667
|
+
<h3 class="signature first" id="connection-instance_method">
|
668
|
+
|
669
|
+
#<strong>connection</strong> ⇒ <tt>Object</tt>
|
670
|
+
|
671
|
+
|
672
|
+
|
673
|
+
|
674
|
+
|
675
|
+
</h3><div class="docstring">
|
676
|
+
<div class="discussion">
|
677
|
+
<p>Creates a connection to the target database and returns the
|
678
|
+
connection object or self</p>
|
679
|
+
|
680
|
+
|
681
|
+
</div>
|
682
|
+
</div>
|
683
|
+
<div class="tags">
|
684
|
+
|
685
|
+
|
686
|
+
</div><table class="source_code">
|
687
|
+
<tr>
|
688
|
+
<td>
|
689
|
+
<pre class="lines">
|
690
|
+
|
691
|
+
|
692
|
+
136
|
693
|
+
137
|
694
|
+
138
|
695
|
+
139
|
696
|
+
140
|
697
|
+
141
|
698
|
+
142
|
699
|
+
143
|
700
|
+
144
|
701
|
+
145
|
702
|
+
146
|
703
|
+
147
|
704
|
+
148
|
705
|
+
149
|
706
|
+
150
|
707
|
+
151
|
708
|
+
152
|
709
|
+
153
|
710
|
+
154</pre>
|
711
|
+
</td>
|
712
|
+
<td>
|
713
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/snowflake.rb', line 136</span>
|
714
|
+
|
715
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_connection'>connection</span>
|
716
|
+
<span class='kw'>return</span> <span class='ivar'>@connection</span> <span class='kw'>if</span> <span class='ivar'>@connection</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_token_expired?'>token_expired?</span>
|
717
|
+
|
718
|
+
<span class='id identifier rubyid_reset_connection'>reset_connection</span> <span class='kw'>if</span> <span class='id identifier rubyid_token_expired?'>token_expired?</span>
|
719
|
+
<span class='ivar'>@token_expires_at</span> <span class='op'>||=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>+</span> <span class='const'><span class='object_link'><a href="#TOKEN_VALIDITY_SECONDS-constant" title="DWH::Adapters::Snowflake::TOKEN_VALIDITY_SECONDS (constant)">TOKEN_VALIDITY_SECONDS</a></span></span>
|
720
|
+
|
721
|
+
<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>
|
722
|
+
<span class='label'>url:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>https://</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:account_identifier</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>.snowflakecomputing.com</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
723
|
+
<span class='label'>headers:</span> <span class='lbrace'>{</span>
|
724
|
+
<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>
|
725
|
+
<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'>Bearer </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_auth_token'>auth_token</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
726
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>X-Snowflake-Authorization-Token-Type</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='id identifier rubyid_auth_token_type'>auth_token_type</span><span class='comma'>,</span>
|
727
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>User-Agent</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:client_name</span><span class='rbracket'>]</span>
|
728
|
+
<span class='rbrace'>}</span><span class='comma'>,</span>
|
729
|
+
<span class='label'>request:</span> <span class='lbrace'>{</span>
|
730
|
+
<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>
|
731
|
+
<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>
|
732
|
+
<span class='rparen'>)</span>
|
733
|
+
<span class='kw'>end</span></pre>
|
734
|
+
</td>
|
735
|
+
</tr>
|
736
|
+
</table>
|
737
|
+
</div>
|
738
|
+
|
739
|
+
<div class="method_details ">
|
740
|
+
<h3 class="signature " id="execute-instance_method">
|
741
|
+
|
742
|
+
#<strong>execute</strong>(sql, format: :array, retries: 0) ⇒ <tt>Array<Array></tt>, ...
|
743
|
+
|
744
|
+
|
745
|
+
|
746
|
+
|
747
|
+
|
748
|
+
</h3><div class="docstring">
|
749
|
+
<div class="discussion">
|
750
|
+
<p>Execute sql on the target database.</p>
|
751
|
+
|
752
|
+
|
753
|
+
</div>
|
754
|
+
</div>
|
755
|
+
<div class="tags">
|
756
|
+
<p class="tag_title">Parameters:</p>
|
757
|
+
<ul class="param">
|
758
|
+
|
759
|
+
<li>
|
760
|
+
|
761
|
+
<span class='name'>sql</span>
|
762
|
+
|
763
|
+
|
764
|
+
<span class='type'>(<tt>String</tt>)</span>
|
765
|
+
|
766
|
+
|
767
|
+
|
768
|
+
—
|
769
|
+
<div class='inline'><p>actual sql</p>
|
770
|
+
</div>
|
771
|
+
|
772
|
+
</li>
|
773
|
+
|
774
|
+
<li>
|
775
|
+
|
776
|
+
<span class='name'>format</span>
|
777
|
+
|
778
|
+
|
779
|
+
<span class='type'>(<tt>Symbol</tt>, <tt>String</tt>)</span>
|
780
|
+
|
781
|
+
|
782
|
+
<em class="default">(defaults to: <tt>:array</tt>)</em>
|
783
|
+
|
784
|
+
|
785
|
+
—
|
786
|
+
<div class='inline'><p>return format type
|
787
|
+
- array returns array of array
|
788
|
+
- object returns array of Hashes
|
789
|
+
- csv returns as csv
|
790
|
+
- native returns the native result from any clients used
|
791
|
+
- For example: Postgres using pg client will return PG::Result
|
792
|
+
- Http clients will returns the HTTP response object</p>
|
793
|
+
</div>
|
794
|
+
|
795
|
+
</li>
|
796
|
+
|
797
|
+
<li>
|
798
|
+
|
799
|
+
<span class='name'>retries</span>
|
800
|
+
|
801
|
+
|
802
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
803
|
+
|
804
|
+
|
805
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
806
|
+
|
807
|
+
|
808
|
+
—
|
809
|
+
<div class='inline'><p>number of retries in case of failure. Default is 0</p>
|
810
|
+
</div>
|
811
|
+
|
812
|
+
</li>
|
813
|
+
|
814
|
+
</ul>
|
815
|
+
|
816
|
+
<p class="tag_title">Returns:</p>
|
817
|
+
<ul class="return">
|
818
|
+
|
819
|
+
<li>
|
820
|
+
|
821
|
+
|
822
|
+
<span class='type'>(<tt>Array<Array></tt>, <tt>Hash</tt>, <tt>CSV</tt>, <tt>Native</tt>)</span>
|
823
|
+
|
824
|
+
|
825
|
+
|
826
|
+
</li>
|
827
|
+
|
828
|
+
</ul>
|
829
|
+
<p class="tag_title">Raises:</p>
|
830
|
+
<ul class="raise">
|
831
|
+
|
832
|
+
<li>
|
833
|
+
|
834
|
+
|
835
|
+
<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>
|
836
|
+
|
837
|
+
|
838
|
+
|
839
|
+
</li>
|
840
|
+
|
841
|
+
</ul>
|
842
|
+
|
843
|
+
</div><table class="source_code">
|
844
|
+
<tr>
|
845
|
+
<td>
|
846
|
+
<pre class="lines">
|
847
|
+
|
848
|
+
|
849
|
+
168
|
850
|
+
169
|
851
|
+
170
|
852
|
+
171
|
853
|
+
172
|
854
|
+
173
|
855
|
+
174
|
856
|
+
175
|
857
|
+
176
|
858
|
+
177</pre>
|
859
|
+
</td>
|
860
|
+
<td>
|
861
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/snowflake.rb', line 168</span>
|
862
|
+
|
863
|
+
<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>
|
864
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_with_retry'>with_retry</span><span class='lparen'>(</span><span class='id identifier rubyid_retries'>retries</span> <span class='op'>+</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
865
|
+
<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>
|
866
|
+
<span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='id identifier rubyid_submit_query'>submit_query</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span>
|
867
|
+
<span class='id identifier rubyid_fetch_data'>fetch_data</span><span class='lparen'>(</span><span class='id identifier rubyid_handle_query_response'>handle_query_response</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
868
|
+
<span class='kw'>end</span>
|
869
|
+
<span class='kw'>end</span>
|
870
|
+
|
871
|
+
<span class='id identifier rubyid_format_result'>format_result</span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span>
|
872
|
+
<span class='kw'>end</span></pre>
|
873
|
+
</td>
|
874
|
+
</tr>
|
875
|
+
</table>
|
876
|
+
</div>
|
877
|
+
|
878
|
+
<div class="method_details ">
|
879
|
+
<h3 class="signature " id="execute_stream-instance_method">
|
880
|
+
|
881
|
+
#<strong>execute_stream</strong>(sql, io, stats: nil, retries: 0) ⇒ <tt>Array<Array></tt>, ...
|
882
|
+
|
883
|
+
|
884
|
+
|
885
|
+
|
886
|
+
|
887
|
+
</h3><div class="docstring">
|
888
|
+
<div class="discussion">
|
889
|
+
<p>Execute sql on the target database.</p>
|
890
|
+
|
891
|
+
|
892
|
+
</div>
|
893
|
+
</div>
|
894
|
+
<div class="tags">
|
895
|
+
<p class="tag_title">Parameters:</p>
|
896
|
+
<ul class="param">
|
897
|
+
|
898
|
+
<li>
|
899
|
+
|
900
|
+
<span class='name'>sql</span>
|
901
|
+
|
902
|
+
|
903
|
+
<span class='type'>(<tt>String</tt>)</span>
|
904
|
+
|
905
|
+
|
906
|
+
|
907
|
+
—
|
908
|
+
<div class='inline'><p>actual sql</p>
|
909
|
+
</div>
|
910
|
+
|
911
|
+
</li>
|
912
|
+
|
913
|
+
<li>
|
914
|
+
|
915
|
+
<span class='name'>format</span>
|
916
|
+
|
917
|
+
|
918
|
+
<span class='type'>(<tt>Symbol</tt>, <tt>String</tt>)</span>
|
919
|
+
|
920
|
+
|
921
|
+
|
922
|
+
—
|
923
|
+
<div class='inline'><p>return format type
|
924
|
+
- array returns array of array
|
925
|
+
- object returns array of Hashes
|
926
|
+
- csv returns as csv
|
927
|
+
- native returns the native result from any clients used
|
928
|
+
- For example: Postgres using pg client will return PG::Result
|
929
|
+
- Http clients will returns the HTTP response object</p>
|
930
|
+
</div>
|
931
|
+
|
932
|
+
</li>
|
933
|
+
|
934
|
+
<li>
|
935
|
+
|
936
|
+
<span class='name'>retries</span>
|
937
|
+
|
938
|
+
|
939
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
940
|
+
|
941
|
+
|
942
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
943
|
+
|
944
|
+
|
945
|
+
—
|
946
|
+
<div class='inline'><p>number of retries in case of failure. Default is 0</p>
|
947
|
+
</div>
|
948
|
+
|
949
|
+
</li>
|
950
|
+
|
951
|
+
</ul>
|
952
|
+
|
953
|
+
<p class="tag_title">Returns:</p>
|
954
|
+
<ul class="return">
|
955
|
+
|
956
|
+
<li>
|
957
|
+
|
958
|
+
|
959
|
+
<span class='type'>(<tt>Array<Array></tt>, <tt>Hash</tt>, <tt>CSV</tt>, <tt>Native</tt>)</span>
|
960
|
+
|
961
|
+
|
962
|
+
|
963
|
+
</li>
|
964
|
+
|
965
|
+
</ul>
|
966
|
+
<p class="tag_title">Raises:</p>
|
967
|
+
<ul class="raise">
|
968
|
+
|
969
|
+
<li>
|
970
|
+
|
971
|
+
|
972
|
+
<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>
|
973
|
+
|
974
|
+
|
975
|
+
|
976
|
+
</li>
|
977
|
+
|
978
|
+
</ul>
|
979
|
+
|
980
|
+
</div><table class="source_code">
|
981
|
+
<tr>
|
982
|
+
<td>
|
983
|
+
<pre class="lines">
|
984
|
+
|
985
|
+
|
986
|
+
180
|
987
|
+
181
|
988
|
+
182
|
989
|
+
183
|
990
|
+
184
|
991
|
+
185
|
992
|
+
186
|
993
|
+
187
|
994
|
+
188
|
995
|
+
189
|
996
|
+
190</pre>
|
997
|
+
</td>
|
998
|
+
<td>
|
999
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/snowflake.rb', line 180</span>
|
1000
|
+
|
1001
|
+
<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>
|
1002
|
+
<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>
|
1003
|
+
<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>
|
1004
|
+
<span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='id identifier rubyid_submit_query'>submit_query</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span>
|
1005
|
+
<span class='id identifier rubyid_fetch_data'>fetch_data</span><span class='lparen'>(</span><span class='id identifier rubyid_handle_query_response'>handle_query_response</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='label'>io:</span> <span class='id identifier rubyid_io'>io</span><span class='comma'>,</span> <span class='label'>stats:</span> <span class='id identifier rubyid_stats'>stats</span><span class='rparen'>)</span>
|
1006
|
+
<span class='kw'>end</span>
|
1007
|
+
<span class='kw'>end</span>
|
1008
|
+
|
1009
|
+
<span class='id identifier rubyid_io'>io</span><span class='period'>.</span><span class='id identifier rubyid_rewind'>rewind</span>
|
1010
|
+
<span class='id identifier rubyid_io'>io</span>
|
1011
|
+
<span class='kw'>end</span></pre>
|
1012
|
+
</td>
|
1013
|
+
</tr>
|
1014
|
+
</table>
|
1015
|
+
</div>
|
1016
|
+
|
1017
|
+
<div class="method_details ">
|
1018
|
+
<h3 class="signature " id="metadata-instance_method">
|
1019
|
+
|
1020
|
+
#<strong>metadata</strong>(table, **qualifiers) ⇒ <tt>Array<String></tt>
|
1021
|
+
|
1022
|
+
|
1023
|
+
|
1024
|
+
|
1025
|
+
|
1026
|
+
</h3><div class="docstring">
|
1027
|
+
<div class="discussion">
|
1028
|
+
<p>Get all tables available in the
|
1029
|
+
target db. It will use the default catalog and schema
|
1030
|
+
config only specified here.</p>
|
1031
|
+
|
1032
|
+
|
1033
|
+
</div>
|
1034
|
+
</div>
|
1035
|
+
<div class="tags">
|
1036
|
+
<p class="tag_title">Parameters:</p>
|
1037
|
+
<ul class="param">
|
1038
|
+
|
1039
|
+
<li>
|
1040
|
+
|
1041
|
+
<span class='name'>qualifiers</span>
|
1042
|
+
|
1043
|
+
|
1044
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1045
|
+
|
1046
|
+
|
1047
|
+
|
1048
|
+
—
|
1049
|
+
<div class='inline'><p>a customizable set of options</p>
|
1050
|
+
</div>
|
1051
|
+
|
1052
|
+
</li>
|
1053
|
+
|
1054
|
+
</ul>
|
1055
|
+
|
1056
|
+
|
1057
|
+
|
1058
|
+
|
1059
|
+
|
1060
|
+
|
1061
|
+
<p class="tag_title">Options Hash (<tt>**qualifiers</tt>):</p>
|
1062
|
+
<ul class="option">
|
1063
|
+
|
1064
|
+
<li>
|
1065
|
+
<span class="name">:catalog</span>
|
1066
|
+
<span class="type">(<tt>String</tt>)</span>
|
1067
|
+
<span class="default">
|
1068
|
+
|
1069
|
+
</span>
|
1070
|
+
|
1071
|
+
— <div class='inline'><p>optional catalog or equivalent name space.
|
1072
|
+
will be ignored if the adapter doesn’t support</p>
|
1073
|
+
</div>
|
1074
|
+
|
1075
|
+
</li>
|
1076
|
+
|
1077
|
+
<li>
|
1078
|
+
<span class="name">:schema</span>
|
1079
|
+
<span class="type">(<tt>String</tt>)</span>
|
1080
|
+
<span class="default">
|
1081
|
+
|
1082
|
+
</span>
|
1083
|
+
|
1084
|
+
— <div class='inline'><p>optional schema to scope to.
|
1085
|
+
will be ignored if the adapter doesn’t support</p>
|
1086
|
+
</div>
|
1087
|
+
|
1088
|
+
</li>
|
1089
|
+
|
1090
|
+
</ul>
|
1091
|
+
|
1092
|
+
|
1093
|
+
<p class="tag_title">Returns:</p>
|
1094
|
+
<ul class="return">
|
1095
|
+
|
1096
|
+
<li>
|
1097
|
+
|
1098
|
+
|
1099
|
+
<span class='type'>(<tt>Array<String></tt>)</span>
|
1100
|
+
|
1101
|
+
|
1102
|
+
|
1103
|
+
</li>
|
1104
|
+
|
1105
|
+
</ul>
|
1106
|
+
|
1107
|
+
</div><table class="source_code">
|
1108
|
+
<tr>
|
1109
|
+
<td>
|
1110
|
+
<pre class="lines">
|
1111
|
+
|
1112
|
+
|
1113
|
+
226
|
1114
|
+
227
|
1115
|
+
228
|
1116
|
+
229
|
1117
|
+
230
|
1118
|
+
231
|
1119
|
+
232
|
1120
|
+
233
|
1121
|
+
234
|
1122
|
+
235
|
1123
|
+
236
|
1124
|
+
237
|
1125
|
+
238
|
1126
|
+
239
|
1127
|
+
240
|
1128
|
+
241
|
1129
|
+
242
|
1130
|
+
243
|
1131
|
+
244
|
1132
|
+
245
|
1133
|
+
246
|
1134
|
+
247
|
1135
|
+
248
|
1136
|
+
249
|
1137
|
+
250
|
1138
|
+
251</pre>
|
1139
|
+
</td>
|
1140
|
+
<td>
|
1141
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/snowflake.rb', line 226</span>
|
1142
|
+
|
1143
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_metadata'>metadata</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='rparen'>)</span>
|
1144
|
+
<span class='id identifier rubyid_catalog'>catalog</span><span class='comma'>,</span> <span class='id identifier rubyid_schema'>schema</span> <span class='op'>=</span> <span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='period'>.</span><span class='id identifier rubyid_values_at'>values_at</span><span class='lparen'>(</span><span class='symbol'>:catalog</span><span class='comma'>,</span> <span class='symbol'>:schema</span><span class='rparen'>)</span>
|
1145
|
+
<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='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='label'>schema:</span> <span class='id identifier rubyid_schema'>schema</span><span class='comma'>,</span> <span class='label'>catalog:</span> <span class='id identifier rubyid_catalog'>catalog</span><span class='rparen'>)</span>
|
1146
|
+
<span class='id identifier rubyid_db'>db</span> <span class='op'>=</span> <span class='id identifier rubyid_db_table'>db_table</span><span class='period'>.</span><span class='id identifier rubyid_catalog'>catalog</span> <span class='op'>||</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:database</span><span class='rbracket'>]</span>
|
1147
|
+
<span class='id identifier rubyid_sql'>sql</span> <span class='op'>=</span> <span class='heredoc_beg'><<~SQL</span>
|
1148
|
+
<span class='tstring_content'> SELECT column_name, data_type, numeric_precision, numeric_scale, character_maximum_length
|
1149
|
+
</span><span class='tstring_content'> FROM </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_db'>db</span><span class='embexpr_end'>}</span><span class='tstring_content'>.information_schema.columns
|
1150
|
+
</span><span class='heredoc_end'> SQL
|
1151
|
+
</span>
|
1152
|
+
<span class='id identifier rubyid_conditions'>conditions</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>table_name = '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_db_table'>db_table</span><span class='period'>.</span><span class='id identifier rubyid_physical_name'>physical_name</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span><span class='embexpr_end'>}</span><span class='tstring_content'>'</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span>
|
1153
|
+
<span class='id identifier rubyid_conditions'>conditions</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>table_schema = '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_db_table'>db_table</span><span class='period'>.</span><span class='id identifier rubyid_schema'>schema</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span><span class='embexpr_end'>}</span><span class='tstring_content'>'</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_db_table'>db_table</span><span class='period'>.</span><span class='id identifier rubyid_schema'>schema</span>
|
1154
|
+
|
1155
|
+
<span class='id identifier rubyid_columns'>columns</span> <span class='op'>=</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sql'>sql</span><span class='embexpr_end'>}</span><span class='tstring_content'> WHERE </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_conditions'>conditions</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'> AND </span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1156
|
+
|
1157
|
+
<span class='id identifier rubyid_columns'>columns</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>
|
1158
|
+
<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>
|
1159
|
+
<span class='label'>name:</span> <span class='id identifier rubyid_col'>col</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='op'>&.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='comma'>,</span>
|
1160
|
+
<span class='label'>data_type:</span> <span class='id identifier rubyid_col'>col</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='op'>&.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='comma'>,</span>
|
1161
|
+
<span class='label'>precision:</span> <span class='id identifier rubyid_col'>col</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
1162
|
+
<span class='label'>scale:</span> <span class='id identifier rubyid_col'>col</span><span class='lbracket'>[</span><span class='int'>3</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
1163
|
+
<span class='label'>max_char_length:</span> <span class='id identifier rubyid_col'>col</span><span class='lbracket'>[</span><span class='int'>4</span><span class='rbracket'>]</span>
|
1164
|
+
<span class='rparen'>)</span>
|
1165
|
+
<span class='kw'>end</span>
|
1166
|
+
|
1167
|
+
<span class='id identifier rubyid_db_table'>db_table</span>
|
1168
|
+
<span class='kw'>end</span></pre>
|
1169
|
+
</td>
|
1170
|
+
</tr>
|
1171
|
+
</table>
|
1172
|
+
</div>
|
1173
|
+
|
1174
|
+
<div class="method_details ">
|
1175
|
+
<h3 class="signature " id="stats-instance_method">
|
1176
|
+
|
1177
|
+
#<strong>stats</strong>(table, date_column: nil) ⇒ <tt><span class='object_link'><a href="../Table.html" title="DWH::Table (class)">DWH::Table</a></span></tt>
|
1178
|
+
|
1179
|
+
|
1180
|
+
|
1181
|
+
|
1182
|
+
|
1183
|
+
</h3><div class="docstring">
|
1184
|
+
<div class="discussion">
|
1185
|
+
<p>Returns basic stats of a given table. Will typically include row_count,
|
1186
|
+
date_start, and date_end.</p>
|
1187
|
+
|
1188
|
+
|
1189
|
+
</div>
|
1190
|
+
</div>
|
1191
|
+
<div class="tags">
|
1192
|
+
|
1193
|
+
<div class="examples">
|
1194
|
+
<h4 class="tag_title">Examples:</h4>
|
1195
|
+
|
1196
|
+
|
1197
|
+
<pre class="example code"><code><span class='id identifier rubyid_stats'>stats</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>public.big_table</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>date_column:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>fact_date</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1198
|
+
<span class='id identifier rubyid_stats'>stats</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>big_table</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1199
|
+
<span class='id identifier rubyid_stats'>stats</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>big_table</span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='label'>schema:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>public</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span></code></pre>
|
1200
|
+
|
1201
|
+
</div>
|
1202
|
+
<p class="tag_title">Parameters:</p>
|
1203
|
+
<ul class="param">
|
1204
|
+
|
1205
|
+
<li>
|
1206
|
+
|
1207
|
+
<span class='name'>table</span>
|
1208
|
+
|
1209
|
+
|
1210
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1211
|
+
|
1212
|
+
|
1213
|
+
|
1214
|
+
—
|
1215
|
+
<div class='inline'><p>table name</p>
|
1216
|
+
</div>
|
1217
|
+
|
1218
|
+
</li>
|
1219
|
+
|
1220
|
+
<li>
|
1221
|
+
|
1222
|
+
<span class='name'>date_column</span>
|
1223
|
+
|
1224
|
+
|
1225
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1226
|
+
|
1227
|
+
|
1228
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1229
|
+
|
1230
|
+
|
1231
|
+
—
|
1232
|
+
<div class='inline'><p>optional date column to use to find range</p>
|
1233
|
+
</div>
|
1234
|
+
|
1235
|
+
</li>
|
1236
|
+
|
1237
|
+
<li>
|
1238
|
+
|
1239
|
+
<span class='name'>qualifiers</span>
|
1240
|
+
|
1241
|
+
|
1242
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1243
|
+
|
1244
|
+
|
1245
|
+
|
1246
|
+
—
|
1247
|
+
<div class='inline'><p>a customizable set of options</p>
|
1248
|
+
</div>
|
1249
|
+
|
1250
|
+
</li>
|
1251
|
+
|
1252
|
+
</ul>
|
1253
|
+
|
1254
|
+
|
1255
|
+
|
1256
|
+
|
1257
|
+
|
1258
|
+
|
1259
|
+
|
1260
|
+
<p class="tag_title">Returns:</p>
|
1261
|
+
<ul class="return">
|
1262
|
+
|
1263
|
+
<li>
|
1264
|
+
|
1265
|
+
|
1266
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Table.html" title="DWH::Table (class)">DWH::Table</a></span></tt>)</span>
|
1267
|
+
|
1268
|
+
|
1269
|
+
|
1270
|
+
</li>
|
1271
|
+
|
1272
|
+
</ul>
|
1273
|
+
<p class="tag_title">Raises:</p>
|
1274
|
+
<ul class="raise">
|
1275
|
+
|
1276
|
+
<li>
|
1277
|
+
|
1278
|
+
|
1279
|
+
<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>
|
1280
|
+
|
1281
|
+
|
1282
|
+
|
1283
|
+
</li>
|
1284
|
+
|
1285
|
+
</ul>
|
1286
|
+
|
1287
|
+
</div><table class="source_code">
|
1288
|
+
<tr>
|
1289
|
+
<td>
|
1290
|
+
<pre class="lines">
|
1291
|
+
|
1292
|
+
|
1293
|
+
254
|
1294
|
+
255
|
1295
|
+
256
|
1296
|
+
257
|
1297
|
+
258
|
1298
|
+
259
|
1299
|
+
260
|
1300
|
+
261
|
1301
|
+
262
|
1302
|
+
263
|
1303
|
+
264
|
1304
|
+
265
|
1305
|
+
266
|
1306
|
+
267
|
1307
|
+
268
|
1308
|
+
269</pre>
|
1309
|
+
</td>
|
1310
|
+
<td>
|
1311
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/snowflake.rb', line 254</span>
|
1312
|
+
|
1313
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_stats'>stats</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='label'>date_column:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1314
|
+
<span class='id identifier rubyid_date_fields'>date_fields</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_date_column'>date_column</span>
|
1315
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, MIN(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_date_column'>date_column</span><span class='embexpr_end'>}</span><span class='tstring_content'>) AS date_start, MAX(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_date_column'>date_column</span><span class='embexpr_end'>}</span><span class='tstring_content'>) AS date_end</span><span class='tstring_end'>"</span></span>
|
1316
|
+
<span class='kw'>else</span>
|
1317
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>, NULL AS date_start, NULL AS date_end</span><span class='tstring_end'>'</span></span>
|
1318
|
+
<span class='kw'>end</span>
|
1319
|
+
|
1320
|
+
<span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>SELECT COUNT(*) AS row_count</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_date_fields'>date_fields</span><span class='embexpr_end'>}</span><span class='tstring_content'> FROM </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_table'>table</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1321
|
+
<span class='id identifier rubyid_cols'>cols</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
1322
|
+
|
1323
|
+
<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>
|
1324
|
+
<span class='label'>row_count:</span> <span class='id identifier rubyid_cols'>cols</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
1325
|
+
<span class='label'>date_start:</span> <span class='id identifier rubyid_cols'>cols</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
1326
|
+
<span class='label'>date_end:</span> <span class='id identifier rubyid_cols'>cols</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span>
|
1327
|
+
<span class='rparen'>)</span>
|
1328
|
+
<span class='kw'>end</span></pre>
|
1329
|
+
</td>
|
1330
|
+
</tr>
|
1331
|
+
</table>
|
1332
|
+
</div>
|
1333
|
+
|
1334
|
+
<div class="method_details ">
|
1335
|
+
<h3 class="signature " id="stream-instance_method">
|
1336
|
+
|
1337
|
+
#<strong>stream</strong>(sql) {|chunk| ... } ⇒ <tt>Object</tt>
|
1338
|
+
|
1339
|
+
|
1340
|
+
|
1341
|
+
|
1342
|
+
|
1343
|
+
</h3><div class="docstring">
|
1344
|
+
<div class="discussion">
|
1345
|
+
<p>Execute SQL query and yield streamed results</p>
|
1346
|
+
|
1347
|
+
|
1348
|
+
</div>
|
1349
|
+
</div>
|
1350
|
+
<div class="tags">
|
1351
|
+
<p class="tag_title">Parameters:</p>
|
1352
|
+
<ul class="param">
|
1353
|
+
|
1354
|
+
<li>
|
1355
|
+
|
1356
|
+
<span class='name'>sql</span>
|
1357
|
+
|
1358
|
+
|
1359
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1360
|
+
|
1361
|
+
|
1362
|
+
|
1363
|
+
—
|
1364
|
+
<div class='inline'><p>SQL query to execute</p>
|
1365
|
+
</div>
|
1366
|
+
|
1367
|
+
</li>
|
1368
|
+
|
1369
|
+
</ul>
|
1370
|
+
|
1371
|
+
<p class="tag_title">Yields:</p>
|
1372
|
+
<ul class="yield">
|
1373
|
+
|
1374
|
+
<li>
|
1375
|
+
|
1376
|
+
|
1377
|
+
<span class='type'>(<tt>chunk</tt>)</span>
|
1378
|
+
|
1379
|
+
|
1380
|
+
|
1381
|
+
—
|
1382
|
+
<div class='inline'><p>yields each chunk of data as it’s processed</p>
|
1383
|
+
</div>
|
1384
|
+
|
1385
|
+
</li>
|
1386
|
+
|
1387
|
+
</ul>
|
1388
|
+
|
1389
|
+
</div><table class="source_code">
|
1390
|
+
<tr>
|
1391
|
+
<td>
|
1392
|
+
<pre class="lines">
|
1393
|
+
|
1394
|
+
|
1395
|
+
195
|
1396
|
+
196
|
1397
|
+
197
|
1398
|
+
198
|
1399
|
+
199
|
1400
|
+
200</pre>
|
1401
|
+
</td>
|
1402
|
+
<td>
|
1403
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/snowflake.rb', line 195</span>
|
1404
|
+
|
1405
|
+
<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>
|
1406
|
+
<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>
|
1407
|
+
<span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='id identifier rubyid_submit_query'>submit_query</span><span class='lparen'>(</span><span class='id identifier rubyid_sql'>sql</span><span class='rparen'>)</span>
|
1408
|
+
<span class='id identifier rubyid_fetch_data'>fetch_data</span><span class='lparen'>(</span><span class='id identifier rubyid_handle_query_response'>handle_query_response</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='label'>proc:</span> <span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1409
|
+
<span class='kw'>end</span>
|
1410
|
+
<span class='kw'>end</span></pre>
|
1411
|
+
</td>
|
1412
|
+
</tr>
|
1413
|
+
</table>
|
1414
|
+
</div>
|
1415
|
+
|
1416
|
+
<div class="method_details ">
|
1417
|
+
<h3 class="signature " id="tables-instance_method">
|
1418
|
+
|
1419
|
+
#<strong>tables</strong>(**qualifiers) ⇒ <tt>Array<String></tt>
|
1420
|
+
|
1421
|
+
|
1422
|
+
|
1423
|
+
|
1424
|
+
|
1425
|
+
</h3><div class="docstring">
|
1426
|
+
<div class="discussion">
|
1427
|
+
<p>Get all tables available in the
|
1428
|
+
target db. It will use the default catalog and schema
|
1429
|
+
config only specified here.</p>
|
1430
|
+
|
1431
|
+
<p>For metadata queries table_catalog and database are
|
1432
|
+
the same in the Snowflake information_schema.</p>
|
1433
|
+
|
1434
|
+
<p>However, we need to prefix the information_schema table with
|
1435
|
+
the db name to correctly constrain to the target db.</p>
|
1436
|
+
|
1437
|
+
|
1438
|
+
</div>
|
1439
|
+
</div>
|
1440
|
+
<div class="tags">
|
1441
|
+
<p class="tag_title">Parameters:</p>
|
1442
|
+
<ul class="param">
|
1443
|
+
|
1444
|
+
<li>
|
1445
|
+
|
1446
|
+
<span class='name'>qualifiers</span>
|
1447
|
+
|
1448
|
+
|
1449
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1450
|
+
|
1451
|
+
|
1452
|
+
|
1453
|
+
—
|
1454
|
+
<div class='inline'><p>a customizable set of options</p>
|
1455
|
+
</div>
|
1456
|
+
|
1457
|
+
</li>
|
1458
|
+
|
1459
|
+
</ul>
|
1460
|
+
|
1461
|
+
|
1462
|
+
|
1463
|
+
|
1464
|
+
<p class="tag_title">Options Hash (<tt>**qualifiers</tt>):</p>
|
1465
|
+
<ul class="option">
|
1466
|
+
|
1467
|
+
<li>
|
1468
|
+
<span class="name">:catalog</span>
|
1469
|
+
<span class="type">(<tt>String</tt>)</span>
|
1470
|
+
<span class="default">
|
1471
|
+
|
1472
|
+
</span>
|
1473
|
+
|
1474
|
+
— <div class='inline'><p>optional catalog or equivalent name space.
|
1475
|
+
will be ignored if the adapter doesn’t support</p>
|
1476
|
+
</div>
|
1477
|
+
|
1478
|
+
</li>
|
1479
|
+
|
1480
|
+
<li>
|
1481
|
+
<span class="name">:schema</span>
|
1482
|
+
<span class="type">(<tt>String</tt>)</span>
|
1483
|
+
<span class="default">
|
1484
|
+
|
1485
|
+
</span>
|
1486
|
+
|
1487
|
+
— <div class='inline'><p>optional schema to scope to.
|
1488
|
+
will be ignored if the adapter doesn’t support</p>
|
1489
|
+
</div>
|
1490
|
+
|
1491
|
+
</li>
|
1492
|
+
|
1493
|
+
</ul>
|
1494
|
+
|
1495
|
+
|
1496
|
+
<p class="tag_title">Returns:</p>
|
1497
|
+
<ul class="return">
|
1498
|
+
|
1499
|
+
<li>
|
1500
|
+
|
1501
|
+
|
1502
|
+
<span class='type'>(<tt>Array<String></tt>)</span>
|
1503
|
+
|
1504
|
+
|
1505
|
+
|
1506
|
+
</li>
|
1507
|
+
|
1508
|
+
<li>
|
1509
|
+
|
1510
|
+
|
1511
|
+
<span class='type'>(<tt>Array<String></tt>)</span>
|
1512
|
+
|
1513
|
+
|
1514
|
+
|
1515
|
+
—
|
1516
|
+
<div class='inline'><p>list of table names</p>
|
1517
|
+
</div>
|
1518
|
+
|
1519
|
+
</li>
|
1520
|
+
|
1521
|
+
</ul>
|
1522
|
+
|
1523
|
+
</div><table class="source_code">
|
1524
|
+
<tr>
|
1525
|
+
<td>
|
1526
|
+
<pre class="lines">
|
1527
|
+
|
1528
|
+
|
1529
|
+
210
|
1530
|
+
211
|
1531
|
+
212
|
1532
|
+
213
|
1533
|
+
214
|
1534
|
+
215
|
1535
|
+
216
|
1536
|
+
217
|
1537
|
+
218
|
1538
|
+
219
|
1539
|
+
220
|
1540
|
+
221
|
1541
|
+
222
|
1542
|
+
223</pre>
|
1543
|
+
</td>
|
1544
|
+
<td>
|
1545
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/snowflake.rb', line 210</span>
|
1546
|
+
|
1547
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_tables'>tables</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='rparen'>)</span>
|
1548
|
+
<span class='id identifier rubyid_catalog'>catalog</span><span class='comma'>,</span> <span class='id identifier rubyid_schema'>schema</span> <span class='op'>=</span> <span class='id identifier rubyid_qualifiers'>qualifiers</span><span class='period'>.</span><span class='id identifier rubyid_values_at'>values_at</span><span class='lparen'>(</span><span class='symbol'>:catalog</span><span class='comma'>,</span> <span class='symbol'>:schema</span><span class='rparen'>)</span>
|
1549
|
+
|
1550
|
+
<span class='id identifier rubyid_db'>db</span> <span class='op'>=</span> <span class='id identifier rubyid_catalog'>catalog</span> <span class='op'>||</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:database</span><span class='rbracket'>]</span>
|
1551
|
+
<span class='id identifier rubyid_sql'>sql</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>SELECT table_name FROM </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_db'>db</span><span class='embexpr_end'>}</span><span class='tstring_content'>.information_schema.tables</span><span class='tstring_end'>"</span></span>
|
1552
|
+
<span class='id identifier rubyid_conditions'>conditions</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
1553
|
+
|
1554
|
+
<span class='id identifier rubyid_conditions'>conditions</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>table_schema = '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_schema'>schema</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span><span class='embexpr_end'>}</span><span class='tstring_content'>'</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_schema'>schema</span>
|
1555
|
+
|
1556
|
+
<span class='id identifier rubyid_sql'>sql</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> WHERE </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_conditions'>conditions</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'> AND </span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_conditions'>conditions</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span>
|
1557
|
+
|
1558
|
+
<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>
|
1559
|
+
<span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span>
|
1560
|
+
<span class='kw'>end</span></pre>
|
1561
|
+
</td>
|
1562
|
+
</tr>
|
1563
|
+
</table>
|
1564
|
+
</div>
|
1565
|
+
|
1566
|
+
<div class="method_details ">
|
1567
|
+
<h3 class="signature " id="test_connection-instance_method">
|
1568
|
+
|
1569
|
+
#<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>
|
1570
|
+
|
1571
|
+
|
1572
|
+
|
1573
|
+
|
1574
|
+
|
1575
|
+
</h3><div class="docstring">
|
1576
|
+
<div class="discussion">
|
1577
|
+
<p>Tests the connection to the target database and returns true
|
1578
|
+
if successful, or raise Exception or false
|
1579
|
+
connection object or self</p>
|
1580
|
+
|
1581
|
+
|
1582
|
+
</div>
|
1583
|
+
</div>
|
1584
|
+
<div class="tags">
|
1585
|
+
|
1586
|
+
<p class="tag_title">Returns:</p>
|
1587
|
+
<ul class="return">
|
1588
|
+
|
1589
|
+
<li>
|
1590
|
+
|
1591
|
+
|
1592
|
+
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="DWH::Adapters::Boolean (class)">Boolean</a></span></tt>)</span>
|
1593
|
+
|
1594
|
+
|
1595
|
+
|
1596
|
+
</li>
|
1597
|
+
|
1598
|
+
</ul>
|
1599
|
+
<p class="tag_title">Raises:</p>
|
1600
|
+
<ul class="raise">
|
1601
|
+
|
1602
|
+
<li>
|
1603
|
+
|
1604
|
+
|
1605
|
+
<span class='type'>(<tt><span class='object_link'><a href="../ConnectionError.html" title="DWH::ConnectionError (class)">ConnectionError</a></span></tt>)</span>
|
1606
|
+
|
1607
|
+
|
1608
|
+
|
1609
|
+
—
|
1610
|
+
<div class='inline'><p>when a connection cannot be made</p>
|
1611
|
+
</div>
|
1612
|
+
|
1613
|
+
</li>
|
1614
|
+
|
1615
|
+
</ul>
|
1616
|
+
|
1617
|
+
</div><table class="source_code">
|
1618
|
+
<tr>
|
1619
|
+
<td>
|
1620
|
+
<pre class="lines">
|
1621
|
+
|
1622
|
+
|
1623
|
+
157
|
1624
|
+
158
|
1625
|
+
159
|
1626
|
+
160
|
1627
|
+
161
|
1628
|
+
162
|
1629
|
+
163
|
1630
|
+
164
|
1631
|
+
165</pre>
|
1632
|
+
</td>
|
1633
|
+
<td>
|
1634
|
+
<pre class="code"><span class="info file"># File 'lib/dwh/adapters/snowflake.rb', line 157</span>
|
1635
|
+
|
1636
|
+
<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>
|
1637
|
+
<span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>SELECT 1</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
1638
|
+
<span class='kw'>true</span>
|
1639
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
1640
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../ConnectionError.html" title="DWH::ConnectionError (class)">ConnectionError</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Failed to connect to Snowflake: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_raise_exception'>raise_exception</span>
|
1641
|
+
|
1642
|
+
<span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Connection test failed: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
1643
|
+
<span class='kw'>false</span>
|
1644
|
+
<span class='kw'>end</span></pre>
|
1645
|
+
</td>
|
1646
|
+
</tr>
|
1647
|
+
</table>
|
1648
|
+
</div>
|
1649
|
+
|
1650
|
+
</div>
|
1651
|
+
|
1652
|
+
</div>
|
1653
|
+
|
1654
|
+
<div id="footer">
|
1655
|
+
Generated on Fri Aug 22 08:31:22 2025 by
|
1656
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1657
|
+
0.9.37 (ruby-3.4.4).
|
1658
|
+
</div>
|
1659
|
+
|
1660
|
+
</div>
|
1661
|
+
</body>
|
1662
|
+
</html>
|