U
    sVc%                     @   s  d Z ddlZddlmZ ddlZddlZddlZddlm	  m
Z ddlZddlmZ ddlmZ ed ejdZejdd Zed	ejd
dgddied	ejdddgddied	ejdddejdddgied	ejdddejdddgied	ejgd iedejgZ dd Z!dd Z"dd Z#d d! Z$d"d# Z%d$d% Z&ej'd&d'd(d)d* Z(ej'd&d'd(d+d, Z)ej'd&d'd(ej*d-e d.d/ Z+dS )0z test orc compat     N)BytesIO)read_orczpyarrow.orcz4ignore:RangeIndex.* is deprecated:DeprecationWarningc                 C   s   | dddS )NiodataZorc )datapathr   r   </tmp/pip-unpacked-wheel-xj8nt62q/pandas/tests/io/test_orc.pydirpath   s    r	   Zunimpl      Zuint64dtypeabcategory   )leftright   z
2022-01-03D)freqz
2022-01-042   floatc              	   C   s   ddddddddd	g	}d
ddddddddg	}t jt dd}t||D ]\}}t j|d||< qHtj| d}t||d}t	
|| d S )Nboolean1byte1short1int1long1float1double1bytes1string1boolint8int16int32int64float32float64objectr   )indexr   zTestOrcFile.emptyFile.orccolumns)pd	DataFrameZ
RangeIndexzipSeriesospathjoinr   tmassert_equal)r	   r,   ZdtypesexpectedZcolnamer   	inputfilegotr   r   r   test_orc_reader_empty0   s4    r9   c                 C   s   t jddgddt jddgddt jdd	gd
dt jddgddt jddgddt jddgddt jddgddt jddgddt jddgddd	}tj|}tj| d}t||	 d}t
|| d S )NFTr"   r   r
   d   r#         r$      r%       r&         ?       @r'         .      r(           r)   hibye	r   r   r   r   r   r   r   r    r!   zTestOrcFile.test1.orcr+   )nparrayr-   r.   	from_dictr1   r2   r3   r   keysr4   r5   r	   r   r6   r7   r8   r   r   r   test_orc_reader_basicQ   s    rM   c                 C   s   ddl m} dtj|d|d|d|d|d|d	|d
|d|d|dg
ddi}tj|}tj	| d}t
|jd d }t|| d S )Nr   )DecimalZ_col0z-1000.50000z
-999.60000z
-998.70000z
-997.80000z
-996.90000z
-995.10000z
-994.11000z
-993.12000z
-992.13000z
-991.14000r)   r   zTestOrcFile.decimal.orc
   )decimalrN   rH   rI   r-   r.   rJ   r1   r2   r3   r   ilocr4   r5   )r	   rN   r   r6   r7   r8   r   r   r   test_orc_reader_decimale   s*     rR   c                 C   s   t jddddddddd	d
g
ddt jtdddtdddtdddtdddtdddtdddtdddtdddtdddtdddg
ddd}tj|}tj	| d}t
|jd d }t|| d S )Nz1900-05-05 12:34:56.100000z1900-05-05 12:34:56.100100z1900-05-05 12:34:56.100200z1900-05-05 12:34:56.100300z1900-05-05 12:34:56.100400z1900-05-05 12:34:56.100500z1900-05-05 12:34:56.100600z1900-05-05 12:34:56.100700z1900-05-05 12:34:56.100800z1900-05-05 12:34:56.100900datetime64[ns]r   il        r)   timedatezTestOrcFile.testDate1900.orcrO   rH   rI   datetimerX   r-   r.   rJ   r1   r2   r3   r   rQ   r4   r5   rL   r   r   r   test_orc_reader_date_low   sB     r[   c                 C   s   t jddddddddd	d
g
ddt jtdddtdddtdddtdddtdddtdddtdddtdddtdddtdddg
ddd}tj|}tj	| d}t
|jd d }t|| d S )Nz2038-05-05 12:34:56.100000z2038-05-05 12:34:56.100100z2038-05-05 12:34:56.100200z2038-05-05 12:34:56.100300z2038-05-05 12:34:56.100400z2038-05-05 12:34:56.100500z2038-05-05 12:34:56.100600z2038-05-05 12:34:56.100700z2038-05-05 12:34:56.100800z2038-05-05 12:34:56.100900rS   r   i  rT   rU   r)   rV   zTestOrcFile.testDate2038.orcrO   rY   rL   r   r   r   test_orc_reader_date_high   sB     r\   c                 C   s   t jddddddddd	d
g
ddt jddddddddddg
ddd}tj|}tj| d}t|j	d d }t
|| d S )NiEAںijFiA!{i~iY5B
irhi;Sinqi:i(r%   r   Zf50dcb8Z382fdaaaZ90758c6Z9e8caf3fZee97332bZd634da1Z2bea4396Zd67d89e8Zad71007eZe8c82066r)   )r   r!   zTestOrcFile.testSnappy.orcrO   )rH   rI   r-   r.   rJ   r1   r2   r3   r   rQ   r4   r5   rL   r   r   r   !test_orc_reader_snappy_compressed   sB     r]   Zpyarrowz7.0.0)min_versionc                 C   s   t jddgddt jddgddt jdd	gd
dt jddgddt jddgddt jddgddt jddgddt jddgddt jddgddd	}tj|}t $}|| t|}t	|| W 5 Q R X d S NFTr"   r   r
   r:   r#   r;   r<   r$   r=   r%   r>   r&   r?   r@   r'   rA   rB   r(   rC   rD   r)   rE   rF   rG   )
rH   rI   r-   r.   rJ   r4   Zensure_cleanto_orcr   r5   )r	   r   r6   r2   r8   r   r   r   test_orc_roundtrip_file   s    

ra   c                  C   s   t jddgddt jddgddt jdd	gd
dt jddgddt jddgddt jddgddt jddgddt jddgddt jddgddd	} tj| }| }tt|}t	|| d S r_   )
rH   rI   r-   r.   rJ   r`   r   r   r4   r5   )r   r6   bytesr8   r   r   r   test_orc_roundtrip_bytesio  s    rc   df_not_supportedc              	   C   s*   d}t jt|d |   W 5 Q R X d S )Nz6The dtype of one or more columns is not supported yet.)match)pytestZraisesNotImplementedErrorr`   )rd   msgr   r   r   $test_orc_writer_dtypes_not_supported,  s    ri   ),__doc__rZ   r   r   r1   ZnumpyrH   rf   Zpandas.util._test_decoratorsutilZ_test_decoratorstdZpandasr-   r   Zpandas._testingZ_testingr4   ZimportorskipmarkfilterwarningsZ
pytestmarkZfixturer	   r.   rI   r0   ZIntervalZPeriodnanZastypeZSparseDtypeZorc_writer_dtypes_not_supportedr9   rM   rR   r[   r\   r]   Z
skip_if_nora   rc   Zparametrizeri   r   r   r   r   <module>   sT   

$!)))

