You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/02/20 15:28:48 UTC

[GitHub] [airflow] hubert-pietron opened a new pull request #21699: Fix oracle test connection

hubert-pietron opened a new pull request #21699:
URL: https://github.com/apache/airflow/pull/21699


   closes: #18967
   Testing connection via "select 1" for Oracle database doesn't work. This PR replace it with checking connection using table dual which is automatically created by database. I added test to prevent future changes in method.
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk merged pull request #21699: Fix oracle test connection

Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #21699:
URL: https://github.com/apache/airflow/pull/21699


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] uranusjr commented on a change in pull request #21699: Fix oracle test connection

Posted by GitBox <gi...@apache.org>.
uranusjr commented on a change in pull request #21699:
URL: https://github.com/apache/airflow/pull/21699#discussion_r810954115



##########
File path: airflow/hooks/dbapi.py
##########
@@ -345,11 +347,13 @@ def bulk_load(self, table, tmp_file):
         """
         raise NotImplementedError()
 
+    # TODO: Merge this implementation back to DbApiHook when dropping
+    # support for Airflow 2.2.

Review comment:
       This should be added to *OracleHook*’s `test_connection` instead.

##########
File path: airflow/providers/oracle/hooks/oracle.py
##########
@@ -52,6 +52,8 @@ class OracleHook(DbApiHook):
 
     supports_autocommit = True
 
+    _test_connection_sql = "select 1 from dual"

Review comment:
       Unfortunately we can’t do this yet because the provider still needs to support Airflow 2.2 and lower. The full `test_connection` function still needs to exist for now.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] uranusjr commented on a change in pull request #21699: Fix oracle test connection

Posted by GitBox <gi...@apache.org>.
uranusjr commented on a change in pull request #21699:
URL: https://github.com/apache/airflow/pull/21699#discussion_r810824368



##########
File path: airflow/providers/oracle/hooks/oracle.py
##########
@@ -339,3 +339,16 @@ def handler(cursor):
         )
 
         return result
+
+    def test_connection(self):
+        """Tests the connection by executing a select 1 from dual query"""
+        status, message = False, ''
+        try:
+            if self.get_first("select 1 from dual"):
+                status = True
+                message = 'Connection successfully tested'
+        except Exception as e:
+            status = False
+            message = str(e)
+
+        return status, message

Review comment:
       While this works (and is the best approach due to backward compatibility considerations), we should look into eventually merge this implementation back into `DbApiHook`. Can you refactor `DbApiHook` to something like this:
   
   ```python
   class DbApiHook:
       _test_connection_sql = "select 1"
   
       def test_connection(self):
           ...
           if self.get_first(self._test_connection_sql):"
               ...
   ```
   
   And add a comment here like this?
   
   ```python
   # TODO: Merge this implementation back to DbApiHook when dropping
   # support for Airflow 2.2.
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] hubert-pietron commented on a change in pull request #21699: Fix oracle test connection

Posted by GitBox <gi...@apache.org>.
hubert-pietron commented on a change in pull request #21699:
URL: https://github.com/apache/airflow/pull/21699#discussion_r810936927



##########
File path: airflow/providers/oracle/hooks/oracle.py
##########
@@ -339,3 +339,16 @@ def handler(cursor):
         )
 
         return result
+
+    def test_connection(self):
+        """Tests the connection by executing a select 1 from dual query"""
+        status, message = False, ''
+        try:
+            if self.get_first("select 1 from dual"):
+                status = True
+                message = 'Connection successfully tested'
+        except Exception as e:
+            status = False
+            message = str(e)
+
+        return status, message

Review comment:
       Thanks for response, can You check if it it's ok right now?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] github-actions[bot] commented on pull request #21699: Fix oracle test connection

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #21699:
URL: https://github.com/apache/airflow/pull/21699#issuecomment-1046697556


   The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] hubert-pietron commented on a change in pull request #21699: Fix oracle test connection

Posted by GitBox <gi...@apache.org>.
hubert-pietron commented on a change in pull request #21699:
URL: https://github.com/apache/airflow/pull/21699#discussion_r810969905



##########
File path: airflow/hooks/dbapi.py
##########
@@ -345,11 +347,13 @@ def bulk_load(self, table, tmp_file):
         """
         raise NotImplementedError()
 
+    # TODO: Merge this implementation back to DbApiHook when dropping
+    # support for Airflow 2.2.

Review comment:
       sorry, I misunderstood changes, now it should be better :)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org