
    [6g_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                            d          Ze
j        d	             Z e
j         e	j        d
dgd           ej        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        ,                    d% ej-        ddd
&           ej-        dd'd
d()           ej.        g d*          g          d+             Z/d, Z0d- Z1dS ).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    W/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/pandas/tests/io/test_orc.pydirpathr      s    8D&%(((          uint64dtype)abr   category   )leftright   z
2022-01-03D)freqz
2022-01-04)paramsc                 8    t          j        d| j        i          S )Nunimpl)pd	DataFrameparam)requests    r   orc_writer_dtypes_not_supportedr%      s     <7=1222r   c                 L   g d}g d}t          j        t          j        d                    }t          ||          D ]\  }}t          j        |          ||<   t
          j                            | d          }t          ||          }t          j
        ||           d S )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"2333Hgv.. 3 3IE222W&ABBI
9g
.
.
.COHc"""""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                            |          }t
          j                            | d          }t          ||	                                          }t          j        ||           d S )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   s8   HeT]&9991c(&111(D$<w777%w777.0CDGTTT(C:Y7778UDM;;;(3S9JJJ8T5M:::
 
D |%%d++HW&=>>I
9diikk
2
2
2COHc"""""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                            |          }t          j                            | d          }t          |          j
        d d         }t          j        ||           d S )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


"3B3
'COHc"""""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                            |          }t          j        	                    | d	          }t          |          j        d d
         }t          j        ||           d S )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EEI
9


"3B3
'COHc"""""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                            |          }t          j        	                    | d	          }t          |          j        d d
         }t          j        ||           d S )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                 H   t          j        g dd          t          j        g dd          d}t          j                            |          }t
          j                            | d          }t          |          j	        d d         }t          j        ||           d S )	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       
 
 
 8   
 
 
! D@ |%%d++HW&BCCI
9


"3B3
'COHc"""""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                            |          }t          j                    5 }|	                    |           t          |          }t          j        ||           d d d            d S # 1 swxY w Y   d S 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    	""" HeT]&9991c(&111(D$<w777%w777.0CDGTTT(C:Y7778UDM;;;(3S9JJJ8T5M:::
 
D |%%d++H			 'dtnn
#&&&	' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 's   :E  E$'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                            |           }|                                }t          t          |                    }t          j        ||           d S r}   )r   r   rX   rY   r!   r"   rZ   r   r   r   rC   rD   )r	   rF   bytesrI   s       r   test_orc_roundtrip_bytesior     s?    	""" HeT]&9991c(&111(D$<w777%w777.0CDGTTT(C:Y7778UDM;;;(3S9JJJ8T5M:::
 
D |%%d++HOOE
75>>
"
"COHc"""""r   c                     t          j        d           d}t          j        t          |          5  |                                  d d d            d S # 1 swxY w Y   d S )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   )  s     	"""
BC	*#	6	6	6 1 1'..0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s   A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                                                                          } t          t          |           d          }t          j        fdj        D                       }t#          j        ||           d S )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_backendc           	          i | ]<}|t           j                            t          j        |         d                     =S )T)from_pandas)r!   arraysArrowExtensionArrayparY   ).0coldfs     r   
<dictcomp>z2test_orc_dtype_backend_pyarrow.<locals>.<dictcomp>M  sN     	
 	
 	
 ..rx3T/R/R/RSS	
 	
 	
r   )r   r   r!   r"   listrX   nanrangearange
date_range	TimestampNaTcopyr   r   r   r<   rC   assert_frame_equal)
bytes_dataresultrF   r   s      @r   test_orc_dtype_backend_pyarrowr   3  sZ   
	"""	5kk #RVS1 0 0 0+++a$$YsCy999"BFC0'''///j!<<<Z((Z(("	
 	

 
B( !!##Jgj))CCCF|	
 	
 	
 	
z	
 	
 	
 H &(+++++r   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
          } |                                                                 }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        ||           d S )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  sb   
	"""	5kk #RVS1 0 0 0a$$Iq"%m7CCCy"%!6gFFFYsCy999"BFC0'''///	
 	

 
B !!##Jgj))9IJJJF|!"(???"*"M"M"MNN*#ruc*"*===    !,#ruc*"*===! ! 9YYYg666Iq"%m7CCCy"%!6gFFFYi@@@ ibeS(9KKKI111CCCItUBE&:)LLL	
 	
 H& &(+++++r   c            	      ~   t          j        dt          t          dd                    i          } t	          j        d          5 }|                     |           t          j        |          	                                }t          |          }d d d            n# 1 swxY w Y   t	          j        ||            d S )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$5677H		#	# tl4  ''))#               &(+++++s   AB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  |                                 d d d            d S # 1 swxY w Y   d S )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     s     
sIII&e	4	4	4B	1  
z	-	-	-  
		                 s   AA!Ac            	      x   d} t          j        dt          t          dd                    i          }t	          j        d          5 }|                    |           t          j        t          |           5  t          |d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )	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	1	1B		#	# 2t
		$]:S111 	2 	2T1111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	22 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2s6   1B/9BB/B	B/B	B//B36B3c                 n   | dz  }t          j        dddgi          }|                    |           t          j        dd          5  t	          |          }d d d            n# 1 swxY w Y   t          j        dddgidt          j        dgd	          
          }t          j        ||           d S )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IIdOOO		0$	7	7    $                             |C:%#&=>>>  H
 &(+++++s   	A%%A),A))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44	!1	%	%	%{r{'C'C'CD	<c	*	*	*IBIl,M,M,MN	  3 3 3# # #B# # #(# # #6&# &# &#R&# &# &#R&# &# &#R' ' '2# # #01 1 1 ,  ,  ,F(, (, (,V, , , AAA...AAAMBBB   	2 	2 	2, , , , ,r   