
    Owg_5              
       ,   d Z ddlZddlmZ ddlmZ ddlZddlZddlZ	ddl
Z
ddlZddlmZ ddlmZ ddlmZ  e
j&                  d       ddlZe
j,                  j/                  d      Ze
j2                  d	        Z e
j2                   e	j6                  d
dgd       ej8                  g dd       ej:                  dd       ej:                  dd      g ej<                  dd       ej<                  dd      gg      d        Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d  Z'd! Z(d" Z)d# Z*d$ Z+e
j,                  jY                  d% ejZ                  ddd
&       ejZ                  dd'd
d()       ej\                  g d*      g      d+        Z/d, Z0d- Z1y).z test orc compat     N)Decimal)BytesIO)read_orc)StringArrayzpyarrow.orcz=ignore:Passing a BlockManager to DataFrame:DeprecationWarningc                      | ddd      S )Niodataorc )datapaths    O/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/io/test_orc.pydirpathr      s    D&%((          uint64dtype)abr   category   )leftright   z
2022-01-03D)freqz
2022-01-04)paramsc                 D    t        j                  d| j                  i      S )Nunimpl)pd	DataFrameparam)requests    r   orc_writer_dtypes_not_supportedr%      s     <<7==122r   c                 F   g d}g d}t        j                  t        j                  d            }t        ||      D ]  \  }}t        j                  |      ||<     t
        j                  j                  | d      }t        ||      }t        j                  ||       y )N	boolean1byte1short1int1long1float1double1bytes1string1)	boolint8int16int32int64float32float64objectr8   r   indexr   zTestOrcFile.emptyFile.orccolumns)r!   r"   
RangeIndexzipSeriesospathjoinr   tmassert_equal)r   r<   dtypesexpectedcolnamer   	inputfilegots           r   test_orc_reader_emptyrJ   -   s    
G
F ||"--"23Hgv. 3IIE23 W&ABI
9g
.COOHc"r   c                    t        j                  ddgd      t        j                  ddgd      t        j                  dd	gd
      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      d	}t        j                  j	                  |      }t
        j                  j                  | d      }t        ||j                               }t        j                  ||       y )NFTr1   r   r   d   r2         r3      r4       r5         ?       @r6         .      r7       r   r8   hibyer'   zTestOrcFile.test1.orcr;   )nparrayr!   r"   	from_dictr@   rA   rB   r   keysrC   rD   r   r	   rF   rH   rI   s        r   test_orc_reader_basicr]   N   s    HHeT]&91c(&1((D$<w7%w7.0CDGT((C:Y788UDM;((3S9J88T5M:
D ||%%d+HW&=>I
9diik
2COOHc"r   c                    dt        j                  t        d      t        d      t        d      t        d      t        d      t        d      t        d      t        d	      t        d
      t        d      g
d      i}t        j                  j                  |      }t        j                  j                  | d      }t        |      j                  d d }t        j                  ||       y )N_col0z-1000.50000z
-999.60000z
-998.70000z
-997.80000z
-996.90000z
-995.10000z
-994.11000z
-993.12000z
-992.13000z
-991.14000r8   r   zTestOrcFile.decimal.orc
   )rX   rY   r   r!   r"   rZ   r@   rA   rB   r   ilocrC   rD   r\   s        r   test_orc_reader_decimalrb   b   s     	&%%%%%%%%% 
D" ||%%d+HW&?@I
9

"
"3B
'COOHc"r   c                    t        j                  g dd      t        j                  t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      g
d      d}t        j
                  j                  |      }t        j                  j                  | d	      }t        |      j                  d d
 }t        j                  ||       y )N)
z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        r8   timedatezTestOrcFile.testDate1900.orcr`   rX   rY   datetimeri   r!   r"   rZ   r@   rA   rB   r   ra   rC   rD   r\   s        r   test_orc_reader_date_lowrl   }   (    #
 dB+dB+dB+dB+dB+dB+dB+dB+dB+dB+ 
!D@ ||%%d+HW&DEI
9

"
"3B
'COOHc"r   c                    t        j                  g dd      t        j                  t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      g
d      d}t        j
                  j                  |      }t        j                  j                  | d	      }t        |      j                  d d
 }t        j                  ||       y )N)
z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.100900rd   r   i  re   rf   r8   rg   zTestOrcFile.testDate2038.orcr`   rj   r\   s        r   test_orc_reader_date_highro      rm   r   c                 D   t        j                  g dd      t        j                  g dd      d}t        j                  j	                  |      }t
        j                  j                  | d      }t        |      j                  d d }t        j                  ||       y )	N)
