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

DbApiHook.test_connection() does not work with Oracle db #18967

Closed
1 of 2 tasks
gbonazzoli opened this issue Oct 14, 2021 · 7 comments · Fixed by #21699
Closed
1 of 2 tasks

DbApiHook.test_connection() does not work with Oracle db #18967

gbonazzoli opened this issue Oct 14, 2021 · 7 comments · Fixed by #21699
Labels

Comments

@gbonazzoli
Copy link

Apache Airflow version

2.2.0 (latest released)

Operating System

Ubuntu 20.04.3 LTS

Versions of Apache Airflow Providers

apache-airflow-providers-oracle==2.0.1

Deployment

Other

Deployment details

Screen Shot 2021-10-14 at 06 27 02

What happened

The title and screenshot are self explaining

What you expected to happen

To have a successful message similar to what I got with SQL Server.

How to reproduce

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@gbonazzoli gbonazzoli added area:core kind:bug This is a clearly a bug labels Oct 14, 2021
@potiuk
Copy link
Member

potiuk commented Oct 14, 2021

cc: @msumit

@hkjang
Copy link

hkjang commented Dec 7, 2021

first thanks. also i got that error message ORA-00923

@uranusjr
Copy link
Member

uranusjr commented Dec 8, 2021

ORA-00923 is FROM keyword not found where expected. Currently we are testing a database connection with select 1, but it seems like Oracle does not support this. From this table, there is likely not any single query that works accross all implementations. Perhaps instead of treating all exceptions as a failure, we should selectively catch some and treat them as success. This button is only meant to test if the conenction config works, and when the backend responds something (even a SQL error), the connection is definitely working.

@uranusjr uranusjr changed the title Airflow 2.2.0 : Connection Type Oracle returns "ORA-00923: FROM keyword not found where expected" as the result of pressing the "new" button "Test" introduced DbApiHook.test_connection() does not work with Oracle db Dec 8, 2021
@gbonazzoli
Copy link
Author

For all Oracle Database's versions you can replace "select 1" with "select 1 from dual"

dual is a logical table present in every oracle schema you're connecting to.

Probably is a simpler implementation of the test.

@potiuk
Copy link
Member

potiuk commented Dec 8, 2021

For all Oracle Database's versions you can replace "select 1" with "select 1 from dual"

dual is a logical table present in every oracle schema you're connecting to.

Probably is a simpler implementation of the test.

Surely for Oracle yes so this mean that you have to add oracle specific 'test_connection" method in https://github.com/apache/airflow/blob/main/airflow/providers/oracle/hooks/oracle.py to override "test_connection" in https://github.com/apache/airflow/blob/main/airflow/hooks/dbapi.py#L376

Would you @hkjang @gbonazzoli care to make a PR fixing it for Oracle Hook? Sounds super easy and since you already use Oracle it wll be easy for you to test the fix.

gbonazzoli added a commit to gbonazzoli/airflow that referenced this issue Dec 9, 2021
Solution for issue apache#18967

In order to check Oracle connection, the "select 1" statement is wrong.
It must be replaced by  "select 1 from dual".
@potiuk potiuk linked a pull request Dec 9, 2021 that will close this issue
@hubert-pietron
Copy link
Contributor

Hi, can i finish it @gbonazzoli ?

@gbonazzoli
Copy link
Author

Yes, you are welcome, very welcome !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants