mirror of
https://github.com/hanzo-ds/connect.git
synced 2026-10-30 20:31:24 +00:00
Imports read `datastore_connect`, distribution `datastore-connect`, so nothing has to import another product's name to talk to Hanzo Datastore. Cut from upstream 0.8.17 — the version this stack already ran — rather than from upstream HEAD, so it is a PURE RENAME with no behaviour change. Forking from HEAD would have dragged versions along with the name (connect alone jumped 0.8.17 -> 1.6.0, a major), which is a different and much riskier change wearing a rename's clothes. X-ClickHouse-* headers are untouched: they are wire protocol the server sends and expects, and a different token shape from the module name.
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
from datastore_connect.driver.exceptions import NotSupportedError
|
|
|
|
pd_time_test = None
|
|
pd_extended_dtypes = False
|
|
|
|
try:
|
|
import numpy as np
|
|
except ImportError:
|
|
np = None
|
|
|
|
try:
|
|
import pandas as pd
|
|
pd_extended_dtypes = not pd.__version__.startswith('0')
|
|
try:
|
|
from pandas.core.dtypes.common import is_datetime64_dtype
|
|
from pandas.core.dtypes.common import is_timedelta64_dtype
|
|
|
|
def combined_test(arr_or_dtype):
|
|
return is_datetime64_dtype(arr_or_dtype) or is_timedelta64_dtype(arr_or_dtype)
|
|
|
|
pd_time_test = combined_test
|
|
except ImportError:
|
|
try:
|
|
from pandas.core.dtypes.common import is_datetime_or_timedelta_dtype
|
|
pd_time_test = is_datetime_or_timedelta_dtype
|
|
except ImportError as ex:
|
|
raise NotSupportedError('pandas version does not contain expected test for temporal types') from ex
|
|
except ImportError:
|
|
pd = None
|
|
|
|
try:
|
|
import pyarrow as arrow
|
|
except ImportError:
|
|
arrow = None
|
|
|
|
|
|
def check_numpy():
|
|
if np:
|
|
return np
|
|
raise NotSupportedError('Numpy package is not installed')
|
|
|
|
|
|
def check_pandas():
|
|
if pd:
|
|
return pd
|
|
raise NotSupportedError('Pandas package is not installed')
|
|
|
|
|
|
def check_arrow():
|
|
if arrow:
|
|
return arrow
|
|
raise NotSupportedError('PyArrow package is not installed')
|