Skip to content

Commit 1d0a8f7

Browse files
authored
add exasol operators doc and example & refactor trino (#49679)
* add exasol operators doc, example and refactor trino * fix lint issue * fix lint issue #2 * fix code duplicate issue * fix lint issue #3 * fix CI Static Checks
1 parent 19504ae commit 1d0a8f7

9 files changed

Lines changed: 218 additions & 27 deletions

File tree

providers/exasol/docs/index.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
Changelog <changelog>
3030
Security <security>
3131

32+
.. toctree::
33+
:hidden:
34+
:maxdepth: 1
35+
:caption: Guides
36+
37+
Operators <operators>
38+
3239
.. toctree::
3340
:hidden:
3441
:maxdepth: 1
@@ -44,6 +51,13 @@
4451
PyPI Repository <https://pypi.org/project/apache-airflow-providers-exasol/>
4552
Installing from sources <installing-providers-from-sources>
4653

54+
.. toctree::
55+
:hidden:
56+
:maxdepth: 1
57+
:caption: System tests
58+
59+
System Tests <_api/tests/system/exasol/index>
60+
4761
.. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE OVERWRITTEN AT RELEASE TIME!
4862
4963
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
.. Licensed to the Apache Software Foundation (ASF) under one
2+
or more contributor license agreements. See the NOTICE file
3+
distributed with this work for additional information
4+
regarding copyright ownership. The ASF licenses this file
5+
to you under the Apache License, Version 2.0 (the
6+
"License"); you may not use this file except in compliance
7+
with the License. You may obtain a copy of the License at
8+
9+
.. http://www.apache.org/licenses/LICENSE-2.0
10+
11+
.. Unless required by applicable law or agreed to in writing,
12+
software distributed under the License is distributed on an
13+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
KIND, either express or implied. See the License for the
15+
specific language governing permissions and limitations
16+
under the License.
17+
18+
19+
20+
.. _howto/operator:ExasolOperator:
21+
22+
SQLExecuteQueryOperator to connect to Exasol
23+
====================================================
24+
25+
Use the :class:`SQLExecuteQueryOperator<airflow.providers.common.sql.operators.sql>` to execute
26+
SQL commands in an `Exasol <https://www.exasol.com/>`__ database.
27+
28+
.. note::
29+
Previously, an ``ExasolOperator`` was used to perform this kind of operation.
30+
After deprecation this has been removed. Please use ``SQLExecuteQueryOperator`` instead.
31+
32+
.. note::
33+
Make sure you have installed the ``apache-airflow-providers-exasol`` package
34+
and its dependency ``pyexasol`` to enable Exasol support.
35+
36+
Using the Operator
37+
^^^^^^^^^^^^^^^^^^
38+
39+
Use the ``conn_id`` argument to connect to your Exasol instance where
40+
the connection metadata is structured as follows:
41+
42+
.. list-table:: Exasol Airflow Connection Metadata
43+
:widths: 25 25
44+
:header-rows: 1
45+
46+
* - Parameter
47+
- Input
48+
* - Host: string
49+
- Exasol hostname, container alias or IP address
50+
* - Schema: string
51+
- Default schema name (e.g. ``TEST``) (optional)
52+
* - Login: string
53+
- Exasol username (e.g. ``TEST`` or ``sys``)
54+
* - Password: string
55+
- Exasol password
56+
* - Port: int
57+
- Exasol port (default: 8563)
58+
* - Extra: JSON
59+
- Additional connection configuration passed to *pyexasol*, such as:
60+
``{"encryption": false}`` or
61+
``{"encryption": true, "websocket_sslopt": {"cert_reqs": 0}}``
62+
63+
An example usage of the SQLExecuteQueryOperator to connect to Exasol is as follows:
64+
65+
.. exampleinclude:: /../../exasol/tests/system/exasol/example_exasol.py
66+
:language: python
67+
:start-after: [START howto_operator_exasol]
68+
:end-before: [END howto_operator_exasol]
69+
70+
Reference
71+
^^^^^^^^^
72+
For further information, look at:
73+
74+
* `Exasol Documentation <https://docs.exasol.com/>`__
75+
76+
.. note::
77+
78+
Parameters provided directly via SQLExecuteQueryOperator() take precedence
79+
over those specified in the Airflow connection metadata (such as ``schema``, ``login``, ``password``, etc).
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
"""
18+
This is an example DAG for the use of the SQLExecuteQueryOperator with Exasol.
19+
"""
20+
21+
from __future__ import annotations
22+
23+
import datetime
24+
25+
from airflow import DAG
26+
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
27+
from airflow.providers.exasol.hooks.exasol import exasol_fetch_all_handler
28+
29+
DAG_ID = "example_exasol"
30+
31+
with DAG(
32+
dag_id=DAG_ID,
33+
start_date=datetime.datetime(2025, 1, 1),
34+
default_args={"conn_id": "my_exasol_conn", "handler": exasol_fetch_all_handler},
35+
schedule="@once",
36+
catchup=False,
37+
) as dag:
38+
# [START howto_operator_exasol]
39+
create_table_exasol = SQLExecuteQueryOperator(
40+
task_id="create_table_exasol",
41+
sql="""
42+
CREATE OR REPLACE TABLE exasol_example (
43+
a VARCHAR(100),
44+
b DECIMAL(18,0)
45+
);
46+
""",
47+
)
48+
49+
alter_table_exasol = SQLExecuteQueryOperator(
50+
task_id="alter_table_exasol",
51+
sql="ALTER TABLE exasol_example ADD COLUMN c DECIMAL(18,0);",
52+
)
53+
54+
insert_data_exasol = SQLExecuteQueryOperator(
55+
task_id="insert_data_exasol",
56+
sql="""
57+
INSERT INTO exasol_example (a, b, c)
58+
VALUES
59+
('a', 1, 1),
60+
('a', 2, 1),
61+
('b', 3, 1);
62+
""",
63+
)
64+
65+
select_data_exasol = SQLExecuteQueryOperator(
66+
task_id="select_data_exasol",
67+
sql="SELECT * FROM exasol_example;",
68+
)
69+
70+
drop_table_exasol = SQLExecuteQueryOperator(
71+
task_id="drop_table_exasol",
72+
sql="DROP TABLE exasol_example;",
73+
)
74+
# [END howto_operator_exasol]
75+
76+
(
77+
create_table_exasol
78+
>> alter_table_exasol
79+
>> insert_data_exasol
80+
>> select_data_exasol
81+
>> drop_table_exasol
82+
)
83+
84+
from tests_common.test_utils.watcher import watcher
85+
86+
list(dag.tasks) >> watcher()
87+
88+
from tests_common.test_utils.system_tests import get_test_run # noqa: E402
89+
90+
# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest)
91+
test_run = get_test_run(dag)
File renamed without changes.

providers/trino/docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
:maxdepth: 1
3535
:caption: Guides
3636

37-
TrinoTransferOperator types <operators/transfer/gcs_to_trino>
38-
TrinoOperator <operators/index>
37+
TrinoTransferOperator types <gcs_to_trino>
38+
Operators <operators>
3939
Connection types <connections>
4040

4141
.. toctree::

providers/trino/docs/operators/index.rst

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)