diff --git a/pandas/io/orc.py b/pandas/io/orc.py index 3999fc5840f02..1b9be9adc1196 100644 --- a/pandas/io/orc.py +++ b/pandas/io/orc.py @@ -19,8 +19,16 @@ ReadBuffer, WriteBuffer, ) +from pandas.compat import pa_version_under8p0 from pandas.compat._optional import import_optional_dependency +from pandas.core.dtypes.common import ( + is_categorical_dtype, + is_interval_dtype, + is_period_dtype, + is_unsigned_integer_dtype, +) + from pandas.core.arrays import ArrowExtensionArray from pandas.core.frame import DataFrame @@ -201,6 +209,20 @@ def to_orc( if engine_kwargs is None: engine_kwargs = {} + # If unsupported dtypes are found raise NotImplementedError + # In Pyarrow 8.0.0 this check will no longer be needed + if pa_version_under8p0: + for dtype in df.dtypes: + if ( + is_categorical_dtype(dtype) + or is_interval_dtype(dtype) + or is_period_dtype(dtype) + or is_unsigned_integer_dtype(dtype) + ): + raise NotImplementedError( + "The dtype of one or more columns is not supported yet." + ) + if engine != "pyarrow": raise ValueError("engine must be 'pyarrow'") engine = import_optional_dependency(engine, min_version="7.0.0")