
    g6U                     L   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c mZ d dlmZ 	 d dlZd Zd Zej(                  j                   d        Zej(                  j                   ej(                  j,                  d               Zd Zd	 Zd
 Zd Zd Zd Zej(                  j
                  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*d Z+d Z,d Z-d Z.d Z/ej(                  j                   d         Z0d! Z1d" Z2d# Z3y# e$ r dZY w xY w# e$ r Y w xY w)$    )OrderedDictN)Versionc                      d} t        j                  t        |       5  t        j                          d d d        y # 1 sw Y   y xY w)NzGDo not call Schema's constructor directly, use `pyarrow.schema` instead)match)pytestraises	TypeErrorpaSchema)msgs    N/var/www/openai/venv/lib/python3.12/site-packages/pyarrow/tests/test_schema.pytest_schema_constructor_errorsr   &   s,    C	y	,
		 
-	,	,s	   <Ac                  h    g d} | D ])  }t        t        |      } |       }t        |      |k(  r)J  y )N)int8int16int32int64uint8uint16uint32uint64)getattrr
   str)dtypesnamefactoryts       r   test_type_integersr   -   s8    5F "d#I1v~~     c                     t        j                  d      } t        t        j                        t        d      k  rt        j                  d      } t        j                         t         j                  ft        j                         t         j                  ft        j                         t         j                  ft        j                         t         j                  ft        j                         t         j                  ft        j                         t         j                  ft        j                         t         j                  ft        j                         t         j                  ft        j                         t         j                  ft        j                          t         j                   ft        j"                         t         j"                  ft        j$                         t         j$                  ft        j&                         t         j&                  ft        j(                         | ft        j*                         | ft        j,                  d      | ft        j.                         t         j                  ft        j.                  d      t         j                  ft        j0                         t         j                  ft        j2                  t        j                               t         j                  ft        j4                  t        j                         t        j&                               t         j                  fg}|D ]  \  }}|j7                         |k(  rJ  y )Ndatetime64[ms]z2.0.0datetime64[ns]ms   )npdtyper   pd__version__r
   nullobject_bool_r   r   r   r   r   r   r   r   float16float32float64date32date64	timestampbinarystringlist_map_to_pandas_dtype)M8cases
arrow_type
numpy_types       r   test_type_to_pandas_dtyper;   7   s   	"	#Br~~!11XX&'	BJJ	RXX	BGG	RXX	RXX	RXX	RXX	bii 	bii 	bii 	rzz"	rzz"	rzz"	b	b	d	R 	bjj!	2

#	bjj!	"'')	bjj)	RZZ\	*BJJ7-E0 #(
J))+z999 #(r   c                  .    t        j                  d       y )Nzarrow_7980.py)	test_utilinvoke_script r   r   &test_type_to_pandas_dtype_check_importr@   X   s     O,r   c                     t        j                         } t        j                  |       }t        |      dk(  sJ t        j                  dt        j
                               }t        j                  |      }t        |      dk(  sJ y )Nzlist<item: int32>my_itemzlist<my_item: string>)r
   r   r4   r   fieldr3   )
value_type	list_typerC   l2s       r   test_type_listrG   _   sd    J$Iy>0000HHY		,E	%Br7----r   c                  z    t        j                         } | t        j                         k(  sJ | dk(  sJ | dk7  sJ y )Nr      )r
   r   )vals    r   test_type_comparisonsrK   i   s8    
((*C"((*'>>!8O8r   c                     g dt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fd	t        j
                         fd
t        j
                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                         fdt        j                  d      fdt        j                  d      fdt        j                   d      fd t        j                   d!      fd"t        j"                  d      fd#t        j"                  d      fd$t        j"                  d      fd%t        j"                  d!      fd&t        j$                  d      fd't        j$                  d      fd(t        j$                  d      fd)t        j$                  d!      fd*t        j&                         f} | D ]  \  }}t        j(                  |      |k(  rJ  y )+Ni1r   i2r   i4r   i8r   u1r   u2r   u4r   u8r   f4r-   f8r.   r/   r0   r3   r   r2   	time32[s]sz
time32[ms]r#   z
time64[us]us
time64[ns]nsztimestamp[s]ztimestamp[ms]ztimestamp[us]ztimestamp[ns]zduration[s]zduration[ms]zduration[us]zduration[ns]month_day_nano_interval)r
   r   r   r   r   r   r   r   r   r-   r.   r/   r0   r3   r2   time32time64r1   durationr\   type_for_alias)r8   rJ   expecteds      r   test_type_for_aliasrb   p   s~   '	rwwy'	' 
