
    bMh7              
          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    X/var/www/html/test/jupyter/venv/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           	         g d}dddddddd	|rd
nd	g	}t          j        t          j        d                    }t          ||          D ]\  }}t          j        |          ||<   |j                            d
          |_        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objectstrr   indexr   zTestOrcFile.emptyFile.orccolumns)r!   r"   
RangeIndexzipSeriesr=   astypeospathjoinr   tmassert_equal)	r   using_infer_stringr=   dtypesexpectedcolnamer   	inputfilegots	            r   test_orc_reader_emptyrM   -   s    
 
 
G 	#1
F |"-"2"2333Hgv.. 3 3IE222'..u55H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_dictrB   rC   rD   r   keysrE   rF   r   r	   rI   rK   rL   s        r   test_orc_reader_basicr`   O   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
   )r[   r\   r   r!   r"   r]   rB   rC   rD   r   ilocrE   rF   r_   s        r   test_orc_reader_decimalre   c   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.orcrc   r[   r\   datetimerl   r!   r"   r]   rB   rC   rD   r   rd   rE   rF   r_   s        r   test_orc_reader_date_lowro   ~   _      #
 
 
 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.100900rg   r   i  rh   ri   r8   rj   zTestOrcFile.testDate2038.orcrc   rm   r_   s        r   test_orc_reader_date_highrr      rp   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.orcrc   )r[   r\   r!   r"   r]   rB   rC   rD   r   rd   rE   rF   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   rO   r2   rP   rQ   r3   rR   r4   rS   r5   rT   rU   r6   rV   rW   r7   rX   r   r8   rY   rZ   r'   )pytestimportorskipr[   r\   r!   r"   r]   rE   ensure_cleanto_orcr   rF   )r   r	   rI   rC   rL   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   r[   r\   r!   r"   r]   r   r   r   rE   rF   )r	   rI   bytesrL   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                       }| rt          j        t%          j                              }|d                             |          |d<   |d                             |          |d<   |d                             |          |d<   t+          j        ||           d S )Nr   abcr   cr   Nr   )s   foos   barNr            @      @r7   r   rU         @TFTTFN20130101   )periods20130103)stringstring_with_nanstring_with_noner   intfloatfloat_with_nanr1   bool_with_narn   datetime_with_natdtype_backendc           	          i | ]<}|t           j                            t          j        |         d                     =S )T)from_pandas)r!   arraysArrowExtensionArraypar\   ).0coldfs     r   
<dictcomp>z2test_orc_dtype_backend_pyarrow.<locals>.<dictcomp>N  sN     	
 	
 	
 ..rx3T/R/R/RSS	
 	
 	
r   r   r   r   )r   r   r!   r"   listr[   nanrangearange
date_range	TimestampNaTcopyr   r   r   r=   
ArrowDtyper   r   rA   rE   assert_frame_equal)rG   
bytes_dataresultrI   string_dtyper   s        @r   test_orc_dtype_backend_pyarrowr   4  s   
	"""	5kk #RVS1 0 0 0+++a$$YsCy999"BFC0'''///j!<<<Z((Z(("	
 	

 
B( !!##Jgj))CCCF|	
 	
 	
 	
z	
 	
 	
 H  Y }RY[[11%h/66|DD&./@&A&H&H&V&V"#'/0B'C'J'J<'X'X#$&(+++++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   rU   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   r[   r   r   r@   NAr   r   r   r   r   r   r\   object_rE   r   )r   r   r   rI   s       r   %test_orc_dtype_backend_numpy_nullabler   ^  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   rE   r   r   pathlibPathas_urir   r   )rI   rC   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   r:   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   rE   r   r   r   r   r   r   )r   r   rC   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           
         | 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t          j        t          j                  t          j        dgt          j        t          j                  	          
          }t          j
        ||           d S )Nztest_string_inference.pr   xy)r	   zfuture.infer_stringT)na_valuer   )r	   r   r=   )r!   r"   r   option_contextr   StringDtyper[   r   IndexrE   r   )tmp_pathrC   r   r   rI   s        r   test_string_inferencer     s   //D	C#s,	-	-	-BIIdOOO		0$	7	7    $                             |C:nbf---#bnbf&E&E&EFFF  H
 &(+++++s   	A%%A),A))2__doc__rn   decimalr   r   r   rB   r   r   r[   r   pandasr!   r   pandas._testing_testingrE   pandas.core.arraysr   r   r   r   markfilterwarnings
pytestmarkfixturer   r\   r@   IntervalPeriodr%   rM   r`   re   ro   rr   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# # #D# # #(# # #6&# &# &#R&# &# &#R&# &# &#R' ' '2# # #01 1 1', ', ',T(, (, (,V, , , AAA...AAAMBBB   	2 	2 	2, , , , ,r   