apache-airflow-providers-teradata 1.0.10__py3-none-any.whl → 2.0.0__py3-none-any.whl
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.
Potentially problematic release.
This version of apache-airflow-providers-teradata might be problematic. Click here for more details.
- airflow/providers/teradata/LICENSE +253 -0
- airflow/providers/teradata/__init__.py +26 -1
- airflow/providers/teradata/get_provider_info.py +43 -24
- airflow/providers/teradata/hooks/teradata.py +202 -0
- airflow/providers/teradata/operators/teradata.py +64 -0
- airflow/providers/teradata/transfers/teradata_to_teradata.py +101 -0
- apache_airflow_providers_teradata-2.0.0.dist-info/METADATA +137 -0
- apache_airflow_providers_teradata-2.0.0.dist-info/RECORD +13 -0
- {apache_airflow_providers_teradata-1.0.10.dist-info → apache_airflow_providers_teradata-2.0.0.dist-info}/WHEEL +1 -2
- apache_airflow_providers_teradata-2.0.0.dist-info/entry_points.txt +3 -0
- airflow/providers/teradata/example_dags/example_execute_bteq.py +0 -51
- airflow/providers/teradata/example_dags/example_export_csv.py +0 -48
- airflow/providers/teradata/example_dags/example_load_csv.py +0 -69
- airflow/providers/teradata/hooks/ttu.py +0 -394
- airflow/providers/teradata/operators/bteq.py +0 -70
- airflow/providers/teradata/operators/fastexport.py +0 -77
- airflow/providers/teradata/operators/fastload.py +0 -105
- apache_airflow_providers_teradata-1.0.10.dist-info/AUTHORS.rst +0 -13
- apache_airflow_providers_teradata-1.0.10.dist-info/LICENSE +0 -22
- apache_airflow_providers_teradata-1.0.10.dist-info/METADATA +0 -53
- apache_airflow_providers_teradata-1.0.10.dist-info/RECORD +0 -19
- apache_airflow_providers_teradata-1.0.10.dist-info/entry_points.txt +0 -3
- apache_airflow_providers_teradata-1.0.10.dist-info/top_level.txt +0 -1
- /airflow/providers/teradata/{example_dags → transfers}/__init__.py +0 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
203
|
+
============================================================================
|
|
204
|
+
APACHE AIRFLOW SUBCOMPONENTS:
|
|
205
|
+
|
|
206
|
+
The Apache Airflow project contains subcomponents with separate copyright
|
|
207
|
+
notices and license terms. Your use of the source code for the these
|
|
208
|
+
subcomponents is subject to the terms and conditions of the following
|
|
209
|
+
licenses.
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
========================================================================
|
|
213
|
+
Third party Apache 2.0 licenses
|
|
214
|
+
========================================================================
|
|
215
|
+
|
|
216
|
+
The following components are provided under the Apache 2.0 License.
|
|
217
|
+
See project link for details. The text of each license is also included
|
|
218
|
+
at licenses/LICENSE-[project].txt.
|
|
219
|
+
|
|
220
|
+
(ALv2 License) hue v4.3.0 (https://github.com/cloudera/hue/)
|
|
221
|
+
(ALv2 License) jqclock v2.3.0 (https://github.com/JohnRDOrazio/jQuery-Clock-Plugin)
|
|
222
|
+
(ALv2 License) bootstrap3-typeahead v4.0.2 (https://github.com/bassjobsen/Bootstrap-3-Typeahead)
|
|
223
|
+
(ALv2 License) connexion v2.7.0 (https://github.com/zalando/connexion)
|
|
224
|
+
|
|
225
|
+
========================================================================
|
|
226
|
+
MIT licenses
|
|
227
|
+
========================================================================
|
|
228
|
+
|
|
229
|
+
The following components are provided under the MIT License. See project link for details.
|
|
230
|
+
The text of each license is also included at licenses/LICENSE-[project].txt.
|
|
231
|
+
|
|
232
|
+
(MIT License) jquery v3.5.1 (https://jquery.org/license/)
|
|
233
|
+
(MIT License) dagre-d3 v0.6.4 (https://github.com/cpettitt/dagre-d3)
|
|
234
|
+
(MIT License) bootstrap v3.4.1 (https://github.com/twbs/bootstrap/)
|
|
235
|
+
(MIT License) d3-tip v0.9.1 (https://github.com/Caged/d3-tip)
|
|
236
|
+
(MIT License) dataTables v1.10.25 (https://datatables.net)
|
|
237
|
+
(MIT License) normalize.css v3.0.2 (http://necolas.github.io/normalize.css/)
|
|
238
|
+
(MIT License) ElasticMock v1.3.2 (https://github.com/vrcmarcos/elasticmock)
|
|
239
|
+
(MIT License) MomentJS v2.24.0 (http://momentjs.com/)
|
|
240
|
+
(MIT License) eonasdan-bootstrap-datetimepicker v4.17.49 (https://github.com/eonasdan/bootstrap-datetimepicker/)
|
|
241
|
+
|
|
242
|
+
========================================================================
|
|
243
|
+
BSD 3-Clause licenses
|
|
244
|
+
========================================================================
|
|
245
|
+
The following components are provided under the BSD 3-Clause license. See project links for details.
|
|
246
|
+
The text of each license is also included at licenses/LICENSE-[project].txt.
|
|
247
|
+
|
|
248
|
+
(BSD 3 License) d3 v5.16.0 (https://d3js.org)
|
|
249
|
+
(BSD 3 License) d3-shape v2.1.0 (https://github.com/d3/d3-shape)
|
|
250
|
+
(BSD 3 License) cgroupspy 0.2.1 (https://github.com/cloudsigma/cgroupspy)
|
|
251
|
+
|
|
252
|
+
========================================================================
|
|
253
|
+
See licenses/LICENSES-ui.txt for packages used in `/airflow/www`
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#
|
|
2
1
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
2
|
# or more contributor license agreements. See the NOTICE file
|
|
4
3
|
# distributed with this work for additional information
|
|
@@ -15,3 +14,29 @@
|
|
|
15
14
|
# KIND, either express or implied. See the License for the
|
|
16
15
|
# specific language governing permissions and limitations
|
|
17
16
|
# under the License.
|
|
17
|
+
#
|
|
18
|
+
# NOTE! THIS FILE IS AUTOMATICALLY GENERATED AND WILL BE
|
|
19
|
+
# OVERWRITTEN WHEN PREPARING DOCUMENTATION FOR THE PACKAGES.
|
|
20
|
+
#
|
|
21
|
+
# IF YOU WANT TO MODIFY THIS FILE, YOU SHOULD MODIFY THE TEMPLATE
|
|
22
|
+
# `PROVIDER__INIT__PY_TEMPLATE.py.jinja2` IN the `dev/breeze/src/airflow_breeze/templates` DIRECTORY
|
|
23
|
+
#
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
import packaging.version
|
|
27
|
+
|
|
28
|
+
__all__ = ["__version__"]
|
|
29
|
+
|
|
30
|
+
__version__ = "2.0.0"
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
from airflow import __version__ as airflow_version
|
|
34
|
+
except ImportError:
|
|
35
|
+
from airflow.version import version as airflow_version
|
|
36
|
+
|
|
37
|
+
if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
|
|
38
|
+
"2.6.0"
|
|
39
|
+
):
|
|
40
|
+
raise RuntimeError(
|
|
41
|
+
f"The package `apache-airflow-providers-teradata:{__version__}` needs Apache Airflow 2.6.0+"
|
|
42
|
+
)
|
|
@@ -14,39 +14,58 @@
|
|
|
14
14
|
# KIND, either express or implied. See the License for the
|
|
15
15
|
# specific language governing permissions and limitations
|
|
16
16
|
# under the License.
|
|
17
|
+
|
|
18
|
+
# NOTE! THIS FILE IS AUTOMATICALLY GENERATED AND WILL BE
|
|
19
|
+
# OVERWRITTEN WHEN PREPARING PACKAGES.
|
|
20
|
+
#
|
|
21
|
+
# IF YOU WANT TO MODIFY THIS FILE, YOU SHOULD MODIFY THE TEMPLATE
|
|
22
|
+
# `get_provider_info_TEMPLATE.py.jinja2` IN the `dev/breeze/src/airflow_breeze/templates` DIRECTORY
|
|
23
|
+
|
|
24
|
+
|
|
17
25
|
def get_provider_info():
|
|
18
26
|
return {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
"package-name": "apache-airflow-providers-teradata",
|
|
28
|
+
"name": "Teradata",
|
|
29
|
+
"description": "`Teradata <https://www.teradata.com/>`__\n",
|
|
30
|
+
"state": "ready",
|
|
31
|
+
"source-date-epoch": 1700148082,
|
|
32
|
+
"versions": ["2.0.0"],
|
|
33
|
+
"dependencies": [
|
|
34
|
+
"apache-airflow>=2.6.0",
|
|
35
|
+
"apache-airflow-providers-common-sql>=1.3.1",
|
|
36
|
+
"teradatasqlalchemy>=17.20.0.0",
|
|
37
|
+
"teradatasql>=17.20.0.28",
|
|
38
|
+
],
|
|
39
|
+
"integrations": [
|
|
24
40
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
41
|
+
"integration-name": "Teradata",
|
|
42
|
+
"external-doc-url": "https://www.teradata.com/",
|
|
43
|
+
"how-to-guide": ["/docs/apache-airflow-providers-teradata/operators/teradata.rst"],
|
|
44
|
+
"logo": "/integration-logos/teradata/Teradata.png",
|
|
45
|
+
"tags": ["software"],
|
|
28
46
|
}
|
|
29
|
-
|
|
30
47
|
],
|
|
31
|
-
|
|
48
|
+
"operators": [
|
|
32
49
|
{
|
|
33
|
-
|
|
34
|
-
|
|
50
|
+
"integration-name": "Teradata",
|
|
51
|
+
"python-modules": ["airflow.providers.teradata.operators.teradata"],
|
|
35
52
|
}
|
|
36
53
|
],
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
54
|
+
"hooks": [
|
|
55
|
+
{"integration-name": "Teradata", "python-modules": ["airflow.providers.teradata.hooks.teradata"]}
|
|
56
|
+
],
|
|
57
|
+
"transfers": [
|
|
42
58
|
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
"source-integration-name": "Teradata",
|
|
60
|
+
"target-integration-name": "Teradata",
|
|
61
|
+
"python-module": "airflow.providers.teradata.transfers.teradata_to_teradata",
|
|
62
|
+
"how-to-guide": "/docs/apache-airflow-providers-teradata/operators/teradata_to_teradata.rst",
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"connection-types": [
|
|
46
66
|
{
|
|
47
|
-
|
|
48
|
-
|
|
67
|
+
"hook-class-name": "airflow.providers.teradata.hooks.teradata.TeradataHook",
|
|
68
|
+
"connection-type": "teradata",
|
|
49
69
|
}
|
|
50
70
|
],
|
|
51
|
-
|
|
52
|
-
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
# or more contributor license agreements. See the NOTICE file
|
|
4
|
+
# distributed with this work for additional information
|
|
5
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
# to you under the Apache License, Version 2.0 (the
|
|
7
|
+
# "License"); you may not use this file except in compliance
|
|
8
|
+
# with the License. You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
|
13
|
+
# software distributed under the License is distributed on an
|
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
# KIND, either express or implied. See the License for the
|
|
16
|
+
# specific language governing permissions and limitations
|
|
17
|
+
# under the License.
|
|
18
|
+
"""An Airflow Hook for interacting with Teradata SQL Server."""
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
from typing import TYPE_CHECKING, Any
|
|
22
|
+
|
|
23
|
+
import sqlalchemy
|
|
24
|
+
import teradatasql
|
|
25
|
+
from teradatasql import TeradataConnection
|
|
26
|
+
|
|
27
|
+
from airflow.providers.common.sql.hooks.sql import DbApiHook
|
|
28
|
+
|
|
29
|
+
if TYPE_CHECKING:
|
|
30
|
+
from airflow.models.connection import Connection
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class TeradataHook(DbApiHook):
|
|
34
|
+
"""General hook for interacting with Teradata SQL Database.
|
|
35
|
+
|
|
36
|
+
This module contains basic APIs to connect to and interact with Teradata SQL Database. It uses teradatasql
|
|
37
|
+
client internally as a database driver for connecting to Teradata database. The config parameters like
|
|
38
|
+
Teradata DB Server URL, username, password and database name are fetched from the predefined connection
|
|
39
|
+
config connection_id. It raises an airflow error if the given connection id doesn't exist.
|
|
40
|
+
|
|
41
|
+
You can also specify ssl parameters in the extra field of your connection
|
|
42
|
+
as ``{"sslmode": "require", "sslcert": "/path/to/cert.pem", etc}``.
|
|
43
|
+
|
|
44
|
+
.. seealso::
|
|
45
|
+
- :ref:`Teradata API connection <howto/connection:teradata>`
|
|
46
|
+
|
|
47
|
+
:param args: passed to DbApiHook
|
|
48
|
+
:param database: The Teradata database to connect to.
|
|
49
|
+
:param kwargs: passed to DbApiHook
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
# Override to provide the connection name.
|
|
53
|
+
conn_name_attr = "teradata_conn_id"
|
|
54
|
+
|
|
55
|
+
# Override to have a default connection id for a particular dbHook
|
|
56
|
+
default_conn_name = "teradata_default"
|
|
57
|
+
|
|
58
|
+
# Override if this db supports autocommit.
|
|
59
|
+
supports_autocommit = True
|
|
60
|
+
|
|
61
|
+
# Override this for hook to have a custom name in the UI selection
|
|
62
|
+
conn_type = "teradata"
|
|
63
|
+
|
|
64
|
+
# Override hook name to give descriptive name for hook
|
|
65
|
+
hook_name = "Teradata"
|
|
66
|
+
|
|
67
|
+
# Override with the Teradata specific placeholder parameter string used for insert queries
|
|
68
|
+
placeholder: str = "?"
|
|
69
|
+
|
|
70
|
+
# Override SQL query to be used for testing database connection
|
|
71
|
+
_test_connection_sql = "select 1"
|
|
72
|
+
|
|
73
|
+
def __init__(
|
|
74
|
+
self,
|
|
75
|
+
*args,
|
|
76
|
+
database: str | None = None,
|
|
77
|
+
**kwargs,
|
|
78
|
+
) -> None:
|
|
79
|
+
super().__init__(*args, schema=database, **kwargs)
|
|
80
|
+
|
|
81
|
+
def get_conn(self) -> TeradataConnection:
|
|
82
|
+
"""Create and return a Teradata Connection object using teradatasql client.
|
|
83
|
+
|
|
84
|
+
Establishes connection to a Teradata SQL database using config corresponding to teradata_conn_id.
|
|
85
|
+
|
|
86
|
+
:return: a Teradata connection object
|
|
87
|
+
"""
|
|
88
|
+
teradata_conn_config: dict = self._get_conn_config_teradatasql()
|
|
89
|
+
teradata_conn = teradatasql.connect(**teradata_conn_config)
|
|
90
|
+
return teradata_conn
|
|
91
|
+
|
|
92
|
+
def bulk_insert_rows(
|
|
93
|
+
self,
|
|
94
|
+
table: str,
|
|
95
|
+
rows: list[tuple],
|
|
96
|
+
target_fields: list[str] | None = None,
|
|
97
|
+
commit_every: int = 5000,
|
|
98
|
+
):
|
|
99
|
+
"""Insert bulk of records into Teradata SQL Database.
|
|
100
|
+
|
|
101
|
+
This uses prepared statements via `executemany()`. For best performance,
|
|
102
|
+
pass in `rows` as an iterator.
|
|
103
|
+
|
|
104
|
+
:param table: target Teradata database table, use dot notation to target a
|
|
105
|
+
specific database
|
|
106
|
+
:param rows: the rows to insert into the table
|
|
107
|
+
:param target_fields: the names of the columns to fill in the table, default None.
|
|
108
|
+
If None, each rows should have some order as table columns name
|
|
109
|
+
:param commit_every: the maximum number of rows to insert in one transaction
|
|
110
|
+
Default 5000. Set greater than 0. Set 1 to insert each row in each transaction
|
|
111
|
+
"""
|
|
112
|
+
if not rows:
|
|
113
|
+
raise ValueError("parameter rows could not be None or empty iterable")
|
|
114
|
+
conn = self.get_conn()
|
|
115
|
+
if self.supports_autocommit:
|
|
116
|
+
self.set_autocommit(conn, False)
|
|
117
|
+
cursor = conn.cursor()
|
|
118
|
+
cursor.fast_executemany = True
|
|
119
|
+
values_base = target_fields if target_fields else rows[0]
|
|
120
|
+
prepared_stm = "INSERT INTO {tablename} {columns} VALUES ({values})".format(
|
|
121
|
+
tablename=table,
|
|
122
|
+
columns="({})".format(", ".join(target_fields)) if target_fields else "",
|
|
123
|
+
values=", ".join("?" for i in range(1, len(values_base) + 1)),
|
|
124
|
+
)
|
|
125
|
+
row_count = 0
|
|
126
|
+
# Chunk the rows
|
|
127
|
+
row_chunk = []
|
|
128
|
+
for row in rows:
|
|
129
|
+
row_chunk.append(row)
|
|
130
|
+
row_count += 1
|
|
131
|
+
if row_count % commit_every == 0:
|
|
132
|
+
cursor.executemany(prepared_stm, row_chunk)
|
|
133
|
+
conn.commit() # type: ignore[attr-defined]
|
|
134
|
+
# Empty chunk
|
|
135
|
+
row_chunk = []
|
|
136
|
+
# Commit the leftover chunk
|
|
137
|
+
if len(row_chunk) > 0:
|
|
138
|
+
cursor.executemany(prepared_stm, row_chunk)
|
|
139
|
+
conn.commit() # type: ignore[attr-defined]
|
|
140
|
+
self.log.info("[%s] inserted %s rows", table, row_count)
|
|
141
|
+
cursor.close()
|
|
142
|
+
conn.close() # type: ignore[attr-defined]
|
|
143
|
+
|
|
144
|
+
def _get_conn_config_teradatasql(self) -> dict[str, Any]:
|
|
145
|
+
"""Return set of config params required for connecting to Teradata DB using teradatasql client."""
|
|
146
|
+
conn: Connection = self.get_connection(getattr(self, self.conn_name_attr))
|
|
147
|
+
conn_config = {
|
|
148
|
+
"host": conn.host or "localhost",
|
|
149
|
+
"dbs_port": conn.port or "1025",
|
|
150
|
+
"database": conn.schema or "",
|
|
151
|
+
"user": conn.login or "dbc",
|
|
152
|
+
"password": conn.password or "dbc",
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if conn.extra_dejson.get("tmode", False):
|
|
156
|
+
conn_config["tmode"] = conn.extra_dejson["tmode"]
|
|
157
|
+
|
|
158
|
+
# Handling SSL connection parameters
|
|
159
|
+
|
|
160
|
+
if conn.extra_dejson.get("sslmode", False):
|
|
161
|
+
conn_config["sslmode"] = conn.extra_dejson["sslmode"]
|
|
162
|
+
if "verify" in conn_config["sslmode"]:
|
|
163
|
+
if conn.extra_dejson.get("sslca", False):
|
|
164
|
+
conn_config["sslca"] = conn.extra_dejson["sslca"]
|
|
165
|
+
if conn.extra_dejson.get("sslcapath", False):
|
|
166
|
+
conn_config["sslcapath"] = conn.extra_dejson["sslcapath"]
|
|
167
|
+
if conn.extra_dejson.get("sslcipher", False):
|
|
168
|
+
conn_config["sslcipher"] = conn.extra_dejson["sslcipher"]
|
|
169
|
+
if conn.extra_dejson.get("sslcrc", False):
|
|
170
|
+
conn_config["sslcrc"] = conn.extra_dejson["sslcrc"]
|
|
171
|
+
if conn.extra_dejson.get("sslprotocol", False):
|
|
172
|
+
conn_config["sslprotocol"] = conn.extra_dejson["sslprotocol"]
|
|
173
|
+
|
|
174
|
+
return conn_config
|
|
175
|
+
|
|
176
|
+
def get_sqlalchemy_engine(self, engine_kwargs=None):
|
|
177
|
+
"""Return a connection object using sqlalchemy."""
|
|
178
|
+
conn: Connection = self.get_connection(getattr(self, self.conn_name_attr))
|
|
179
|
+
link = f"teradatasql://{conn.login}:{conn.password}@{conn.host}"
|
|
180
|
+
connection = sqlalchemy.create_engine(link)
|
|
181
|
+
return connection
|
|
182
|
+
|
|
183
|
+
@staticmethod
|
|
184
|
+
def get_ui_field_behaviour() -> dict:
|
|
185
|
+
"""Return custom field behaviour."""
|
|
186
|
+
import json
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
"hidden_fields": ["port"],
|
|
190
|
+
"relabeling": {
|
|
191
|
+
"host": "Database Server URL",
|
|
192
|
+
"schema": "Database Name",
|
|
193
|
+
"login": "Username",
|
|
194
|
+
},
|
|
195
|
+
"placeholders": {
|
|
196
|
+
"extra": json.dumps(
|
|
197
|
+
{"tmode": "TERA", "sslmode": "verify-ca", "sslca": "/tmp/server-ca.pem"}, indent=4
|
|
198
|
+
),
|
|
199
|
+
"login": "dbc",
|
|
200
|
+
"password": "dbc",
|
|
201
|
+
},
|
|
202
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
# or more contributor license agreements. See the NOTICE file
|
|
4
|
+
# distributed with this work for additional information
|
|
5
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
# to you under the Apache License, Version 2.0 (the
|
|
7
|
+
# "License"); you may not use this file except in compliance
|
|
8
|
+
# with the License. You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
|
13
|
+
# software distributed under the License is distributed on an
|
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
# KIND, either express or implied. See the License for the
|
|
16
|
+
# specific language governing permissions and limitations
|
|
17
|
+
# under the License.
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
from typing import Sequence
|
|
21
|
+
|
|
22
|
+
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
|
|
23
|
+
from airflow.providers.teradata.hooks.teradata import TeradataHook
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class TeradataOperator(SQLExecuteQueryOperator):
|
|
27
|
+
"""
|
|
28
|
+
General Teradata Operator to execute queries on Teradata Database.
|
|
29
|
+
|
|
30
|
+
Executes sql statements in the Teradata SQL Database using teradatasql jdbc driver
|
|
31
|
+
|
|
32
|
+
.. seealso::
|
|
33
|
+
For more information on how to use this operator, take a look at the guide:
|
|
34
|
+
:ref:`howto/operator:TeradataOperator`
|
|
35
|
+
|
|
36
|
+
:param sql: the SQL query to be executed as a single string, or a list of str (sql statements)
|
|
37
|
+
:param conn_id: reference to a predefined database
|
|
38
|
+
:param autocommit: if True, each command is automatically committed.(default value: False)
|
|
39
|
+
:param parameters: (optional) the parameters to render the SQL query with.
|
|
40
|
+
:param schema: The Teradata database to connect to.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
template_fields: Sequence[str] = (
|
|
44
|
+
"parameters",
|
|
45
|
+
"sql",
|
|
46
|
+
)
|
|
47
|
+
template_ext: Sequence[str] = (".sql",)
|
|
48
|
+
template_fields_renderers = {"sql": "sql"}
|
|
49
|
+
ui_color = "#e07c24"
|
|
50
|
+
|
|
51
|
+
def __init__(
|
|
52
|
+
self,
|
|
53
|
+
conn_id: str = TeradataHook.default_conn_name,
|
|
54
|
+
schema: str | None = None,
|
|
55
|
+
**kwargs,
|
|
56
|
+
) -> None:
|
|
57
|
+
if schema:
|
|
58
|
+
hook_params = kwargs.pop("hook_params", {})
|
|
59
|
+
kwargs["hook_params"] = {
|
|
60
|
+
"database": schema,
|
|
61
|
+
**hook_params,
|
|
62
|
+
}
|
|
63
|
+
super().__init__(**kwargs)
|
|
64
|
+
self.conn_id = conn_id
|