rxxz' 
"((*	'
 
rxxz' 
"((*' 
rxxz' 
"((*' 
rxxz' 
"((*' 
ryy{' 
299;' 
ryy{' 
299;' 
ryy{'  
299;!'" 
rzz|#'$ 
BJJL!%'& 
rzz|''( 
BJJL!)'* 
299;+', 
299;-'. 
299;/'0 
		1'2 
299;3'4 
biin%5'6 
ryy'7'8 
ryy'9': 
ryy';'< 
c*+='> 
",,t,-?'@ 
",,t,-A'B 
",,t,-C'D 
C()E'F 
T*+G'H 
T*+I'J 
T*+K'L 
#B$>$>$@AM'ER X  %111 r   c                  L    t        j                         } t        |       dk(  sJ y )Nr3   )r
   r3   r   )r   s    r   test_type_stringrd      s    
		Aq6Xr   c                  z    d} t        j                  d|       }|j                  dk(  sJ |j                  | k(  sJ y )NzAmerica/Los_Angelesr[   )tz)r
   r1   unitrf   )rf   r   s     r   test_type_timestamp_with_tzrh      s7    	B
Tb!A66T>>442::r   c                     t        j                  d      } t        j                  d      }t        j                  d      }t        j                  d      }| j                  dk(  sJ |j                  dk(  sJ |j                  dk(  sJ |j                  dk(  sJ t	        |       dk(  sJ t	        |      dk(  sJ t        j                  t              5  t        j                  d       d d d        t        j                  t              5  t        j                  d       d d d        y # 1 sw Y   AxY w# 1 sw Y   y xY w)NrX   r#   rY   r[   rW   rZ   )r
   r]   r^   rg   r   r   r   
ValueError)t1t2t3t4s       r   test_time_typesro      s    	3B	4B	4B	4B77c>>77d??77d??77d??r7k!!!r7l"""	z	"
		$ 
# 
z	"
		# 
#	" 
#	" 
#	"s   D(	D4(D14D=c                  	   t        j                  d      t        j                         ft        j                  d      t        j                         ft        j                  d      t        j
                         ft        j                  d      t        j                         ft        j                  d      t        j                         ft        j                  d      t        j                         ft        j                  d      t        j                         ft        j                  d      t        j                         ft        j                  d	      t        j                         ft        j                  d
      t        j                         ft        j                  d      t        j                         ft        j                  d      t        j                         ft        j                  d      t        j                         ft        j                  d      t        j                   d      ft        j                  d      t        j                   d      ft        j                  d      t        j                   d      ft        j                  d      t        j                   d      ft        j                  d      t        j"                  d      ft        j                  d      t        j"                  d      ft        j                  d      t        j"                  d      ft        j                  d      t        j"                  d      fg} | D ]!  \  }}t        j$                  |      }||k(  r!J  t        j$                  d      t        j                         k(  sJ t        j$                  t         j&                        t        j                         k(  sJ t        j$                  d      t        j                         k(  sJ t        j$                  t(              t        j                         k(  sJ t+        j,                  t.              5  t        j$                  t        j                  d             d d d        t+        j,                  t0              5  t        j$                  d       d d d        y # 1 sw Y   AxY w# 1 sw Y   y xY w)Nboolr   r   r   r   r   r   r   r,   r-   r.   USzdatetime64[s]rX   r!   r#   zdatetime64[us]rY   r"   r[   ztimedelta64[s]ztimedelta64[ms]ztimedelta64[us]ztimedelta64[ns]Onot_convertible_to_dtype)r%   r&   r
   r+   r   r   r   r   r   r   r   r,   r-   r.   r3   r2   r1   r_   from_numpy_dtypestr_rq   r   r   NotImplementedErrorr	   )r8   dtptresults       r   test_from_numpy_dtyper|      s    
&	288:&	&	2779%	'	BHHJ'	'	BHHJ'	'	BHHJ'	'	BHHJ'	(	RYY[)	(	RYY[)	)	bjjl+	)	bjjl+	)	bjjl+	#		$	#		$	/	"BLL$56	"	#R\\$%78	"	#R\\$%78	"	#R\\$%78	"	#R[[%56	#	$bkk$&78	#	$bkk$&78	#	$bkk$&78+E0 B$$R(|| 
 s#ryy{222rww'299;666w'288:555t$
222	*	+
BHHSM* 
, 
y	!
67 
"	! 
,	+ 
"	!s   )R=S	=S	Sc            	         t        j                  dt        j                               t        j                  dt        j                               t        j                  dt        j                  t        j
                                     g} t        j                  |       }|j                  g dk(  sJ |j                  t        j                         t        j                         t        j                  t        j
                               gk(  sJ t        |      dk(  sJ |d   j                  dk(  sJ |d   j                  | d   j                  k(  sJ |j                  d      j                  dk(  sJ |j                  d      j                  | d   j                  k(  sJ t        |      dk(  sJ t        j                  t              5  t        j                  d g       d d d        y # 1 sw Y   y xY w)Nfoobarbazr~   r   r      r   Bfoo: int32
bar: string
baz: list<item: int8>
  child 0, item: int8)r
   rC   r   r3   r4   r   schemanamestypeslenr   typereprr   r   r	   fieldsschs     r   test_schemar      sn   

#
		$
+,F
 ))F
C99----99RYY["((27792EFFFFs8q==q6;;%q6;;&)..(((99U  E)))99U  F1INN2229     
y	!
		4& 
"	!	!s   G++G4c            	         t        j                  dt        j                               t        j                  dt        j                               t        j                  dt        j                  t        j
                                     g} t        j                  |       }t        j                  |      } |       J ~ |       J y )Nr~   r   r   )	r
   rC   r   r3   r4   r   r   weakrefref)r   r   wrs      r   test_schema_weakrefr     s    

#
		$
+,F
 YYvF	V	B44<<r   c            
      h   d} t        j                  t        j                  dddddi      t        j                  dd	d
ddi      gd| i      }|j                         d| d d z   dz   t	        t        |       dz
        z   k(  sJ t        j                  dgddi      j                         }|dk(  sJ |j                  d      dj                  |       k(  sJ |j                  dd      dj                  |       k(  sJ |j                  dd      dk(  sJ |j                  ddd      dk(  sJ y )Na  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla accumsan vel
turpis et mollis. Aliquam tincidunt arcu id tortor blandit blandit. Donec
eget leo quis lectus scelerisque varius. Class aptent taciti sociosqu ad
litora torquent per conubia nostra, per inceptos himenaeos. Praesent
faucibus, diam eu volutpat iaculis, tellus est porta ligula, a efficitur
turpis nulla facilisis quam. Aliquam vitae lorem erat. Proin a dolor ac libero
dignissim mollis vitae eu mauris. Quisque posuere tellus vitae massa
pellentesque sagittis. Aenean feugiat, diam ac dignissim fermentum, lorem
sapien commodo massa, vel volutpat orci nisi eu justo. Nulla non blandit
sapien. Quisque pretium vestibulum urna eu vehicula.r~   r   Fkey1value1metadatar   r3   Tkey3value3loremzfoo: int32 not null
  -- field metadata --
  key1: 'value1'
bar: string
  -- field metadata --
  key3: 'value3'
-- schema metadata --
lorem: 'A   z' + )f0r   keyCvaluexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzjf0: int32
-- schema metadata --
key: 'valuexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')truncate_metadatazfoo: int32 not null
  -- field metadata --
  key1: 'value1'
bar: string
  -- field metadata --
  key3: 'value3'
-- schema metadata --
lorem: '{}')r   show_field_metadatazAfoo: int32 not null
bar: string
-- schema metadata --
lorem: '{}')r   show_schema_metadatazofoo: int32 not null
  -- field metadata --
  key1: 'value1'
bar: string
  -- field metadata --
  key3: 'value3')r   r   r   zfoo: int32 not null
bar: string)r
   r   rC   	to_stringr   r   format)r   	my_schemar{   s      r   #test_schema_to_string_with_metadatar     s   
8E 		288E7E.4h-?A88E8T.4h-?AB %,U#3	5I   % CRj% "%" %(E
R$8%9 9 9 9 YY(!&(: ;==FY[  & & & & 7 < ve}   38  :> ve}   49  ;?   3849  ;?  r   c                  ~   dt        j                         fdt        j                         fdt        j                  t        j                               fg} t        j
                  |       }|j                  g dk(  sJ |j                  t        j                         t        j                         t        j                  t        j                               gk(  sJ t        |      dk(  sJ t        |      dk(  sJ t        j                  t              5  t        j
                  dg       d d d        y # 1 sw Y   y xY wNr~   r   r   r   r   r   )r~   N)r
   r   r3   r4   r   r   r   r   r   r   r   r   r	   r   s     r   test_schema_from_tuplesr   Y  s    	
				#$F
 ))F
C99----99RYY["((27792EFFFFs8q==9     
y	!
		=/" 
"	!	!s   D33D<c            	         t        dt        j                         fdt        j                         fdt        j                  t        j
                               fg      } t        j                  |       }|j                  g dk(  sJ |j                  t        j                         t        j                         t        j                  t        j
                               gk(  sJ t        |      dk(  sJ t        |      dk(  sJ t        dg      } t        j                  t              5  t        j                  |        d d d        y # 1 sw Y   y xY wr   )r   r
   r   r3   r4   r   r   r   r   r   r   r   r   r	   r   s     r   test_schema_from_mappingr   m  s    	
				#$ F
 ))F
C99----99RYY["((27792EFFFFs8q==9     -)F	y	!
		& 
"	!	!s   (EEc            	         t        j                  dt        j                               t        j                  dt        j                               t        j                  dt        j                  t        j
                                     g} t        j                  |       }|j                  g dk(  sJ |j                  t        j                         t        j                         t        j                  t        j
                               gk(  sJ t        |      dk(  sJ t        |      dk(  sJ |d   j                  dk(  sJ |d   j                  | d   j                  k(  sJ t        j                  t              5  |j!                  d      | d   k(  sJ 	 d d d        t        j                  t              5  |j!                  d      J 	 d d d        t        j                  t"        t        f      5  |j!                  d      J 	 d d d        |j%                  d      d	k(  sJ |j'                  d      dd
gk(  sJ y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   PxY w)Nr~   r   )r~   r   r~   r   zBfoo: int32
bar: string
foo: list<item: int8>
  child 0, item: int8r      xxx   )r
   rC   r   r3   r4   r   r   r   r   r   r   r   r   r   warnsFutureWarningfield_by_nameUserWarningget_field_indexget_all_field_indicesr   s     r   test_schema_duplicate_fieldsr     s   

#
		$
+,F
 ))F
C99----99RYY["((27792EFFFFs8q==9     q6;;%q6;;&)..(((	m	$  '6!9444 
%	m	$  '/// 
%	{M2	3  '/// 
4 u%+++ $$U+1v555 
%	$	$	$	3	3s$   >I:I6IIII#c                  L   t        j                  dt        j                               j                  ddi      } | j	                         | gk(  sJ t        j                  dt        j
                         d      }t        j                  dt        j                  | |g      d      }|j	                         t        j                  dt        j                               j                  ddi      t        j                  d	t        j
                         d      gk(  sJ t        j                  dt        j                  | |g            }|j	                         t        j                  dt        j                               j                  ddi      t        j                  d	t        j
                               gk(  sJ t        j                  d
t        j                  |g            }|j	                         t        j                  dt        j                  | |g            gk(  sJ y )Nr~      foo   barr   Fnullableffzff.foozff.barfffzfff.ff)r
   rC   r   with_metadataflattenr.   struct)r   f1r   r   s       r   test_field_flattenr     s   	%	$	2	2FF3C	DB::<B4	%	6B	$		2r(+e	<B::<
288:&44ff5EF
2::<%8: : : :
 
$		2r(+	,B::<
288:&44ff5EF
2::<(* * * * ((5"))RD/
*C;;=RXXh		2r(0CDEEEEr   c            	      $   t        j                  dt        j                               t        j                  dt        j                               t        j                  dt        j                  t        j
                                     g} t        j                  |       }|j                  J ddd}|j                  |      }|j                  |k(  sJ |j                         }|j                  J |j                         }|j                  J y )Nr~   r   r   r      badgerr   s   pandas)
r
   rC   r   r3   r4   r   r   r   r   remove_metadata)r   s1r   s2s3s4s         r   test_schema_add_remove_metadatar     s    

#
		$
+,F 
6	B;;95H			(	#B;;("""				B;; 
			B;;r   c            	         t        j                  dt        j                               t        j                  dt        j                               t        j                  dt        j                  t        j
                                     g} ddd}t        j                  |       }t        j                  |       }t        j                  | |      }t        j                  | |      }|j                  |d	      sJ |j                  |d	      sJ |j                  |      sJ |j                  |d	      rJ |j                  |d	      rJ | d
