diff --git a/airflow/providers/oracle/hooks/oracle.py b/airflow/providers/oracle/hooks/oracle.py index 84c0f5d6a1e33..c018c7c6c04bf 100644 --- a/airflow/providers/oracle/hooks/oracle.py +++ b/airflow/providers/oracle/hooks/oracle.py @@ -16,12 +16,17 @@ # specific language governing permissions and limitations # under the License. +import math import warnings from datetime import datetime from typing import Dict, List, Optional, Union import cx_Oracle -import numpy + +try: + import numpy +except ImportError: + numpy = None # type: ignore from airflow.hooks.dbapi import DbApiHook @@ -211,9 +216,9 @@ def insert_rows( lst.append("'" + str(cell).replace("'", "''") + "'") elif cell is None: lst.append('NULL') - elif isinstance(cell, float) and numpy.isnan(cell): # coerce numpy NaN to NULL + elif isinstance(cell, float) and math.isnan(cell): # coerce numpy NaN to NULL lst.append('NULL') - elif isinstance(cell, numpy.datetime64): + elif numpy and isinstance(cell, numpy.datetime64): lst.append("'" + str(cell) + "'") elif isinstance(cell, datetime): lst.append( diff --git a/airflow/providers/oracle/provider.yaml b/airflow/providers/oracle/provider.yaml index 254c577fecb5b..32be4596150dc 100644 --- a/airflow/providers/oracle/provider.yaml +++ b/airflow/providers/oracle/provider.yaml @@ -42,6 +42,9 @@ integrations: logo: /integration-logos/oracle/Oracle.png tags: [software] +additional-extras: + numpy: numpy + operators: - integration-name: Oracle python-modules: