Skip to content

Commit

Permalink
Add documentation about "providers.jdbc" in provider.yaml
Browse files Browse the repository at this point in the history
Version 4.0.0 of the JDBC provider added configuration options
in airflow.cfg to be configured so that based on its value
the driver_path and driver_class values set in the connection's
extra field are utilised. The definition and description of this
configuraiton is missing in provider.yaml. Adding the same here.

closes: #35499
  • Loading branch information
pankajkoti committed Nov 11, 2023
1 parent 1f76986 commit 07d65a2
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
6 changes: 3 additions & 3 deletions airflow/providers/jdbc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ Breaking changes
To configure driver parameters (driver path and driver class), you can use the following methods:

1. Supply them as constructor arguments when instantiating the hook.
2. Set the "driver_path" and/or "driver_class" parameters in the "hook_params" dictionary when creating the hook using SQL operators.
3. Set the "driver_path" and/or "driver_class" extra in the connection and correspondingly enable the "allow_driver_path_in_extra" and/or "allow_driver_class_in_extra" options in the "providers.jdbc" section of the Airflow configuration.
4. Patch the "JdbcHook.default_driver_path" and/or "JdbcHook.default_driver_class" values in the "local_settings.py" file.
2. Set the ``driver_path`` and/or ``driver_class`` parameters in the ``hook_params`` dictionary when creating the hook using SQL operators.
3. Set the ``driver_path`` and/or ``driver_class`` extra in the connection and correspondingly enable the ``allow_driver_path_in_extra`` and/or ``allow_driver_class_in_extra`` options in the ``providers.jdbc`` section of the Airflow configuration.
4. Patch the ``JdbcHook.default_driver_path`` and/or ``JdbcHook.default_driver_class`` values in the ``local_settings.py`` file.

* ``Restrict direct usage of driver params via extras for JDBC connection (#31849)``

Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/jdbc/hooks/jdbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class JdbcHook(DbApiHook):
configuration, you should make sure that you trust the users who can edit connections in the UI
to not use it maliciously.
4. Patch the ``JdbcHook.default_driver_path`` and/or ``JdbcHook.default_driver_class`` values in the
"local_settings.py" file.
``local_settings.py`` file.
See :doc:`/connections/jdbc` for full documentation.
Expand Down
24 changes: 23 additions & 1 deletion airflow/providers/jdbc/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,29 @@ hooks:
python-modules:
- airflow.providers.jdbc.hooks.jdbc


connection-types:
- hook-class-name: airflow.providers.jdbc.hooks.jdbc.JdbcHook
connection-type: jdbc

config:
providers.jdbc:
description: This section applies for the JDBC provider and connection type.
options:
allow_driver_path_in_extra:
description: |
Whether to allow using ``driver_path`` set in the connection's ``extra`` field. If set to False,
``driver_path`` will be ignored. If enabling this functionality, you should make sure that you
trust the users who can edit connections to not use it maliciously.
version_added: "4.0.0"
type: boolean
example: ~
default: "False"
allow_driver_class_in_extra:
description: |
Whether to allow using ``driver_class`` set in the connection's ``extra`` field. If set to False,
``driver_class`` will be ignored. If enabling this functionality, you should make sure that you
trust the users who can edit connections to not use it maliciously.
version_added: "4.0.0"
type: boolean
example: ~
default: "False"
18 changes: 18 additions & 0 deletions docs/apache-airflow-providers-jdbc/configurations-ref.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
.. http://www.apache.org/licenses/LICENSE-2.0
.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
.. include:: ../exts/includes/providers-configurations-ref.rst
3 changes: 2 additions & 1 deletion docs/apache-airflow-providers-jdbc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
:maxdepth: 1
:caption: Guides

Operators <operators>
Configuration <configurations-ref>
Connection types <connections/jdbc>
Operators <operators>

.. toctree::
:hidden:
Expand Down

0 comments on commit 07d65a2

Please sign in to comment.