= t        j                  |       }|j                  |      rJ y )Nr~   r   r   r   r   r   r   Tcheck_metadatar   )r
   rC   r   r3   r4   r   r   equalsr   r   sch1sch2sch3sch4s         r   test_schema_equalsr     s*   

#
		$
+,F
 95H99VD99VD99Vh/D99Vh/D;;tD;111;;tD;111;;t{{4{555{{4{555r
99VD{{4    r   c            	         t        j                  t        j                  dt        j                               t        j                  dt        j                               g      } t        j                  t        j                  dt        j                               t        j                  dt        j                         ddi      g      }| j                  |d      rJ | j                  |      sJ y )Nr~   r   aalphar   Tr   )r
   r   rC   r   r3   r   )schema1schema2s     r   ,test_schema_equals_propagates_check_metadatar     s    ii

#
		$ G ii

#
		sGn= G ~~gd~;;;>>'"""r   c                  8   t        j                  t        j                  dt        j                               g      } d dt        j                  ddg      fD ]5  }t        j                  t              5  | j                  |       d d d        7 y # 1 sw Y   BxY w)Nr   r3   r   r   )	r
   r   rC   r   arrayr   r   r	   r   )r   rJ   s     r   test_schema_equals_invalid_typer     si    YYbhhj123Fh!Q 01]]9%MM# &% 2%%s   3BB	c            	      4   t        j                  dt        j                               t        j                  dt        j                               t        j                  dt        j                  t        j
                                     g} ddd}t        j                  |       }t        j                  |       }t        j                  | |      }t        j                  | |      }||k(  sJ ||k(  sJ ||k(  sJ ||k7  rJ ||k(  sJ |g k7  sJ |dk7  sJ y )Nr~   r   r   r   r   r   r   )r
   rC   r   r3   r4   r   r   r   s         r   test_schema_equality_operatorsr     s    

#
		$
+,F
 95H99VD99VD99Vh/D99Vh/D4<<4<< 4<<t|4<< 2::5==r   c            	      |   t        j                  dt        j                               t        j                  dt        j                               t        j                  dt        j                  t        j
                                     g} t        j                  |       }|j                  d      j                  dk(  sJ |j                  d      j                  dk(  sJ |j                  d      j                  dk(  sJ t        j                  t              5  |j                  d       d d d        t        j                  t              5  |j                  d       d d d        t        j                  t              5  |j                  d       d d d        y # 1 sw Y   pxY w# 1 sw Y   IxY w# 1 sw Y   y xY w)	Nr~   r   r   r   r   otherg           )r
   rC   r   r3   r4   r   r   r   r   r   KeyErrorr	   
IndexErrorr   r   s     r   test_schema_get_fieldsr     s$   

#
		$
+,F YYvF<<##u,,,<<?5(((<<  E)))	x	 W 
!	y	!S 
"	z	"Q 
#	"	 
!	 	!	!	"	"s$   FF&?F2F#&F/2F;c            	         t        j                  dt        j                               t        j                  dt        j                               t        j                  dt        j                  t        j
                                     g} t        j                  |       }|d   j                  |d         sJ |d   j                  |d         sJ |d   j                  |d	         sJ t        j                  t              5  |d
    d d d        t        j                  t              5  |d    d d d        y # 1 sw Y   1xY w# 1 sw Y   y xY w)Nr~   r   r   r   r   r   r   r   )r
   rC   r   r3   r4   r   r   r   r   r   r   r   s     r   test_schema_negative_indexingr   -  s    

#
		$
+,F YYvF":VAY'''":VAY'''":VAY'''	z	"r
 
# 
z	"q	 
#	" 
#	" 
#	"s   D:+E:EEc                  >   t        j                  dt        j                  t        j                         t        j                                     t        j                  dt        j
                               g} t        j                  |       }d}t        |      |k(  sJ y )NonetwozCone: dictionary<values=string, indices=int16, ordered=0>
