21
21
)
22
22
from pandas .compat ._optional import import_optional_dependency
23
23
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
+
24
31
from pandas .core .arrays import ArrowExtensionArray
25
32
from pandas .core .frame import DataFrame
26
33
@@ -201,10 +208,22 @@ def to_orc(
201
208
if engine_kwargs is None :
202
209
engine_kwargs = {}
203
210
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
+
204
224
if engine != "pyarrow" :
205
225
raise ValueError ("engine must be 'pyarrow'" )
206
226
engine = import_optional_dependency (engine , min_version = "7.0.0" )
207
- pa = import_optional_dependency ("pyarrow" )
208
227
orc = import_optional_dependency ("pyarrow.orc" )
209
228
210
229
was_none = path is None
@@ -219,7 +238,7 @@ def to_orc(
219
238
handles .handle ,
220
239
** engine_kwargs ,
221
240
)
222
- except ( TypeError , pa . ArrowNotImplementedError ) as e :
241
+ except TypeError as e :
223
242
raise NotImplementedError (
224
243
"The dtype of one or more columns is not supported yet."
225
244
) from e
0 commit comments