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

Make numpy effectively an optional dependency for Oracle provider #24272

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions airflow/providers/oracle/hooks/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions airflow/providers/oracle/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ integrations:
logo: /integration-logos/oracle/Oracle.png
tags: [software]

additional-extras:
numpy: numpy

operators:
- integration-name: Oracle
python-modules:
Expand Down