two: int32)r
   rC   
dictionaryr   r3   r   r   r   )r   r   ra   s      r   "test_schema_repr_with_dictionariesr   A  sp    
bhhj"))+>?

#F ))F
C	 
 9   r   c                    t        j                         t        j                         t        j                         t        j                  d      t        j                  t        j                               t        j
                  t        j                         t        j                               t        j                  t        j                  dd      t        j                  dd      g      t        j                  t        j                  dt        j                               t        j                  dt        j                               gt         j                  j                        t        j                  t        j                  dt        j                               t        j                  dt        j                               gt         j                  j                        t        j                  d      t        j                  d      t        j                         t        j                          t        j"                  d      t        j"                  d	      t        j$                  d
d      t        j&                  dd      t        j                  ddddi      t        j                  t        j                  dt        j(                                     t        j*                  t        j                  dt        j(                                     t        j
                  t        j                  dt        j                         d      t        j                  dt        j                                     g}|D ])  }| j-                  | j/                  |            }||k(  r)J  g }t1        |      D ]e  \  }}t3        |t         j4                        r|j7                  |       2|j7                  t        j                  dj9                  |      |             g t        j:                  |ddi      }| j-                  | j/                  |            }||k(  sJ y )N
   r   r   br3   rX   rY   r#   r[   r$   r   L   &   r   r   r   elementr   Fr   valuez_f{})r
   r   r3   r2   r4   r5   r   rC   unionr   libUnionMode_SPARSEUnionMode_DENSEr]   r^   r/   r0   r1   
