Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jdbc Operator How To #11472

Merged
merged 12 commits into from
Oct 29, 2020
Merged

Jdbc Operator How To #11472

merged 12 commits into from
Oct 29, 2020

Conversation

francescomucio
Copy link
Contributor

Added an How To page for the Jdbc operator (and an example dag to get code snippet for the page)


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks$,^Build docs$,^Spell check docs$,^Backport packages$,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks$,^Build docs$,^Spell check docs$,^Backport packages$,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks$,^Build docs$,^Spell check docs$,^Backport packages$,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks$,^Build docs$,^Spell check docs$,^Backport packages$,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks$,^Build docs$,^Spell check docs$,^Backport packages$,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks$,^Build docs$,^Spell check docs$,^Backport packages$,^Checks: Helm tests$,^Test OpenAPI*.

* Install the python module jaydebeapi:
.. code-block:: bash

pip install jaydebeapi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, we should use extra packages to manage dependencies for Airflow. WDYT?
See: https://airflow.readthedocs.io/en/latest/installation.html#extra-packages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the software section like for ODBC?
Should I add this as part of this PR?

The parameter ``autocommit`` if set to ``True`` will execute a commit after
each command (default is ``False``)

Prerequisite Tasks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the second section in the document and the first should describe the JDBC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved


pip install jaydebeapi

* Install a JVM.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a link to external docs about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always found installing Java very platform specific, what do you think of https://adoptopenjdk.net/installation.html?
I guess it is missing the step about setting the JAVA_HOME folder like you do in your Dockerfile.

pip install jaydebeapi

* Install a JVM.
* Have the JDBC driver for your database installed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a link to external docs about it? Ideally, you should include a simple command here to check if this condition is met.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have included a simple check, not sure if it is enough

@@ -0,0 +1,66 @@
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be in airflow.providers.jdbc.example_dags

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved


# [START howto_operator_jdbc_template]
delete_data = JdbcOperator(
task_id='insert_data',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
task_id='insert_data',
task_id='delete_data',

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed

* Install the python module jaydebeapi:
.. code-block:: bash

pip install jaydebeapi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pip install jaydebeapi
pip install 'apache-airflow[jdbc]'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified

@@ -75,6 +75,8 @@ Fundamentals

* - :mod:`airflow.operators.latest_only`
-
* - :mod:`airflow.providers.jdbc.operators.jdbc`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fundamentals section only includes operators that are in the Airflow core. Please look at the protocol section: https://airflow.readthedocs.io/en/latest/operators-and-hooks-ref.html#protocol-operators-and-hooks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out this, I removed this and moved the link to the JDBC doc below

@mik-laj mik-laj merged commit ba9c044 into apache:master Oct 29, 2020
@kaxil
Copy link
Member

kaxil commented Oct 29, 2020

Good work @francescomucio 🎉

@ashb
Copy link
Member

ashb commented Oct 29, 2020

This, I think, has broken master and all open PRs

>       self.assertEqual([], invalid_files)
E       AssertionError: Lists differ: [] != ['/opt/airflow/airflow/providers/jdbc/example_dags/example_jdbc_operator.py']
E       
E       Second list contains 1 additional elements.
E       First extra element 0:
E       '/opt/airflow/airflow/providers/jdbc/example_dags/example_jdbc_operator.py'
E       
E       - []
E       + ['/opt/airflow/airflow/providers/jdbc/example_dags/example_jdbc_operator.py']

tests/core/test_project_structure.py:230: AssertionError

@ashb
Copy link
Member

ashb commented Oct 29, 2020

@potiuk Selective tests (? or something else) caused CI to not detect failing tests:

https://github.com/apache/airflow/runs/1307780299

tests/core/test_project_structure.py sssssssssss                         [ 23%]

ashb added a commit to astronomer/airflow that referenced this pull request Oct 29, 2020
This was merged in apache#11472, but for some reason that didn't run tests so
the failure wasn't noticed
@ashb ashb mentioned this pull request Oct 29, 2020
ashb added a commit that referenced this pull request Oct 29, 2020
This was merged in #11472, but for some reason that didn't run tests so
the failure wasn't noticed
kaxil added a commit that referenced this pull request Oct 29, 2020
This was merged in #11472, but for some reason that didn't run tests so
the failure wasn't noticed.

a7ad204 fixed 1 error but the docs error was missed
@francescomucio
Copy link
Contributor Author

Sorry for the mess, not sure what I should keep an eye on next time

michalmisiewicz pushed a commit to michalmisiewicz/airflow that referenced this pull request Oct 30, 2020
michalmisiewicz pushed a commit to michalmisiewicz/airflow that referenced this pull request Oct 30, 2020
This was merged in apache#11472, but for some reason that didn't run tests so
the failure wasn't noticed
michalmisiewicz pushed a commit to michalmisiewicz/airflow that referenced this pull request Oct 30, 2020
This was merged in apache#11472, but for some reason that didn't run tests so
the failure wasn't noticed.

a7ad204 fixed 1 error but the docs error was missed
szn pushed a commit to szn/airflow that referenced this pull request Nov 1, 2020
szn pushed a commit to szn/airflow that referenced this pull request Nov 1, 2020
This was merged in apache#11472, but for some reason that didn't run tests so
the failure wasn't noticed
szn pushed a commit to szn/airflow that referenced this pull request Nov 1, 2020
This was merged in apache#11472, but for some reason that didn't run tests so
the failure wasn't noticed.

a7ad204 fixed 1 error but the docs error was missed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants