Skip to content

Commit 41a5048

Browse files
committed
Revert "CLN: Remove read_orc dtype checking (pandas-dev#51604)"
This reverts commit b69bd07.
1 parent ce32601 commit 41a5048

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

pandas/io/orc.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
)
2222
from pandas.compat._optional import import_optional_dependency
2323

24+
from pandas.core.dtypes.common import (
25+
is_categorical_dtype,
26+
is_interval_dtype,
27+
is_period_dtype,
28+
is_unsigned_integer_dtype,
29+
)
30+
2431
from pandas.core.arrays import ArrowExtensionArray
2532
from pandas.core.frame import DataFrame
2633

@@ -201,10 +208,22 @@ def to_orc(
201208
if engine_kwargs is None:
202209
engine_kwargs = {}
203210

211+
# If unsupported dtypes are found raise NotImplementedError
212+
# In Pyarrow 9.0.0 this check will no longer be needed
213+
for dtype in df.dtypes:
214+
if (
215+
is_categorical_dtype(dtype)
216+
or is_interval_dtype(dtype)
217+
or is_period_dtype(dtype)
218+
or is_unsigned_integer_dtype(dtype)
219+
):
220+
raise NotImplementedError(
221+
"The dtype of one or more columns is not supported yet."
222+
)
223+
204224
if engine != "pyarrow":
205225
raise ValueError("engine must be 'pyarrow'")
206226
engine = import_optional_dependency(engine, min_version="7.0.0")
207-
pa = import_optional_dependency("pyarrow")
208227
orc = import_optional_dependency("pyarrow.orc")
209228

210229
was_none = path is None
@@ -219,7 +238,7 @@ def to_orc(
219238
handles.handle,
220239
**engine_kwargs,
221240
)
222-
except (TypeError, pa.ArrowNotImplementedError) as e:
241+
except TypeError as e:
223242
raise NotImplementedError(
224243
"The dtype of one or more columns is not supported yet."
225244
) from e

0 commit comments

Comments
 (0)