decimal128
decimal256r   
large_listloadsdumps	enumerate
isinstanceFieldappendr   r   )pickle_moduler8   rJ   roundtrippedr   ifr   s           r   test_type_schema_picklingr
  P  s   
	
		
		
		"

		RWWY'
		HHS&!HHS(#
 	 	HHS"'')$HHS"((*%
 66""	$ 	HHS"'')$HHS"((*%
 66!!	# 			#
		$
		
		
T
T
b!
b"
h&&)9:
)RXXZ01
bhhy"((*56
		e<"''),	.= ED $**=+>+>s+CDl"""  F% 1a"MM!MM"((6==#3Q78	 ! YYv(89F &&}':':6'BCL\!!!r   c                  (   t        j                  t        j                  dt        j                               t        j                  dt        j                  t        j
                         t        j                                     t        j                  dt        j                  t        j                  t        j                                           g      } t        j                  t        j                  dt        j                         d      t        j                  dt        j                               g      }| |fD ]P  }|j                         }t        |t         j                        sJ |j                  dk(  sJ |j                  |k(  rPJ  y )	Nr   r   f2r   Fr   r   r   )r
   r   rC   r   r   r   r3   r4   empty_tabler  Tablenum_rows)r   r   r   tables       r   test_empty_tabler    s
   ii