iEAںijFiA!{i~iY5B
irhi;Sinqi:i(r4   r   )
f50dcb8382fdaaa90758c69e8caf3fee97332bd634da12bea4396d67d89e8ad71007ee8c82066r8   )r+   r0   zTestOrcFile.testSnappy.orcr`   )rX   rY   r!   r"   rZ   r@   rA   rB   r   ra   rC   rD   r\   s        r   !test_orc_reader_snappy_compressedr{      s     
 88 
!D@ ||%%d+HW&BCI
9

"
"3B
'COOHc"r   c                    t        j                  d       t        j                  ddgd      t        j                  ddgd      t        j                  d	d
gd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      d	}t        j
                  j                  |      }t        j                         5 }|j                  |       t        |      }t        j                  ||       d d d        y # 1 sw Y   y xY wNpyarrowFTr1   r   r   rL   r2   rM   rN   r3   rO   r4   rP   r5   rQ   rR   r6   rS   rT   r7   rU   r   r8   rV   rW   r'   )pytestimportorskiprX   rY   r!   r"   rZ   rC   ensure_cleanto_orcr   rD   )r   r	   rF   rA   rI   s        r   test_orc_roundtrip_filer      s    	" HHeT]&91c(&1((D$<w7%w7.0CDGT((C:Y788UDM;((3S9J88T5M:
D ||%%d+H		 'dtn
#&	' ' 's   $3E  E)c                     t        j                  d       t        j                  ddgd      t        j                  ddgd      t        j                  d	d
gd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      d	} t        j
                  j                  |       }|j                         }t        t        |            }t        j                  ||       y r}   )r   r   rX   rY   r!   r"   rZ   r   r   r   rC   rD   )r	   rF   bytesrI   s       r   test_orc_roundtrip_bytesior     s     	" HHeT]&91c(&1((D$<w7%w7.0CDGT((C:Y788UDM;((3S9J88T5M:
D ||%%d+HOOE
75>
"COOHc"r   c                     t        j                  d       d}t        j                  t        |      5  | j	                          d d d        y # 1 sw Y   y xY w)Nr~   z6The dtype of one or more columns is not supported yet.match)r   r   raisesNotImplementedErrorr   )r%   msgs     r   $test_orc_writer_dtypes_not_supportedr   )  sG     	"
BC	*#	6 1'..01 1 1s   AAc                  $   t        j                  d       t        j                  t	        d      dt
        j                  dgg dg dt	        t        dd            t        j                  d	d
d      dt
        j                  dgg dg dt        j                  dd      t        j                  d      t        j                  t        j                  d      gd      } | j                         j                         }t        t        |      d      }t        j                  | j                   D ci c]:  }|t        j"                  j%                  t'        j(                  | |   d            < c}      }t+        j,                  ||       y c c}w )Nr~   abcr   cr   Nr   )s   foos   barNr            @      @r7   r   rR         @TFTTFN20130101   )periods20130103)stringstring_with_nanstring_with_noner   intfloatfloat_with_nanr1   bool_with_nark   datetime_with_natdtype_backendT)from_pandas)r   r   r!   r"   listrX   nanrangearange
date_range	TimestampNaTcopyr   r   r   r<   arraysArrowExtensionArrayparY   rC   assert_frame_equal)df
bytes_dataresultcolrF   s        r   test_orc_dtype_backend_pyarrowr   3  s-   
	"	5k #RVVS1 0+a$YYsCy9"BFFC0'/j!<Z(Z("	

B( !!#Jgj)CF|| zz	
 ..rxx3T/RSS	
H &(+	
s   0?Fc                     t        j                  d       t        j                  t	        d      dt
        j                  dgg dt	        t        dd            t        j                  dt        j                  dgd	
      t        j                  t        j                  t        j                  t        j                  gd	
      t        j                  ddd
      dt
        j                  dgg dg dd
      } | j                         j                         }t        t        |      d      }t        j                  t        t        j                   g dt
        j"                  
            t        t        j                   dt        j                  dgt
        j"                  
            t        t        j                   dt        j                  dgt
        j"                  
            t        j                  g dd	
      t        j                  dt        j                  dgd	
      t        j                  t        j                  t        j                  t        j                  gd	
      t        j                  g dd
      t        j                  dt        j                  dgd
      t        j                  g dd
      t        j                  ddt        j                  gd
      d
      }t%        j&                  ||       y )Nr~   r   r   r   r   r   r   r   Int64r   r   r   r7   rR   r   r   r   )
r   r   r   r   int_with_nanna_onlyr   r   r1   r   numpy_nullabler   )r   r   r   r   r   r   )r   g      @g      @Float64booleanTF)r   r   r!   r"   r   rX   r   r   r?   NAr   r   r   r   r   r   rY   object_rC   r   )r   r   r   rF   s       r   %test_orc_dtype_backend_numpy_nullabler   V  s   
	"	5k #RVVS1 0a$IIq"%%m7Cyy"%%!6gFYYsCy9"BFFC0'/	

B !!#Jgj)9IJF||!"((?"**"MN*#ruuc*"**=  !,#ruuc*"**=! 99Yg6IIq"%%m7Cyy"%%!6gFYYi@ iibeeS(9KII1CIItUBEE&:)L	
H& &(+r   c            	      V   t        j                  dt        t        dd            i      } t	        j
                  d      5 }| j                  |       t        j                  |      j                         }t        |      }d d d        t	        j                  |        y # 1 sw Y    xY w)Nr   r   r   tmp.orc)r!   r"   r   r   rC   r   r   pathlibPathas_urir   r   )rF   rA   urir   s       r   test_orc_uri_pathr     s    ||UDq!$567H		# tll4 '')# &(+	 s    A BB(r:   )startstopstepr   znon-default)r   r   r   namer   c                     t        j                  dg di|       }d}t        j                  t        |      5  |j                          d d d        y # 1 sw Y   y xY w)Nr   r   r9   z[orc does not support serializing a non-default index|orc does not serialize index meta-datar   )r!   r"   r   r   
ValueErrorr   )r:   r   r   s      r   test_to_orc_non_default_indexr     sQ     
sI&e	4B	1  
z	- 
		  s   AAc            	      L   d} t        j                  dt        t        dd            i      }t	        j
                  d      5 }|j                  |       t        j                  t        |       5  t        |d       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)	NzPdtype_backend numpy is invalid, only 'numpy_nullable' and 'pyarrow' are allowed.r   r   r   r   r   numpyr   )r!   r"   r   r   rC   r   r   r   r   r   r   )r   r   rA   s      r   test_invalid_dtype_backendr     s    	!  
ud5A;/0	1B		# 2t
		$]]:S1 	2T1	22 2	2 	22 2s$   -B/B=BB	BB#c                 `   | dz  }t        j                  dddgi      }|j                  |       t        j                  dd      5  t	        |      }d d d        t        j                  dddgidt        j
                  dgd	      
      }t        j                  |       y # 1 sw Y   RxY w)Nztest_string_inference.pr   xy)r	   zfuture.infer_stringTzstring[pyarrow_numpy]r   )r	   r   r<   )r!   r"   r   option_contextr   IndexrC   r   )tmp_pathrA   r   r   rF   s        r   test_string_inferencer     s    //D	C#s,	-BIIdO			0$	7  $ ||C:%#&=>H
 &(+   s   B$$B-)2__doc__rk   decimalr   r   r   r@   r   r   rX   r   pandasr!   r   pandas._testing_testingrC   pandas.core.arraysr   r   r~   r   markfilterwarnings
pytestmarkfixturer   rY   r?   IntervalPeriodr%   rJ   r]   rb   rl   ro   r{   r   r   r   r   r   r   parametrizer=   r   r   r   r   r   r   r   <module>r      s       	       *   M " [[''C

 ) ) !R)		/4	!1	%{r{{'CD	<c	*IBIIl,MN	33#B#(#6&#R&#R&#R'2#01 ,F(,V, AAA.AAAMB	2,r   