rxxz"
r}}RXXZ=>
rxx 456 G ii
bhhj51
bhhj! G
 G$""$%***~~"""||v%%%	 %r   c            	         dd l } t        t        d             | j                  t        t        d                  g dt	        j
                  g dd       | j
                  g d | j                               g}|D ]g  } | j                  d|i|	      }t        j                  j                  |      }t        j                  j                  |      j                  }||k(  rgJ  y )
Nr   r   )r~   r   Nr   qux)z2007-07-13T01:23:34.123456789z2006-01-13T12:34:56.432539784z2010-08-13T05:46:57.437699912r"   )r&   )r   r   Nr   )index)pandaslistrangeCategoricalr%   r   
Int32Dtype	DataFramer
   r   from_pandasr  r   )r'   inputsdatadfr   ra   s         r   test_schema_from_pandasr    s    U2YtE"I'*
 
 "		#
 	]R]]_5
F R\\3+T2&&r*88''+22!!!	 r   c                  (   t        j                  t        j                  dt        j                               t        j                  dt        j                               g      } t        j                  |       t
        j                  dkD  rdndkD  sJ | j                  ddi      }t        j                  |      t        j                  |       kD  sJ | j                  ddi      }t        j                  |      t        j                  |      kD  sJ y )	Nr~   r   l              r   zsome metadatazsome more metadata)	r
   r   rC   r   r3   sys	getsizeofmaxsizer   )r   r   schema3s      r   test_schema_sizeofr'    s    YY

#
		$ F == #++*=B2FFF""E?#;<G==!CMM&$9999""E+?#@AG==!CMM'$::::r   c                     t        j                  t        j                  dt        j                               t        j                  dt        j                               t        j                  dt        j
                  t        j                                     g      } t        j                  t        j                  dt        j                               t        j                  dt        j                               g      }t        j                  t        j                  dt        j                  t        j                         t        j                                     g      }t        j                  t        j                  dt        j                               t        j                  dt        j                               g      }t        j                  | ||g      }t        j                  t        j                  dt        j                               t        j                  dt        j                               t        j                  dt        j
                  t        j                                     t        j                  dt        j                               t        j                  dt        j                  t        j                         t        j                                     g      }|j                  |      sJ t        j                  t         j                        5  t        j                  ||g       d d d        t        j                  | ||f      }|j                  |      sJ t        j                  ||gd      }|j                  |      sJ t        j                  t              5  t        j                  | dg       d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)	Nr~   r   r   r  quux
permissive)promote_optionsr   )r
   r   rC   r   r3   r4   r   r+   r   r   unify_schemasr   r   r   ArrowTypeErrorr	   )r   r   cdr{   ra   s         r   test_schema_merger0    s   
		

#
		$
+, 	A
 			

#

# 	A 			
rxxz299;?@ 	A 			

#

# 	A
 q!Qi(Fyy

#
		$
+,

#
rxxz299;?@ H =="""	r((	)
!Q  
* q!Qi(F=="""q!flCF== 
y	!
!Q  
"	! 
*	) 
"	!s   %O5O"O"O+c                      d} d}t        j                  t        j                  dt        j                         d| i      gd|i      }dt	        |      v sJ dt	        |      v sJ y )Ns   abcdef s   ghijkl intsr   r   abcdefghijkl)r
   r   rC   r   r   )data1data2r   s      r   test_undecodable_metadatar7    sd    EEYY	&"((*u~	>?!F s6{"""s6{"""r   )4collectionsr   r#  r   r   numpyr%   ImportErrorpyarrowr
   pyarrow.tests.utiltestsutilr=   pyarrow.vendored.versionr   r  r'   r   r   markr;   	processesr@   rG   rK   rb   rd   rh   ro   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r
  r  r  r'  r0  r7  r?   r   r   <module>rB     sz  $ $ 
    & & ,	
 : :@ -  -
.+2\
* '8 '8T6
DN#(*6@F(0!0#6*(!0"f&& " "(;(!V#Y  	B  		s"   D D DDD#"D#