+
    nDj^:                    v   ^ RI t ^ RIt^ RIHtHt ^ RIHt ^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtHtHtHtHtHtHtH t H!t!H"t" ^ RI#H$t$ R t%R t&R t'R:R	 lt(R
 t)R t*R t+ ! R R4      t,R t-R t.R t/R t0R t1 ! R R] Pd                  4      t3 ! R R]34      t4 ! R R]44      t5 ! R R]44      t6 ! R R]34      t7 ! R R]74      t8]Pr                  P"                   ! R  R!]74      4       t: ! R" R#4      t; ! R$ R%];]Px                  4      t= ! R& R'];]Px                  4      t>R( t?R) t@R* tAR+ tBR, tC]Pr                  P                  R-R. R/ R0 R1 34      R2 4       tER3 tF]Pr                  P                  R4R5 R63R7 R63R8 R63.4      R9 4       tGR# );    N)datedatetime)Decimal)
open_csvread_csvReadOptionsParseOptionsConvertOptionsISO8601	write_csvWriteOptions	CSVWriter
InvalidRow)utilc               #   ~   "   \         P                  p T  R j  xL
  V  F  pV  F  pW,           x  K  	  K  	  R #  L"5iN)stringascii_lowercase)lettersfirstseconds      P/data/cameron/venvs/s3viz/lib/python3.14/site-packages/pyarrow/tests/test_csv.pygenerate_col_namesr   /   s:     $$GF.    s   =;#=c              #   Z   "   \        ^ W!,          V4       F  pWW1,            x  K  	  R# 5ir   Nrangearrnum_colsnum_rowsis   &&& r   
split_rowsr#   8   s(     1h)84AL!! 5s   )+c              #   N   "   \        ^ V4       F  pWRV1,          x  K  	  R# 5ir   r   r   s   &&& r   split_columnsr%   >   s%     1h+X+  s   #%c           	      8   \         P                  ! ^*4      p\        W,          4       Uu. uF  qTP                  ^ R4      NK  	  pp\        P
                  ! 4       p\        \        P                  ! \        4       V 4      4      pV'       d2   VP                  RP                  V4      4       VP                  V4       \        W`V4       FB  p	VP                  RP                  \        \        V	4      4      4       VP                  V4       KD  	  VP                  4       P!                  4       p\#        W`V4       U	u. uF.  p	\$        P&                  ! V	\$        P(                  ! 4       R7      NK0  	  p
p	\$        P*                  P-                  W4      pW{3# u upi u up	i )*     ,)type)randomRandomr   randintioStringIOlist	itertoolsislicer   writejoinr#   mapstrgetvalueencoder%   paarrayint64Tablefrom_arrays)r    r!   linesepwrite_namesrnd_r   csv	col_namesrowcolumnsexpecteds   &&&&        r   make_random_csvrG   D   s1   
--
C).x/B)C
D)CA;;q$)CC
D
++-CY%%&8&:HEFI		#((9%&		'#2		#((3sC=)*		' 3 ,,.


!C'x@B@3 xx"((*-@  Bxx##G7H= EBs   F:4Fc                     \         P                  ! 4       pVP                  R P                  V 4      4       VP                  R4       VP	                  4       P                  4       # )r)   
)r.   r/   r3   r4   r7   r8   )column_namesrB   s   & r   make_empty_csvrK   V   sB    
++-CIIchh|$%IIdO<<>  ""    c                8   V ! 4       pVP                  4        FV  w  r4\        W#4      V^ ,          8X  g   Q RV,           4       hV F&  p\        W#V4       \        W#4      V8X  d   K!  Q R4       h	  KX  	  \        P                  ! \
        4      ;_uu_ 4        RVn        RRR4       VP                  4        UUu/ uF  w  r4W4^,          bK  	  pppV ! R/ VB pVP                  4        F  w  r7\        W#4      V8X  d   K  Q h	  R#   + '       g   i     Lo; iu uppi )z<
Check setting and getting attributes of an *Options class.
zincorrect default value for zfailed setting valueTN )itemsgetattrsetattrpytestraisesAttributeErrorzzz_non_existent)clsattr_valuesoptsnamevaluesvnon_defaultsvalues   &,      r   check_options_classr^   ]   s     5D#))+t"fQi/ 	2*T1	2/AD"4&!+C-CC+  , 
~	&	& $ 
' 9D8I8I8KL8KD)O8KLLD#))+t"e+++ , 
'	& Ms   D7DD	c                     V ! R/ VB pVP                  VP                  VVP                  R 7      4      pVP                  4        F  w  rV\	        WE4      V8X  d   K  Q h	  R# ))protocolNrN   )loadsdumpsHIGHEST_PROTOCOLrO   rP   )rV   picklerrW   rX   new_optsrY   r]   s   &&,    r   check_options_class_picklingrf   u   sb    D}}W]]44;4L4L + N OH"((*x&%/// +rL   c                   8   a  ] tR t^}t o R tR tR tR tRtV t	R# )InvalidRowHandlerc                     Wn         . V n        R # r   resultrows)selfrk   s   &&r   __init__InvalidRowHandler.__init__~   s    	rL   c                P    V P                   P                  V4       V P                  # r   )rl   appendrk   )rm   rD   s   &&r   __call__InvalidRowHandler.__call__   s    		{{rL   c                d    \        V\        4      ;'       d    VP                  V P                  8H  # r   
isinstancerh   rk   rm   others   &&r   __eq__InvalidRowHandler.__eq__   s,    5"34 , ,+	-rL   c                n    \        V\        4      '       * ;'       g    VP                  V P                  8g  # r   ru   rw   s   &&r   __ne__InvalidRowHandler.__ne__   s/    u&788 , ,+	-rL   rj   N)
__name__
__module____qualname____firstlineno__rn   rr   ry   r|   __static_attributes____classdictcell____classdict__s   @r   rh   rh   }   s     -- -rL   rh   c                      ^p ^p\        ^^4       Uu. uF  q"NK  	  pp\        \        W0V4      4      pV. RO. RO.8X  g   Q h\        \        W0V4      4      pV^^.^^.^^.^^	.^^
..8X  g   Q hR# u upi )   N)            r   )         	   
   )r   r0   r#   r%   )r    r!   xr   rl   rE   s         r   #test_split_rows_and_columns_utilityr      s    HHArl
#l1lC
#
3(34D    =9:G	
A	
A	
A	
A	
B    $s   
A2c                    \         pV! 4       p\        VR R.^ ^.. RR..RR .RR.^ ^.R7       \        WR ^RR.RR^R7       VP                  ^ 8  g   Q hRVn        VP                  R8X  g   Q hV! R	R
7      pVP                  R	8X  g   Q hVP	                  4        Rp\
        P                  ! \        P                  VR7      ;_uu_ 4        V! 4       p^ Vn        VP	                  4        RRR4       Rp\
        P                  ! \        P                  VR7      ;_uu_ 4        V! 4       pRVn	        VP	                  4        RRR4       Rp\
        P                  ! \        P                  VR7      ;_uu_ 4        V! 4       pRVn
        VP	                  4        RRR4       Rp\
        P                  ! \        P                  VR7      ;_uu_ 4        V! 4       pR Vn        RVn        VP	                  4        RRR4       Rp\        V4      RV R28X  g   Q h\        V4      RV R28X  g   Q hR#   + '       g   i     ELM; i  + '       g   i     EL
; i  + '       g   i     L; i  + '       g   i     L{; i)TFabcdutf8utf16)use_threads	skip_rowsrJ   autogenerate_column_namesencodingskip_rows_after_names)rd   r   r   rJ   r   r   r   90  i  
block_sizez-ReadOptions: block_size must be at least 1: 0matchNz-ReadOptions: skip_rows cannot be negative: -1z9ReadOptions: skip_rows_after_names cannot be negative: -1zTReadOptions: autogenerate_column_names cannot be true when column_names are providedz
    use_threads=True,
    block_size=1048576,
    skip_rows=0,
    skip_rows_after_names=0,
    column_names=['a', 'b'],
    autogenerate_column_names=True,
    encoding='utf8'z<pyarrow.csv.ReadOptions>()zReadOptions()ab)r   r^   rf   r   validaterR   rS   r9   ArrowInvalidr   r   r   rJ   reprr6   )pickle_modulerV   rX   r   expected_repr_inners   &    r   test_read_optionsr      s   
C5D$#$a&&(4,%738$-"('!2/0"g7 !-1+,/3Tl;@*179; ??QDO??e###$D??d"""MMO;E	re	4	4u 
5
 <E	re	4	4u 
5
 HE	re	4	4u%'" 
5
)E	re	4	4u)-&&	 
5 :56I5J!LLLLt9,':&;1====G 
5	4	4 
5	4	4 
5	4 
5	4s0   H."I9I&I).H?	I	I&	)I9	c                 F   \         p\        R 4      p\        VRR.RR.. RORR.RR.RR.RV.R7       \        WRRRRRRVR7	       V! 4       P	                  4        V! 4       pR	Vn        VP	                  4        R
p\        P                  ! \        P                  VR7      ;_uu_ 4        V! 4       pRVn        VP	                  4        RRR4       \        P                  ! \        P                  VR7      ;_uu_ 4        V! 4       pRVn        VP	                  4        RRR4       Rp\        P                  ! \        P                  VR7      ;_uu_ 4        V! 4       pRVn
        VP	                  4        RRR4       \        P                  ! \        P                  VR7      ;_uu_ 4        V! 4       pRVn
        VP	                  4        RRR4       Rp\        P                  ! \        P                  VR7      ;_uu_ 4        V! 4       pRVn        VP	                  4        RRR4       \        P                  ! \        P                  VR7      ;_uu_ 4        V! 4       pRVn        VP	                  4        RRR4       Rp\        V4      RV R28X  g   Q h\        V4      RV R28X  g   Q hR#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELj; i  + '       g   i     EL); i  + '       g   i     L; i  + '       g   i     L; i)skipr)   r   FyTN)	delimiterescape_char
quote_chardouble_quotenewlines_in_valuesignore_empty_linesinvalid_row_handler)rd   r   r   r   r   r   r   r   	z,ParseOptions: delimiter cannot be \\r or \\nr   rI   z-ParseOptions: quote_char cannot be \\r or \\nz.ParseOptions: escape_char cannot be \\r or \\nz
    delimiter=',',
    quote_char='"',
    double_quote=True,
    escape_char='\r',
    newlines_in_values=False,
    ignore_empty_lines=True,
    invalid_row_handler=Nonez<pyarrow.csv.ParseOptions>(r   zParseOptions()"zF)r	   rh   r^   rf   r   r   rR   rS   r9   r   r   r   r   r6   )r   rV   skip_handlerrX   r   r   s   &     r   test_parse_optionsr      s[   
C$V,LSz%*CL#4&*E],14=,0%=-1<,@B !+.-0,1.348495AC ENN5DDNMMO>E	re	4	4u 
5
 
re	4	4u 
5
 @E	re	4	4u 
5
 
re	4	4u 
5
 AE	re	4	4u 
5
 
re	4	4u 
5
  :67J6K1MMMMt9-(;'<A>>>>U 
5	4	4
 
5	4	4 
5	4	4
 
5	4	4 
5	4
 
5	4sH   )J->KK*K)K=L-J>	K	K&	)K:	=L	L 	c                 	   \         pV! 4       p\        VR R.RR .R R.RR.. RR..RR .RR .. \        R..R7	       \        WRR RRRR.RR \        R.R7
       \        P
                  ! \        4      ;_uu_ 4        R	Vn        R
R
R
4       VP                  ^ 8  g   Q hRVn        VP                  R8X  g   Q hVP                  / 8X  g   Q hR\        P                  ! 4       R\        P                  ! 4       /Vn	        VP                  R\        P                  ! 4       R\        P                  ! 4       /8X  g   Q hRRRR/Vn	        VP                  R\        P                  ! 4       R\        P                  ! 4       /8X  g   Q h\        P                  ! R\        P                  ! 4       3R\        P                   ! 4       3.4      pW2n	        VP                  R\        P                  ! 4       R\        P                   ! 4       /8X  g   Q hR\        P"                  ! 4       3.Vn	        VP                  R\        P"                  ! 4       /8X  g   Q h\        P
                  ! \$        RR7      ;_uu_ 4        RR
/Vn	        R
R
R
4       \        P
                  ! \$        4      ;_uu_ 4        ^ Vn	        R
R
R
4       \'        VP(                  \*        4      '       g   Q hRVP(                  9   g   Q hRVP(                  9   g   Q hRR.Vn        VP(                  RR.8X  g   Q h\'        VP,                  \*        4      '       g   Q hRR.Vn        VP,                  RR.8X  g   Q h\'        VP.                  \*        4      '       g   Q hRR.Vn        VP.                  RR.8X  g   Q hVP0                  . 8X  g   Q h\        .Vn        VP0                  \        .8X  g   Q hV! R\        P                  ! 4       /RR.RR.RR.R \        R!.R"7      pVP                  R\        P                  ! 4       /8X  g   Q hVP(                  RR.8X  g   Q hVP.                  RR.8X  g   Q hVP,                  RR.8X  g   Q hVP                  R 8X  g   Q hVP0                  \        R!.8X  g   Q hR#p\3        V4      R$V R%28X  g   Q h\5        V4      R&V R%28X  g   Q hR
#   + '       g   i     ELH; i  + '       g   i     ELf; i  + '       g   i     ELH; i)'TF.r)   defabcz%y-%m)
check_utf8strings_can_be_nullquoted_strings_can_be_nulldecimal_pointinclude_columnsinclude_missing_columnsauto_dict_encodetimestamp_parsers)	rd   r   r   r   r   r   r   r   r   z..N韆 r   cr[   int16wnullr   r   zDataType expectedr    N/AxxxyyyNnnTttFffi  z%Y-%m-%d)column_typesnull_valuestrue_valuesfalse_valuesauto_dict_max_cardinalityr   a  
    check_utf8=True,
    column_types={'a': DataType(null)},
    null_values=['N', 'nn'],
    true_values=['T', 'tt'],
    false_values=['F', 'ff'],
    decimal_point='.',
    strings_can_be_null=False,
    quoted_strings_can_be_null=True,
    include_columns=[],
    include_missing_columns=False,
    auto_dict_encode=False,
    auto_dict_max_cardinality=999,
    timestamp_parsers=['ISO8601', '%Y-%m-%d']z<pyarrow.csv.ConvertOptions>(r   zConvertOptions()r
   r^   r   rf   rR   rS   
ValueErrorr   r   r   r9   r   float32r   schemaint32r   binary	TypeErrorrv   r   r0   r   r   r   r   r6   )r   rV   rX   r   r   s   &    r   test_convert_optionsr   -  s   
C5Du"DM$(%=CjeU^,!&124 ! #( %"G,	. 
z	"	"! 
# ))A---%*D"))U222"""bhhj#rzz|<Dbhhj#rzz| DDDDgsF3Dbhhj#rwwy AAAAYYbhhj)C+=>?Fbhhj#ryy{ CCCCryy{+,Dbiik 2222	y(;	<	< $K 
=	y	!	! 
" d&&----!!!!!D$$$$$u~Du~---d&&----u~Du~---d''....D...!!R'''%YD!!gY...S"''),;S$K $K3"):!68D bggi 0000T{***d+++T{***))S000!!gz%::::1 :89L8MQOOOOt9/*=)>a@@@@M 
#	"	"* 
=	<	<	!	!	!s$   8R?,
S S'?S	S$	'S8	c                  ,   \         p V ! 4       p\        V R R.. RO. ROR7       VP                  ^ 8  g   Q hRVn        VP                  R8X  g   Q hV ! RR7      pVP                  R8X  g   Q hVP                  4        Rp\        P
                  ! \        P                  VR7      ;_uu_ 4        V ! 4       p^ Vn        VP                  4        RRR4       R	p\        V4      R
V R28X  g   Q h\        V4      RV R28X  g   Q hR#   + '       g   i     L@; i)TF)include_headerr   quoting_styler   i&  )
batch_sizez.WriteOptions: batch_size must be at least 1: 0r   NzY
    include_header=True,
    batch_size=0,
    delimiter=',',
    quoting_style='needed'z<pyarrow.csv.WriteOptions>(r   zWriteOptions()r)   r   |)needednone	all_valid)
r   r^   r   r   rR   rS   r9   r   r   r6   )rV   rX   r   r   s       r   test_write_optionsr     s    
C5DT5M5E57 ??QDO??e###$D??d"""MMO<E	re	4	4u 
5
 :67J6K1MMMMt9-(;'<A>>>> 
5	4s   ,DD	c                      a  ] tR tRt o Rt]P                  R 4       t]]P                  R 4       4       t	]
R 4       tR tR t]P                  P                   R 4       tR	 tR
 tRtV tR# )BaseTestCSVi  zDCommon tests which are shared by streaming and non streaming readersc                    \         h)zz
:param b: bytes to be parsed
:param kwargs: arguments passed on to open the csv file
:return: b parsed as a single Table
NotImplementedErrorrm   r   kwargss   &&,r   
read_bytesBaseTestCSV.read_bytes  s
     "!rL   c                    \         h)z#Whether this test is multi-threadedr   rm   s   &r   r   BaseTestCSV.use_threads  s
     "!rL   c                d    V P                   \        V4      8X  g   Q hV P                  V8X  g   Q hR # r   )num_columnslenrJ   )tablenamess   &&r   check_namesBaseTestCSV.check_names  s.      CJ...!!U***rL   c                B   R p\        4       p^Vn        V P                  WR7      pV P                  VRR.4       VP	                  4       RRR.RRR./8X  g   Q h^Vn        V P                  WR7      pV P                  VRR.4       VP	                  4       R. R. /8X  g   Q h^Vn        \
        P                  ! \        P                  4      ;_uu_ 4        V P                  WR7      pRRR4       R	p^Vn        V P                  WR7      pV P                  VRR.4       VP	                  4       RR.RR./8X  g   Q h^Vn        RR.Vn	        V P                  WR7      pV P                  VRR.4       VP	                  4       R. R. /8X  g   Q hR#   + '       g   i     L; i)
   ab,cd
ef,gh
ij,kl
mn,op
read_optionsefghijmnklopN   abcd
,,,,,
ij,kl
mn,op
)
r   r   r   r   	to_pydictrR   rS   r9   r   rJ   rm   rl   rX   r   s   &   r   test_header_skip_rows!BaseTestCSV.test_header_skip_rows  s   .}8t- 4,4,%
 
 	
 

 8t- ""%
 
 	
 

 ]]2??++OODO<E ,
 .8t- 4&4&%
 
 	
 
 !4L8t- ""%
 
 	
 
' ,+s   FF	c                   R p\        4       p^Vn        V P                  WR7      pV P                  VRR.4       VP	                  4       RRR.RRR./8X  g   Q h^Vn        V P                  WR7      pV P                  VRR.4       VP	                  4       R. R. /8X  g   Q h^Vn        V P                  WR7      pV P                  VRR.4       VP	                  4       R. R. /8X  g   Q hRp^Vn        R	R
.Vn        V P                  WR7      pV P                  VR	R
.4       VP	                  4       R	RR.R
RR./8X  g   Q h\        4       pRp^Vn        \        4       pRVn        V P                  WVR7      pV P                  VRR.4       VP	                  4       RR.RR./8X  g   Q h^Vn        ^Vn        V P                  WVR7      pV P                  VRR.4       VP	                  4       RR.RR./8X  g   Q h\        4       p\        ^RR7      w  rRVn        \        V4      ^,          Vn        V P                  WR7      pVP                  VP                  8X  g   Q hVP                  ^d8X  g   Q hVP	                  4       pVP	                  4       P                  4        F  w  rxVR,          Wg,          8X  d   K  Q h	  V P                  WVR7      pVP                  VP                  8X  g   Q hVP                  ^d8X  g   Q hVP	                  4       pVP	                  4       P                  4        F  w  rxVR,          Wg,          8X  d   K  Q h	  \        ^^RR7      w  r\        4       p^%Vn        ^)Vn        VP                  P                  Vn        V P                  WVR7      pVP                  VP                  8X  g   Q hVP                  VP                  VP                  ,
          VP                  ,
          8X  g   Q hVP	                  4       pVP	                  4       P                  4        F1  w  rxWP                  VP                  ,           R Wg,          8X  d   K1  Q h	  R# )r   r  r   r   r  r  r  r  r	  f0f1s#   ab,cd
"e
f","g

h"
"ij","k
l"
mn,opTr  parse_optionsr(   r    r!   i  :i  NNF)r    r!   r?   N)r   r   r   r   r
  rJ   r	   r   r   rG   r   r   r!   rO   r   r   )	rm   rl   rX   r   
parse_optsrF   
table_dictrY   rZ   s	   &        r   test_skip_rows_after_names&BaseTestCSV.test_skip_rows_after_names  s   .}%&"8t- 4,4,%
 
 	
 
 &'"8t- ""%
 
 	
 
 &'"8t- ""%
 
 	
 
 .%&"!4L8t- 4,4,%
 
 	
 
 } =%&"!^
(,
%.8   :t- 4&4&%
 
 	
 
 &'".8   :t- 4&4&%
 
 	
 
 } )!dC%("d)b.8||x...~~$$$__&
$..0668LD$<:#3333 9 .8   :||x...~~$$$__&
$..0668LD$<:#3333 9 )!c5:<}%'"$OO11.8   :||x...!!DNN2**++ 	, + __&
$..0668LD>>D,F,FFGH$% & % 9rL   c                
  a  V 3R  lp\        ^^dRR7      w  r#\        4       p\        V4      ^,          Vn        \	        4       pR\
        P                  ! 4       /Vn        VR,           pV! R^f4      p\        P                  ! \
        P                  VR7      ;_uu_ 4        S P                  VVVR7       RRR4       VR	,           pV! R
^fV4      p	\        P                  ! \
        P                  V	R7      ;_uu_ 4        S P                  VVVR7       RRR4       Rp
W*,           pV! R^fV
R,          P                  R4      4      p\        P                  ! \
        P                  VR7      ;_uu_ 4        S P                  VVVR7       RRR4       ^/Vn        \        P                  ! \
        P                  VR7      ;_uu_ 4        S P                  VVVR7       RRR4       \        P                  ! \
        P                  V	R7      ;_uu_ 4        S P                  VVVR7       RRR4       \        P                  ! \
        P                  VR7      ;_uu_ 4        S P                  VVVR7       RRR4       ^ Vn        \        ^^dRR7      w  r#. ROVn        VR,           pV! R^e4      p\        P                  ! \
        P                  VR7      ;_uu_ 4        S P                  VVVR7       RRR4       W*,           pV! R^eV
R,          P                  R4      4      p\        P                  ! \
        P                  VR7      ;_uu_ 4        S P                  VVVR7       RRR4       VR	,           pV! R
^e4      p	V	P                  \        V4      4      p	\        P                  ! \
        P                  V	R7      ;_uu_ 4        S P                  VVVR7       RRR4       ^Vn        \        P                  ! \
        P                  VR7      ;_uu_ 4        S P                  VVVR7       RRR4       \        P                  ! \
        P                  V	R7      ;_uu_ 4        S P                  VVVR7       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL'; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL{; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELP; i  + '       g   i     EL; i  + '       g   i     R# ; i)c                 b   < SP                   '       d   R pMRV R2pV P                  ! V.VO5!  # )r   zRow #z: )r   format)
msg_formatrD   argsrow_inform   s   &&* r   
format_msg@BaseTestCSV.test_row_number_offset_in_errors.<locals>.format_msg`  s7    "3%r?$$X555rL   T)r?   r   s   1,2
z{}Expected 4 columns, got 2r   r  convert_optionsNs	   a,b,c,d
zDIn CSV column #0: {}CSV conversion error to int32: invalid value 'a'z#{}Expected 4 columns, got 2: {} ...:r   `   Nzutf-8Fs  this is a long rowthis is a long rowthis is a long rowthis is a long rowthis is a long rowthis is a long rowthis is a long rowthis is a long rowthis is a long rowthis is a long rowthis is a long rowthis is a long rowthis is a long rowthis is a long rowthis is a long row,3
)r   r   r   d)rG   r   r   r   r
   r9   r   r   rR   rS   r   r   decoder   rJ   r  r   )rm   r  rB   rA   r  r!  csv_bad_columnsmessage_columnscsv_bad_typemessage_valuelong_rowcsv_bad_columns_longmessage_longs   f            r    test_row_number_offset_in_errors,BaseTestCSV.test_row_number_offset_in_errors]  s?   	6 !CT:"}"%c(Q,(*(+RXXZ'8$ 
*$%BCH]]2??/BBOOO)5,;  = C
 ^+"? ]]2??-@@OOL)5,;  = A
 <"~!"G"*4."7"7"@B]]2??,??OO0)5,;  = @ .0*]]2??/BBOOO)5,;  = C
 ]]2??-@@OOL)5,;  = A
 ]]2??,??OO0)5,;  = @
 ./* !CU;$8!
*$%BCH]]2??/BBOOO)5,;  = C
  #~!"G"*4."7"7"@B]]2??,??OO0)5,;  = @
 ^+"? &,,SX6]]2??-@@OOL)5,;  = A "$]]2??/BBOOO)5,;  = C
 ]]2??-@@OOL)5,;  = A@a CBB A@@ @?? CBB
 A@@
 @?? CBB @?? A@@ CBB
 A@@s   Q==R2R%R9SS!S5
T	TT1U=R	R"	%R6	9S
	S	!S2	5T		T	T.	1U	U	c                  a  R p\        4       p\        P                  ! \        RR7      ;_uu_ 4        S P	                  W#R7       RRR4       \        R4      Vn        S P	                  W#R7      pVP                  4       RRR.R	R
R./8X  g   Q hV 3R lp\        ^^V! ^4      R4      \        ^^V! ^4      R4      .pVP                  P                  V8X  g   Q h\        R4      Vn        \        P                  ! \        RR7      ;_uu_ 4        S P	                  W#R7       RRR4       \        ^^V! ^4      R4      .pVP                  P                  V8X  g   Q h\        R4      Vn        VP                  VP                  V4      4      pS P	                  W#R7      pVP                  4       RRR.R	R
R./8X  g   Q hR#   + '       g   i     EL; i  + '       g   i     L; i)s   a,b
c
d,e
f,g,h
i,j
zExpected 2 columns, got 1: cr   r  Nr   r   r#  r"   r   ejc                 0   < SP                   '       d   R # T # r   )r   )r   rm   s   &r   row_num5BaseTestCSV.test_invalid_row_handler.<locals>.row_num  s    +++422rL   r   zf,g,herror)r	   rR   rS   r   r   rh   r   r
  r   rl   ra   rb   )rm   r   rl   r  r   r3  expected_rowss   f&     r   test_invalid_row_handler$BaseTestCSV.test_invalid_row_handler  s   +!^
]]46 6 OODO;6 *;6)B
&? #s#s%
 
 	
 

	3 q!WQZ-q!WQZ1
 --22mCCC *;7)C
&]]46 6 OODO;6 $Aq'!*c:;--22mCCC *;6)B
&"(()<)<Z)HI
? #s#s%
 
 	
 
G6 6 6.6 6s   F=G=G	G!	c           
        R pRRR.RRR.RRR	./p\        ^^4       FA  pV P                  V\        R
R7      \        VR7      R7      P	                  4       pWB8X  d   KA  Q h	  \        ^^4       FM  p\
        P                  ! \        RR7      ;_uu_ 4        V P                  V\        VR7      R7       RRR4       KO  	  R#   + '       g   i     Kd  ; i)s   a,b,c
d,e,"f
"
g,h,i
r   r#  gr   r0  hr   zf
r"   T)r   r   r  r  z#cell values spanning multiple linesr   r  N)r   r   r	   r   r
  rR   rS   r   )rm   rl   rF   r   r#  s   &    r   test_chunker_out_of_sync$BaseTestCSV.test_chunker_out_of_sync  s     0#s#s%

  2,JLD$I(J?   AAJ  = = '  2,Jz%JL L{j'I   KL L 'L L Ls   CCrN   N)r~   r   r   r   __doc__r   abstractmethodr   propertyr   staticmethodr   r  r  rR   marknumpyr,  r7  r=  r   r   r   s   @r   r   r     s     N" " "  " + ++
Zg&R [[f= f=P)
VK KrL   r   c                   X  a  ] tR tRt o RR/R ltR tR tR tR tR	 t	R
 t
R tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR  t R! t!R" t"R# t#]$PJ                  PL                  R$ 4       t']$PJ                  PL                  R% 4       t(R&t)V t*R'# )(BaseCSVTableReadi  validate_fullTc                   \        V P                  \        4      '       g   Q hVP                  R\	        4       4      pV P                  Vn        \        V.VO5/ VB pVP                  VR7       V# )a  
Reads the CSV file into memory using pyarrow's read_csv
csv The CSV bytes
args Positional arguments to be forwarded to pyarrow's read_csv
validate_full Whether or not to fully validate the resulting table
kwargs Keyword arguments to be forwarded to pyarrow's read_csv
r  full)rv   r   bool
setdefaultr   r   r   )rm   rB   rG  r  r   r  r   s   &&$*,  r   r   BaseCSVTableRead.read_csv  sf     $**D1111((G#'#3#3 .t.v.M*rL   c                P    V P                   ! \        P                  ! V4      3/ VB # r   )r   r9   	py_bufferr   s   &&,r   r   BaseCSVTableRead.read_bytes      }}R\\!_777rL   c                ~   R pR^.R^./p\         P                  ! V4      pV P                  V4      pVP                  4       V8X  g   Q h\         P                  ! VP                  4       4      p\        P                  ! \        4      ;_uu_ 4        V P                  V4       RRR4       R#   + '       g   i     R# ; i)s   a,b
1,2
r   r   N)	r.   BytesIOr   r
  r/   r$  rR   rS   r   )rm   dataexpected_databior   sios   &     r   test_file_object!BaseCSVTableRead.test_file_object  s    qc3,jjc" M111kk$++-(]]9%%MM# &%%%s   B++B<	c                    R pV P                  V4      p\        V\        P                  4      '       g   Q hV P	                  V. RO4       VP
                  ^ 8X  g   Q hR# )   abc,def,gh
N)r   r   r  )r   rv   r9   r<   r   r!   rm   rl   r   s   &  r   test_headerBaseCSVTableRead.test_header*  sO    %%**** 45~~"""rL   c                j    R pR^.R^./pV P                  V4      pVP                  4       V8X  g   Q hR# )s   ﻿a,b
1,2
r   r   Nr   r
  )rm   rl   rU  r   s   &   r   test_bomBaseCSVTableRead.test_bom1  s<    (qc3,% M111rL   c                   . ROpR Fv  pRV3 Fk  pVP                  V4      V,           pV P                  V4      p\        VP                  4       4      ^8X  g   Q hVP	                  4       R. ROR. RO/8X  d   Kk  Q h	  Kx  	  R# )	   a,brL   r   r   N)rd  s   1,2s   3,4s   56,78)   
      
)r   r   8   )r   r   N   )r4   r   r   
to_batchesr
  )rm   rl   line_endingfile_endingrT  r   s   &     r   test_one_chunkBaseCSVTableRead.test_one_chunk7  s     22K #[1"''-;-5++-.!333(-   	  2 3rL   c                &   R p\        4       pRR.Vn        V P                  WR7      pV P                  VRR.4       VP	                  4       R. ROR. RO/8X  g   Q h^Vn        V P                  WR7      pV P                  VRR.4       VP	                  4       RR.RR./8X  g   Q h^Vn        V P                  WR7      pV P                  VRR.4       VP	                  4       R. R. /8X  g   Q h^Vn        \        P                  ! \        P                  4      ;_uu_ 4        V P                  WR7      pRRR4       ^ Vn        . ROVn        \        P                  ! \        P                  R	R
7      ;_uu_ 4        V P                  WR7      pRRR4       Rp^Vn        RR.Vn        V P                  WR7      pV P                  VRR.4       VP	                  4       RRR.RRR./8X  g   Q hR#   + '       g   i     L; i  + '       g   i     L|; i)r   r   r   r  r  r  r  r  NExpected 3 columns, got 2r   r	  r   r  r  r  r   r  r  r  )r   r   r   )
r   rJ   r   r   r
  r   rR   rS   r9   r   r  s   &   r   test_header_column_names)BaseCSVTableRead.test_header_column_namesE  s	   .} #J8c
+ ))%
 
 	
 

 8c
+ $$%
 
 	
 

 8c
+ %
 
 	
 

 ]]2??++OODO<E ,
 +]]2??!<> >OODO<E>
 . #J8c
+ $$%
 
 	
 
# ,+> >s    G-9H -G=	 H	c                   R p\        4       pRVn        V P                  WR7      pV P                  VRR.4       VP	                  4       R. ROR. R	O/8X  g   Q h^Vn        V P                  WR7      pV P                  VRR.4       VP	                  4       RR.RR./8X  g   Q h^Vn        \        P                  ! \        P                  4      ;_uu_ 4        V P                  WR7      pRRR4       R#   + '       g   i     R# ; i)
r   Tr  r  r  r  r  Nrq  rr  )
r   r   r   r   r
  r   rR   rS   r9   r   r  s   &   r   %test_header_autogenerate_column_names6BaseCSVTableRead.test_header_autogenerate_column_namesx  s    .})-&8t- **%
 
 	
 

 8t- 4&4&%
 
 	
 
 ]]2??++OODO<E ,+++s   C33D	c                   R p\        4       pR.Vn        V P                  WR7      pV P                  VR.4       VP	                  4       R. RO/8X  g   Q hRR.Vn        V P                  WR7      p\
        P                  ! R\
        P                  ! 4       3R\
        P                  ! 4       3.4      pVP                  V8X  g   Q hVP	                  4       R. ROR. RO/8X  g   Q h. R	OVn        \        P                  ! \        RR7      ;_uu_ 4        V P                  WR7       RRR4       R#   + '       g   i     R# ; i)
r   r   r!  r   z9Column 'xx' in include_columns does not exist in CSV filer   Nr  r  r  r  r  r  xxr   yy)r
   r   r   r   r
  r9   r   r   rR   rS   KeyError)rm   rl   r!  r   r   s   &    r   test_include_columns%BaseCSVTableRead.test_include_columns  s.   .(*+/&'F' $%
 
 	
 

 ,0,'FT299;/!299;/1 2||v%%% $$%
 
 	
 
 +=']]8">? ? OODOB? ? ? ?s   D..D?	c                6   R p\        4       p\        4       p. ROVn        RVn        V P	                  WVR7      p\
        P                  ! R\
        P                  ! 4       3R\
        P                  ! 4       3R\
        P                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       R. R	OR. R
OR. R	O/8X  g   Q hRR.Vn
        RR.Vn        V P	                  WVR7      p\
        P                  ! R\
        P                  ! 4       3R\
        P                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       R. ROR. RO/8X  g   Q hR\
        P                  ! 4       R\
        P                  ! 4       /Vn        V P	                  WVR7      p\
        P                  ! R\
        P                  ! 4       3R\
        P                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       R. ROR. RO/8X  g   Q hR# )r   r}  r   r~  Tr   Nr   r|  NNNrz  rr  )NNNN)s   cds   ghs   kls   op)r   r
   r   r   r   r9   r   r   r   r
  rJ   r   r   r   rm   rl   r  r!  r   r   s   &     r   test_include_missing_columns-BaseCSVTableRead.test_include_missing_columns  s   ."}(**<'26/0?   AT2779-!299;/!2779-/ 0 ||v%%% $$$%
 
 	
 
 &*4L!+/,'0?   AT299;/!2779-/ 0||v%%% **%
 
 	
 
 )-biik(,bhhj(:$0?   AT299;/!288:.0 1||v%%% .*%
 
 	
 
rL   c                H   R pV P                  V4      p\        P                  ! R\        P                  ! 4       3R\        P                  ! 4       3R\        P                  ! 4       3.4      pVP                  V8X  g   Q hVP	                  4       R^^.R^^.R^^./8X  g   Q hR# )s   a,b,c
1,2,3
4,5,6
r   r   r   N)r   r9   r   r;   r
  rm   rl   r   r   s   &   r   test_simple_ints!BaseCSVTableRead.test_simple_ints  s    '%S"((*- "((*- "((*-/ 0 ||v%%% !Q!Q!Q%
 
 	
 
rL   c           
     |   R pV P                  V4      p\        P                  ! R\        P                  ! 4       3R\        P                  ! 4       3R\        P
                  ! 4       3R\        P                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       RRR.R^R.RRR.RR	R
./8X  g   Q hR# )s    a,b,c,d
1,2,3,0
4.0,-5,foo,True
r   r   r   r#        ?g      @3fooFTN)r   r9   r   float64r;   r   bool_r
  r  s   &   r   test_simple_varied#BaseCSVTableRead.test_simple_varied  s    5%S"**,/ "((*- "))+. "((*-/ 0 ||v%%% #s!R#u%	%
 
 	
 
rL   c                   R pV P                  V4      p\        P                  ! R\        P                  ! 4       3R\        P                  ! 4       3R\        P
                  ! 4       3R\        P                  ! 4       3R\        P                  ! 4       3R\        P                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       R. ROR. R	OR. R
OR. ROR. ROR. RO/8X  g   Q hR# )sC   a,b,c,d,e,f
1,2,,,3,N/A
nan,-5,foo,,nan,TRUE
4.5,#N/A,nan,,,false
r   r   r   r#  r0  fN)r  Ng      @)r   r  N)r   r  nanr  )   3s   nan   )NTF)
r   r9   r   r  r;   r   r   r   r  r
  r  s   &   r   test_simple_nulls"BaseCSVTableRead.test_simple_nulls  s    . %S"**,/ "((*- "))+. "''), "))+. "((*-/ 0 ||v%%% !##($%
 
 	
 
rL   c                T   \        R R7      pRpV P                  W!R7      p\        P                  ! R\        P                  ! 4       3R\        P
                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       R. R
OR. RO/8X  g   Q h\        RR7      pV P                  W!VR	7      p\        P                  ! R\        P
                  ! 4       3R\        P                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       R. ROR. RO/8X  g   Q hR# );r   s   a;b
1.25;2,5
NA;-3
-4;NAr/  r   r   Nr)   )r   )r  r!  )g      ?Ng      )z2,5z-3NA)z1.25r  z-4)g      @g      N)r	   r   r9   r   r  r   r
  r
   )rm   r  rl   r   r   r!  s   &     r   test_decimal_point#BaseCSVTableRead.test_decimal_point  s   $s3-BS"**,/ "))+.0 1||v%%% #$%
 
 	
 

 )s;0?   AS"))+. "**,/1 2||v%%% %"%
 
 	
 
rL   c                   R pV P                  V4      p\        P                  ! R\        P                  ! 4       3R\        P                  ! R4      3R\        P                  ! R4      3.4      pVP                  V8X  g   Q hVP                  4       RRR.R\        R^^4      \        R^^^4      .R\        R^^^ ^ ^ R4      \        R^^^^ ^ R	4      ./8X  g   Q hR
# )sk   a,b,c
1970,1970-01-01 00:00:00,1970-01-01 00:00:00.123
1989,1989-07-14 01:00:00,1989-07-14 01:00:00.123456
r   r   sr   ns  i  ix @ N)r   r9   r   r;   	timestampr
  r   r  s   &   r   test_simple_timestamps'BaseCSVTableRead.test_simple_timestamps)  s    I %S"((*- ",,s"34 ",,t"457 8 ||v%%% $(4A&q"a(@A(4Aq!Q74B1a8:%
 
 	
 
rL   c           
     $   R p\        4       pV P                  WR7      p\        P                  ! R\        P                  ! 4       3R\        P
                  ! R4      3.4      pVP                  V8X  g   Q hVP                  4       RRR.R\        R^^4      \        R^^4      ./8X  g   Q hR.Vn        V P                  WR7      p\        P                  ! R\        P
                  ! R4      3R\        P                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       R\        R	^^4      \        R	^^4      .RR
R./8X  g   Q hR\        .Vn        V P                  WR7      p\        P                  ! R\        P
                  ! R4      3R\        P
                  ! R4      3.4      pVP                  V8X  g   Q hVP                  4       R\        R	^^4      \        R	^^4      .R\        R^^4      \        R^^4      ./8X  g   Q hR# )s6   a,b
1970/01/01,1980-01-01 00
1970/01/02,1980-01-02 00
ry  r   r   r  z
1970/01/01z
1970/01/02i  z%Y/%m/%dr  z1980-01-01 00z1980-01-02 00N)
r
   r   r9   r   r   r  r
  r   r   r   )rm   rl   rX   r   r   s   &    r   test_timestamp_parsers'BaseCSVTableRead.test_timestamp_parsers:  s   K;S"))+. ",,s"346 7||v%%% ,-(4A&q!(<=%
 
 	
 

 #-;S",,s"34 "))+.0 1||v%%% (4A&q!(<=/?3%
 
 	
 

 #-g!6;S",,s"34 ",,s"346 7||v%%% (4A&q!(<=(4A&q!(<=%
 
 	
 
rL   c           
     (   R pV P                  V4      p\        P                  ! R\        P                  ! 4       3R\        P                  ! 4       3.4      pVP                  V8X  g   Q hVP	                  4       R\        R^^4      \        R^^4      .R\        R^^4      \        R^^4      ./8X  g   Q h\        4       pR\        P                  ! 4       R\        P                  ! 4       /Vn        V P                  WR7      p\        P                  ! R\        P                  ! 4       3R\        P                  ! 4       3.4      pVP                  V8X  g   Q hVP	                  4       R\        R^^4      \        R^^4      .R\        R^^4      \        R^^4      ./8X  g   Q h\        4       pR\        P                  ! R4      R\        P                  ! R4      /Vn        V P                  WR7      p\        P                  ! R\        P                  ! R4      3R\        P                  ! R4      3.4      pVP                  V8X  g   Q hVP	                  4       R\        R^^4      \        R^^4      .R\        R^^4      \        R^^4      ./8X  g   Q hR# )	s0   a,b
1970-01-01,1970-01-02
1971-01-01,1971-01-02
r   r   r  i  ry  r  msN)r   r9   r   date32r
  r   r
   date64r   r  r   )rm   rl   r   r   rX   s   &    r   
test_datesBaseCSVTableRead.test_dates\  sQ   E%S"))+. "))+.0 1||v%%% $tQ"Dq!$45$tQ"Dq!$45%
 
 	
 
  "))+sBIIK@;S"))+. "))+.0 1||v%%% $tQ"Dq!$45$tQ"Dq!$45%
 
 	
 
  ",,s"3S",,t:LM;S",,s"34 ",,t"457 8||v%%% (4A&q!(<=(4A&q!(<=%
 
 	
 
rL   c                   ^ RI Hp RpV P                  V4      p\        P                  ! R\        P
                  ! R4      3R\        P                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       RV! ^^"^84      V! ^^;^;4      .RRR./8X  g   Q h\        4       pR\        P                  ! R4      R\        P
                  ! R	4      /Vn
        V P                  W%R
7      p\        P                  ! R\        P                  ! R4      3R\        P
                  ! R	4      3.4      pVP                  V8X  g   Q hVP                  4       RV! ^^"^84      V! ^^;^;4      .RV! ^^"^8R4      V! ^^;^;R4      ./8X  g   Q hR# )r   )times0   a,b
12:34:56,12:34:56.789
23:59:59,23:59:59.999
r   r  r   z12:34:56.789z23:59:59.999usr  ry  i
 iX> N)r   r  r   r9   r   time32r   r
  r
   time64r   )rm   r  rl   r   r   rX   s   &     r   
test_timesBaseCSVTableRead.test_times  sw   !E%S"))C.1 "))+.0 1||v%%% $r2r"DR$45..1%
 
 	
 
  "))D/3		$H;S"))D/2 "))D/24 5||v%%% $r2r"DR$45$r2r6*DRV,DE%
 
 	
 
rL   c                   \        R R7      pRP                  4       pV P                  W!R7      p\        P                  ! R\        P
                  ! \        P                  ! 4       \        P                  ! 4       4      3R\        P                  ! 4       3.4      pR. ROR. RO/pVP                  V8X  g   Q hVP                  4       V8X  g   Q h^Vn
        V P                  W!R7      pVP                  V8X  g   Q hVP                  4       V8X  g   Q h^Vn
        V P                  W!R7      pVP                  \        P                  ! R\        P                  ! 4       3R\        P                  ! 4       3.4      8X  g   Q hVP                  4       V8X  g   Q h^2Vn
        RVn        RpV P                  W!RR	7      pVP                  V8X  g   Q hVR,          P                  ^ 4      P
                  p\        V4      ^8X  g   Q hV^ ,          P                  4       R8X  g   Q hV^,          P                  4       R
8X  g   Q hR Vn        V P                  W!R7      p\        P                  ! R\        P
                  ! \        P                  ! 4       \        P                   ! 4       4      3R\        P                  ! 4       3.4      pR. ROR. RO/pVP                  V8X  g   Q hVP                  4       V8X  g   Q hR# )T)r   u   a,b
ab,1
cdé,2
cdé,3
ab,4ry  r   r   r   Fs   a,b
ab,1
cd,2
ab,3)r!  rG     cdN)r      cdér  r   )r   r   r   r   )   abr  r  r   r   r   )r
   r8   r   r9   r   
dictionaryr   r   r;   r
  r   r   chunkr   as_py	as_bufferr   )rm   rX   rl   r   r   rF   dict_valuess   &      r   test_auto_dict_encode&BaseCSVTableRead.test_auto_dict_encode  s   t40779;S"--
BIIK"HI "((*-/ 0 -
 ||v%%% H,,,)*&;||v%%% H,,, *+&;||ryy3		*<+.
*;*=  > > 	> > H,,, *,&+.3   5||v%%%Cj&&q)44;1$$$1~##%---1~'')Y666 ;S"--
BIIK"HI "((*-/ 0 *
 ||v%%% H,,,rL   c           
        \        R R.R7      pRpV P                  W!R7      p\        P                  ! R\        P                  ! 4       3R\        P
                  ! 4       3R\        P
                  ! 4       3R\        P                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       RR	R	.RR R
.RRR.R^R	./8X  g   Q h\        R R.RR7      pV P                  W!R7      pVP                  4       RR	R	.RR	R
.RRR.R^R	./8X  g   Q hRVn        V P                  W!R7      pVP                  4       RR	R	.RR R
.RRR.R^R	./8X  g   Q h\        . R7      pRpV P                  W!R7      p\        P                  ! R\        P
                  ! 4       3R\        P
                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       RR
.RR./8X  g   Q hR	# )XxxZzz)r   s$   a,b,c,d
Zzz,"Xxx",1,2
Xxx,#N/A,,Zzz
ry  r   r   r   r#  Nz#N/A1r   T)r   r   Fs
   a,b
#N/A,
)	r
   r   r9   r   r   r   r;   r
  r   rm   rX   rl   r   r   s   &    r   test_custom_nulls"BaseCSVTableRead.test_custom_nulls  s   5%.9=;S"''), "))+. "))+. "((*-/ 0 ||v%%% $%#r!T	%
 
 	
 
 5%.268; $$#r!T	%
 
 	
 
 +0'; $%#r!T	%
 
 	
 
 "-;S"))+. "))+.0 1||v%%% &"%
 
 	
 
rL   c                l   \        R R.RR.R7      pRpV P                  W!R7      p\        P                  ! R\        P                  ! 4       3R\        P
                  ! 4       3R	\        P                  ! 4       3.4      pVP                  V8X  g   Q hVP                  4       R. ROR. ROR	. RO/8X  g   Q hR
# )r   yesr   no)r   r   s>   a,b,c
True,T,t
False,F,f
True,yes,yes
False,no,no
N/A,N/A,N/A
ry  r   r   r   N)TrueFalser  r  r   )TFTFN)tr  r  r  r   )r
   r   r9   r   r   r  r
  r  s   &    r   test_custom_bools"BaseCSVTableRead.test_custom_bools  s    3,,/;8! ;S"))+. "((*- "))+.0 1 ||v%%% :1/%
 
 	
 
rL   c                   \        R RRRRRR\        P                  ! ^^4      RR/R	7      pR
pV P                  W!R7      p\        P                  ! R\        P
                  ! 4       3R \        P                  ! 4       3R\        P                  ! 4       3R\        P                  ! 4       3R\        P                  ! ^^4      3.4      pR^^.R RR.RRR.RRR.R\        R4      \        R4      ./pVP                  V8X  g   Q hVP                  4       V8X  g   Q h\        \        P                  ! R \        P                  ! 4       3R\        P                  ! 4       3R\        P                  ! 4       3R\        P                  ! ^^4      3R\        P                  ! 4       3.4      R	7      pV P                  W!R7      pVP                  V8X  g   Q hVP                  4       V8X  g   Q hRp\        P                  ! \        P                  4      ;_uu_ 4       pV P                  W!R7       RRR4       \        XP                  4      pRV9   g   Q hRV9   g   Q hR#   + '       g   i     L9; i)r   r   r   r   r#  booleanr0  zzr   r   s(   a,b,c,d,e
1,2,3,true,1.0
4,-5,6,false,0
ry  r          @r  6TF1.00z0.00s(   a,b,c,d,e
1,XXX,3,true,5
4,-5,6,false,7
NzIn CSV column #1: z2CSV conversion error to float: invalid value 'XXX'g      )r
   r9   
decimal128r   r   r;   r   r   r  r   r
  rR   rS   r   r6   r]   )rm   rX   rl   r   r   rF   excerrs   &       r   test_column_types"BaseCSVTableRead.test_column_types  s   C,/,/,/r11E,0&	,: ;
 >;S"((*- "**,/ "))+. "((*- "--A"67	9 : !Q#t#s$'&/76?3
 ||v%%% H,,,S"**,$7%("))+$6%("((*$5%("--A*>$?%)288:$6	$8 9: ;||v%%% H,,,=]]2??++sOODO7 ,#))n#s***CsJJJ	 ,+s   II&	c           
     |   R \         P                  ! \         P                  ! 4       \         P                  ! 4       4      3R\         P                  ! \         P                  ! 4       \         P                  ! 4       4      3R\         P                  ! \         P                  ! 4       \         P
                  ! ^^4      4      3R\         P                  ! \         P                  ! 4       \         P                  ! 4       4      3.p\        \        V4      R7      pRpV P                  W2R7      p\         P                  ! V4      pR . R
OR. ROR\        R4      \        R	4      \        R4      .R. RO/pVP                  V8X  g   Q hVP                  4       V8X  g   Q hR \         P                  ! \         P                  ! 4       \         P                  ! 4       4      3V^ &   \        \        V4      R7      p\        P                  ! \         4      ;_uu_ 4        V P                  W2R7      pRRR4       R#   + '       g   i     R# ; i)r   r   r   r#  r  s<   a,b,c,d
abc,123456,1.0,zz
defg,123456,0.5,xx
abc,N/A,1.0,xx
ry  Nr  z0.50)r   defgr   )r  r  N)r  r}  r}  )r9   r  r   r   r;   r  
large_utf8r
   dictr   r   r   r
  int8rR   rS   r   )rm   r   rX   rl   r   r   rF   s   &      r   test_column_types_dict'BaseCSVTableRead.test_column_types_dict8  s    "--
BGGI67"--
BHHJ78"--
BMM"a,@AB"--
BMMO<=	? 4+=>$ ;<('''&/76?GFOD#	
 ||v%%% H,,, bggi CDQ4+=>]].//OODO?E 0///s   H**H;	c                v   R p\        RR.R7      p\        R\        P                  ! 4       /R7      pV P	                  WVR7      p\        P
                  ! R\        P                  ! 4       3R\        P                  ! 4       3.4      pVP
                  V8X  g   Q hVP                  4       R. ROR. RO/8X  g   Q hR# )	s   a,b
c,d
e,f
r   r   rJ   r  r   N)   a   c   e)r   r#  r  )r   r
   r9   r   r   r   r   r
  r  s   &     r   #test_column_types_with_column_names4BaseCSVTableRead.test_column_types_with_column_namesX  s     ""c
;(sBIIK6HI0?   AS"))+. "))+.0 1||v%%% #%
 
 	
 
rL   c                r    R pV P                  V4      pVP                  4       R^^.R^^.R^^./8X  g   Q hR#    a,b,c
1,2,3
4,5,6r   r   r   Nr`  r\  s   &  r   test_no_ending_newline'BaseCSVTableRead.test_no_ending_newlineh  sN    %% !Q!Q!Q%
 
 	
 
rL   c                ^    R pV P                  V4      pVP                  4       R. /8X  g   Q hR# )s   ,

r   Nr`  r\  s   &  r   test_trivialBaseCSVTableRead.test_trivialr  s.    % RH,,,rL   c                `   R pV P                  V4      pVP                  4       R^^.R^^./8X  g   Q h\        RR7      pV P                  WR7      pVP                  4       R. ROR. RO/8X  g   Q h\        ^R7      pV P                  WVR7      pVP                  4       R	R^.R
R^./8X  g   Q hR# )s   a,b
1,2

3,4
r   r   F)r   r/  N)r   r<  r  2)Nr   Nr   )Nr   Nr   )r   r
  r	   r   )rm   rl   r   r  r  s   &    r   test_empty_lines!BaseCSVTableRead.test_empty_linesx  s    +% !Q!Q%
 
 	
 
 %>B ##%
 
 	
 
 #Q/-9   ; $$%
 
 	
 
rL   c                D   R p\         P                  ! \        P                  RR7      ;_uu_ 4        V P	                  V4       RRR4       Rp\         P                  ! \        P                  RR7      ;_uu_ 4        V P	                  V4       RRR4       R FK  p\         P                  ! \        P                  RR7      ;_uu_ 4        V P	                  V4       RRR4       KM  	  R#   + '       g   i     L; i  + '       g   i     Lv; i  + '       g   i     K  ; i)s   a,b,c
1,2
4,5,6
rp  r   Ns   a,b,c
1,2,3
4zExpected 3 columns, got 1Empty CSV file)rL   re  rg  rf  s   

)rR   rS   r9   r   r   )rm   rl   s   & r   test_invalid_csv!BaseCSVTableRead.test_invalid_csv  s    %]]2??2MNNOOD! O!]]2??2MNNOOD! O9Dr6FGG% HG : ON ON HGGs#   C(;C;D(C8	;D	Dc                    R pV P                  V4      pVP                  4       RR.RR./8X  g   Q h\        RR7      pV P                  WR7      pVP                  4       RR	.R
R./8X  g   Q hR# )   a;b,c
de,fg;eh
a;bder   fg;ehr  r  r/  r   de,fgb,cehN)r   r
  r	   )rm   rl   r   rX   s   &   r   test_options_delimiter'BaseCSVTableRead.test_options_delimiter  s    #% D6'%
 
 	
 
 c*9 'D6%
 
 	
 
rL   c                    \        ^^
R7      w  rV P                  V4      pVP                  VP                  8X  g   Q hVP                  V4      '       g   Q hVP	                  4       VP	                  4       8X  g   Q hR# r   r  N)rG   r   r   equalsr
  )rm   rB   rF   r   s   &   r   test_small_random_csv&BaseCSVTableRead.test_small_random_csv  sg    'R@$||x...||H%%%% H$6$6$8888rL   c                f   \        ^RR7      w  r. ROpWP                  R4      .pV F  pV F|  p\        VR7      pV P                  WWR7      pVP                  VP                  8X  g   Q hVP                  V4      '       d   KW  VP                  4       VP                  4       8X  d   K|  Q h	  K  	  R# )r     r  rg  r   r  N)            %   o   )rG   rstripr   r   r   r
  r
  )	rm   csv_baserF   block_sizescsvsrB   r   r  r   s	   &        r   test_stress_block_sizes(BaseCSVTableRead.test_stress_block_sizes  s    ,a#F///'23C)
*jAG||x666||H-- ??,0B0B0DDDD * rL   c                    \         P                  pR p\        V4       Uu. uF  pRV 2NK
  	  pp\	        V4      pV! 4       p\        VR,           Uu/ uF  qw\        P                  ! 4       bK  	  upR7      pV P                  WXR7      p	V! 4       V,
          p
V
R8:  g   Q hV	P                  V8X  g   Q hV	P                  ^ 8X  g   Q hV	P                  V8X  g   Q hR#   \         d    \         P                   p Li ; iu upi u upi )i'  K:NNr   r  ry        $@N)r  thread_timerT   r   rK   r
   r9   r   r   r   r!   rJ   )rm   clockr   r"   rC   rB   t1kr!  r   dts   &          r   "test_stress_convert_options_blowup3BaseCSVTableRead.test_stress_convert_options_blowup  s    	$$E &+K&89&8qW&8	9Y'W(2;C.A.QRYY[..ACEWr\ Tzz  K///~~"""!!Y...#  	IIE	 : Bs   C C>DC;:C;c           
     X   \         P                  ! 4       P                  \         P                  ! 4       P                  8w  d   \        P
                  ! R 4       R pRpRp^ pVR8  d   V^
8  d   \        RV4       RRV,          ,           pRp \        P                  ! 4       ;_uu_ 4       p \         P                  ! VR	7      pVP                  4        \        P                  ! 4       p	 V P                  V4       \        P                  ! V.. V.R
4        RRR4       Te   TP                  e   MT^,          pK  Xf   \        P                   ! R4       VR8:  g   Q hVP                  p
\#        V
\$        P&                  4      '       g   Q hV
P(                  \*        P,                  8X  g   Q hR#   \         d)   p
T
p\        P                  ! 4       T	,
          p Rp
?
LRp
?
ii ; i  \        P                  ! T.. T.R
4       i ; i  + '       g   i     L; i  \         d     EL	i ; i)z'test only works from main Python threadc                  z    \         P                  ! R 4       \        P                  ! \        P                  4       R# )g?N)r  sleepsignalraise_signalSIGINTrN   rL   r   signal_from_thread>BaseCSVTableRead.test_cancellation.<locals>.signal_from_thread  s    JJsO.rL   g        i g      @zworkload size:s   a,b,c
s   1,2,3
Ntargetr  z0Failed to get an interruption during CSV readingr  )	threadingcurrent_threadidentmain_threadrR   r   printr   signal_wakeup_fdThreadstartr  r   KeyboardInterruptselect__context__failrv   r9   ArrowCancelledsignumr(  r*  )rm   r+  last_durationworkload_sizeattempts	large_csvexc_infosigfdr  r   r0  s   &          r   test_cancellation"BaseCSVTableRead.test_cancellation  s   $$&,,%%'--.KKAB	/ c!hm"M2"Z-%??IH **,,B%,,4FG	!YY[= OOI6 ugrE7DA -( # ''3 *A-MKKJK ###  !R..////xx6==(((?  1 ='(H,0IIK",<M= ugrE7DA -,  % sl   H +H-<G'*F1;HH 1G$<GG'G$$G''HHH	H H H)(H)c                ~   a  \         P                  ! V 3R  lR7      pVP                  4        VP                  4        R# )c                  &   < S P                  R 4      # )s   f64
0.1)r   r   s   r   <lambda>=BaseCSVTableRead.test_cancellation_disabled.<locals>.<lambda>  s    4??;7rL   r-  N)r/  r5  r6  r4   )rm   r  s   f r   test_cancellation_disabled+BaseCSVTableRead.test_cancellation_disabled  s*    
 79			rL   rN   N)+r~   r   r   r   r   r   rX  r]  ra  rm  rs  rv  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r#  rR   rC  r/  rC  rI  r   r   r   s   @r   rF  rF    s      8	#21
f=2C:+
Z

 
.
2
" 
D"
H
6/-b,
\
*'KR@@
 
-
*
&
9E/0 [[@) @)D [[ rL   rF  c                   0   a  ] tR tRt o ]R 4       tRtV tR# )TestSerialCSVTableReadi"  c                    R # FrN   r   s   &r   r   "TestSerialCSVTableRead.use_threads#      rL   rN   Nr~   r   r   r   rA  r   r   r   r   s   @r   rL  rL  "        rL   rL  c                   0   a  ] tR tRt o ]R 4       tRtV tR# )TestThreadedCSVTableReadi(  c                    R # TrN   r   s   &r   r   $TestThreadedCSVTableRead.use_threads)      rL   rN   NrQ  r   s   @r   rT  rT  (  s      rL   rT  c                      a a ] tR tRt oR tR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tV 3R lt]P.                  P0                  V 3R l4       tRtVtV ;t# )BaseStreamingCSVReadi.  c                v    VP                  R\        4       4      pV P                  Vn        \        V.VO5/ VB # )z
Reads the CSV file into memory using pyarrow's open_csv
csv The CSV bytes
args Positional arguments to be forwarded to pyarrow's open_csv
kwargs Keyword arguments to be forwarded to pyarrow's open_csv
r  )rL  r   r   r   )rm   rB   r  r   r  s   &&*, r   r   BaseStreamingCSVRead.open_csv0  s;     ((G#'#3#3 -d-f--rL   c                P    V P                   ! \        P                  ! V4      3/ VB # r   )r   r9   rO  r   s   &&,r   
open_bytesBaseStreamingCSVRead.open_bytes;  rQ  rL   c                   VP                   V8X  g   Q h\        V4      p\        V4      \        V4      8X  g   Q h\        WC4       FA  w  rVVP	                  R R7       VP                   V8X  g   Q hVP                  4       V8X  d   KA  Q h	  R# )TrI  N)r   r0   r   zipr   r
  )rm   readerexpected_schemarU  batchesbatchexpected_batchs   &&&&   r   check_reader!BaseStreamingCSVRead.check_reader>  s|    }}///v,7|s=1111%(%@!ENNN%<<?222??$666 &ArL   c                D    V P                   ! V3/ VB P                  4       # r   )r^  read_allr   s   &&,r   r   BaseStreamingCSVRead.read_bytesG  s    q+F+4466rL   c                   R pR^^.R^^./p\         P                  ! V4      pV P                  V4      p\        P                  ! R\        P
                  ! 4       3R\        P
                  ! 4       3.4      pV P                  WEV.4       R# )s   a,b
1,2
3,4
r   r   N)r.   rS  r   r9   r   r;   rg  )rm   rT  rU  rV  rb  rc  s   &     r   rX  %BaseStreamingCSVRead.test_file_objectJ  sy    !q!fcAq62jjs#))c288:%6&)288:%6%8 9&M?CrL   c                    R pV P                  V4      p\        P                  ! R\        P                  ! 4       3R\        P                  ! 4       3R\        P                  ! 4       3.4      pV P	                  W#. 4       R# )r[  r   r   r  N)r^  r9   r   r   rg  rm   rl   rb  rc  s   &   r   r]   BaseStreamingCSVRead.test_headerS  sc    &))eRWWY%7&+RWWY%7&*BGGI%6%8 9 	&26rL   c           	        R p\         P                  ! R\         P                  ! 4       3R\         P                  ! 4       3.4      p\	        4       p\        V4      Vn        V P                  WR7      pV P                  WBR. ROR. RO/.4       \        V4      ^,
          Vn        V P                  WR7      pV P                  WBRRR.RRR./RR.RR	./.4       R
# )   a,b
123,456
abc,de
gh,ij
r   r   r  123r   r     456   de   ijN)rs  r   r  )rt  ru  rv  )	r9   r   r   r   r   r   r   r^  rg  )rm   rl   rc  r  rb  s   &    r   test_inference#BaseStreamingCSVRead.test_inference[  s    3))c299;%7&)299;%7%9 : #}"%d)A&!5!;= >	? #&d)a-A&%&)!46$%*+	,rL   c                   R p\        4       p\        V4      ^,
          Vn        V P                  WR7      p\        P
                  ! R\        P                  ! 4       3R\        P                  ! 4       3.4      pVP
                  V8X  g   Q hVP                  4       P                  4       R^{.RR./8X  g   Q h\        P                  ! \        RR7      ;_uu_ 4        VP                  4        RRR4       \        P                  ! \        4      ;_uu_ 4        VP                  4        RRR4       R#   + '       g   i     LM; i  + '       g   i     R# ; i)rr  r  r   r   i  zCSV conversion error to int64r   N)r   r   r   r^  r9   r   r;   read_next_batchr
  rR   rS   r   StopIterationrm   rl   r  rb  rc  s   &    r   test_inference_failure+BaseStreamingCSVRead.test_inference_failurep  s   3"}"%d)a-A))c288:%6&)288:%6%8 9}}///%%'113#cU8
 
 	
 
 ]]:!@B B""$B ]]=))""$ *)	B B *))s   D0E0E 	E	c                   R p\        4       p^
Vn        \        P                  ! \        P
                  RR7      ;_uu_ 4        V P                  WR7      pRRR4       Rp^Vn        V P                  WR7      pVP                  4       P                  4       R^.R^./8X  g   Q h\        P                  ! \        P
                  RR7      ;_uu_ 4        VP                  4        RRR4       \        P                  ! \        4      ;_uu_ 4        VP                  4        RRR4       R#   + '       g   i     L; i  + '       g   i     L`; i  + '       g   i     R# ; i)s   a,b
1,2,3
4,5
6,7
zExpected 2 columns, got 3r   r  Ns   a,b
1,2
3,4,5
6,7
r   r   )
r   r   rR   rS   r9   r   r^  rz  r
  r{  )rm   rl   r  rb  s   &   r   r  %BaseStreamingCSVRead.test_invalid_csv  s	   ("}"$]]2??!<> >__ % 1F> )"#A%%'113aS#s7KKKK]]2??!<> >""$> ]]=))""$ *)> >> > *))s$   D'D:E'D7	:E
	E	c                   R pV P                  V4      p\        P                  ! R\        P                  ! 4       3R\        P                  ! 4       3.4      pV P	                  W#RR.RR./.4       \        RR7      pV P                  WR7      p\        P                  ! R\        P                  ! 4       3R	\        P                  ! 4       3.4      pV P	                  W#RR
.R	R./.4       R# )r  r   r   r  r  r  r  r/  r   r  r  r  N)r^  r9   r   r   rg  r	   )rm   rl   rb  rc  rX   s   &    r   r  +BaseStreamingCSVRead.test_options_delimiter  s    #&))eRYY[%9&)299;%7%9 :&!D6', -	. c*:))c299;%7&+RYY[%9%; <&'!D6+ ,	-rL   c                   R pV P                  V4      p\        P                  ! R\        P                  ! 4       3R\        P                  ! 4       3R\        P                  ! 4       3.4      pV P	                  W#R^^.R^^.R^^./.4       R# r  )r^  r9   r   r;   rg  ro  s   &   r   r  +BaseStreamingCSVRead.test_no_ending_newline  s    %&))c288:%6&)288:%6&)288:%6%8 9 	&!Q!Q!Q) *	+rL   c                    \         P                  ! \        R R7      ;_uu_ 4        V P                  R4       RRR4       R#   + '       g   i     R# ; i)r  r   rL   N)rR   rS   r   r^  r   s   &r   test_empty_file$BaseStreamingCSVRead.test_empty_file  s/    ]]:-=>>OOC  ?>>>s   AA	c                   R p\        4       p. ROVn        V P                  WR7      p\        P                  ! R\        P
                  ! 4       3R\        P
                  ! 4       3R\        P
                  ! 4       3.4      pV P                  W4R^^.R^^.R^^./.4       \        4       pRR.Vn        V P                  WVR7      p\        P                  ! R\        P
                  ! 4       3R\        P
                  ! 4       3.4      pV P                  W4R^^.R^^./.4       R\        P                  ! 4       /Vn
        V P                  WVR7      p\        P                  ! R\        P
                  ! 4       3R\        P                  ! 4       3.4      pV P                  W4RRR.R^^./.4       . ROVn        \        P                  ! \        R	R
7      ;_uu_ 4        V P                  WVR7      pRRR4       RVn        V P                  WVR7      p\        P                  ! R\        P                  ! 4       3R\        P
                  ! 4       3R\        P                  ! 4       3.4      pV P                  W4RRR.RRR.R^^./.4       R\        P                  ! 4       R\        P                   ! 4       /Vn
        V P                  WVR7      p\        P                  ! R\        P                   ! 4       3R\        P
                  ! 4       3R\        P                  ! 4       3.4      pV P                  W4RRR.RRR.R^^./.4       R#   + '       g   i     EL_; i)s   1,2,3
4,5,6r#  r0  r  r  r   r  5r:  z,Column 'g' in include_columns does not existr   NT)r#  r0  r  )r:  r  r0  )r   rJ   r^  r9   r   r;   rg  r
   r   r   r   rR   rS   r  r   r   r  )rm   rl   r  rb  rc  r!  s   &     r   test_column_options(BaseStreamingCSVRead.test_column_options  sB   "}$3!A))c288:%6&)288:%6&)288:%6%8 9 	&!Q!Q!Q) *	+ )*+.*'1@ ! B))c288:%6&)288:%6%8 9&!Q!Q) *	+
 ),RYY['9$1@ ! B))c288:%6&)299;%7%9 :&#s!Q) *	+
 +:']]DF F __T5D % FFF 37/1@ ! B))c2779%5&)288:%6&)299;%7%9 : 	&$#s!Q) *	+
 ),RYY[#rzz|'L$1@ ! B))c2::<%8&)288:%6&)299;%7%9 : 	&$#s!Q) *	+/F F Fs   MM	c                   R p\        4       pV P                  WR7      p\        P                  ! R\        P                  ! 4       3R\        P
                  ! 4       3.4      pV P                  W4RR.RR./.4       RVn        V P                  WR7      p\        P                  ! R\        P                  ! 4       3R\        P                  ! 4       3.4      pV P                  W4RR.RR./.4       RpR	Vn        V P                  WR7      p\        P                  ! R\        P                  ! 4       3R\        P                  ! 4       3.4      pV P                  W4RR.RR./.4       R
# )s   a,b
un,lphantr  r   r   uns   lphantlatin1u
   éléphants    a , b 
 u n ,  l  p h a n t r   N)r   r^  r9   r   r   r   rg  r   r|  s   &    r   test_encoding"BaseStreamingCSVRead.test_encoding  s\   ("}A))c299;%7&)299;%7%9 :&$"3!46 7	8 !)A))c299;%7&)299;%7%9 :&$,1 2	3
F 'A))c299;%7&)299;%7%9 :&$,1 2	3rL   c                   \        ^^
R7      w  rV P                  V4      pVP                  4       pVP                  VP                  8X  g   Q hVP	                  V4      '       g   Q hVP                  4       VP                  4       8X  g   Q hR# r	  )rG   r^  rj  r   r
  r
  )rm   rB   rF   rb  r   s   &    r   r  *BaseStreamingCSVRead.test_small_random_csv  ss    'R@%!||x...||H%%%% H$6$6$8888rL   c                   \        ^RR7      w  r. ROpWP                  R4      .pV F  pV F  pVRV P                  R4      ^8  g   Q h\        VR7      pV P	                  WWR7      pVP                  4       p	V	P                  VP                  8X  g   Q hV	P                  V4      '       d   K  V	P                  4       VP                  4       8X  d   K  Q h	  K  	  R# )	r   r  r  rg  Nre  r   r  )            r  r  )	rG   r  countr   r^  rj  r   r
  r
  )
rm   r  rF   r  r  rB   r   r  rb  r   s
   &         r   r  ,BaseStreamingCSVRead.test_stress_block_sizes"  s    ,a#F///'23C)
;J'--e4999*jA ) 4)||x666||H-- ??,0B0B0DDDD * rL   c                   \         P                  ! 4        \        P                  ! 4       pR  pRp\	        4       pRR.Vn        ^Vn        V P                  W4R7      pV! VR^
.R^./4       \        P                  ! 4       pV! VR^.R^./4       \        P                  ! 4       V8:  g   Q hV! VR^.R^./4       \        P                  ! 4       V8:  g   Q hV! VR^.R^./4       \        P                  ! 4       V8:  g   Q h\        P                  ! \        4      ;_uu_ 4        VP                  4        RRR4       \        P                  ! 4       V8X  g   Q hRp\        P                  ! 4       V8X  g   Q hR#   + '       g   i     LL; i)c                 T    V P                  4       pVP                  4       V8X  g   Q hR # r   )rz  r
  )rb  rF   re  s   && r   check_one_batchABaseStreamingCSVRead.test_batch_lifetime.<locals>.check_one_batch9  s%    **,E??$000rL   s   10,11
12,13
14,15
16,17
r   r   r  N)gccollectr9   total_allocated_bytesr   rJ   r   r^  rR   rS   r{  rz  )rm   old_allocatedr  rl   r  rb  allocated_after_first_batchs   &      r   test_batch_lifetime(BaseStreamingCSVRead.test_batch_lifetime4  s_   


002	1 /"}%(#J!"#ArdC" 67&(&>&>&@#rdC" 67'')-HHHHrdC" 67'')-HHHHrdC" 67'')-HHHH]]=))""$ *'')]:::'')]:::	 *)s   #E88F	c                0  < \         SV `  4        R p\        4       p^Vn        RR.Vn        V P                  WR7      p\        P                  ! \        4      ;_uu_ 4        VP                  4       '       g   Q h RRR4       R#   + '       g   i     R# ; i)r   r   r   r  N)
superr  r   r   rJ   r^  rR   rS   r{  rz  rm   rl   rX   rb  	__class__s   &   r   r  *BaseStreamingCSVRead.test_header_skip_rowsP  sr    %'. }!4L9]]=))))++++ *)))s    BB	c                  < \         SV `  4        R p\        4       p^Vn        V P	                  WR7      p\
        P                  ! \        4      ;_uu_ 4        VP                  4       '       g   Q h RRR4       RVn        V P	                  WR7      p\
        P                  ! \        4      ;_uu_ 4        VP                  4       '       g   Q h RRR4       R#   + '       g   i     Lo; i  + '       g   i     R# ; i)r   r  Nr   )	r  r  r   r   r^  rR   rS   r{  rz  r  s   &   r   r  /BaseStreamingCSVRead.test_skip_rows_after_names]  s    *,. }%&"9]]=))))++++ * &+"9]]=))))++++ *) *) *))s   C4C+C(	+C<	rN   )r~   r   r   r   r   r^  rg  r   rX  r]  rw  r}  r  r  r  r  r  r  r  r  r  r  rR   rC  rD  r  r   r   __classcell__r  r   s   @@r   rZ  rZ  .  s     	.877D7,*%(%,-"
+!?+B3<9E$;8, [[, , ,rL   rZ  c                   0   a  ] tR tRt o ]R 4       tRtV tR# )TestSerialStreamingCSVReadiq  c                    R # rN  rN   r   s   &r   r   &TestSerialStreamingCSVRead.use_threadsr  rP  rL   rN   NrQ  r   s   @r   r  r  q  rR  rL   r  c                   0   a  ] tR tRt o ]R 4       tRtV tR# )TestThreadedStreamingCSVReadiw  c                    R # rV  rN   r   s   &r   r   (TestThreadedStreamingCSVRead.use_threadsy  rX  rL   rN   NrQ  r   s   @r   r  r  w  s      rL   r  c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )BaseTestCompressedCSVReadi~  c                >    \         P                  ! R R7      V n        R# )zarrow-csv-test-)prefixN)tempfilemkdtemptmpdirr   s   &r   setUpBaseTestCompressedCSVRead.setUp  s    &&.?@rL   c                F    \         P                  ! V P                  4       R # r   )shutilrmtreer  r   s   &r   tearDown"BaseTestCompressedCSVRead.tearDown  s    dkk"rL   c                     \        V4      #   \        P                   d+   p\        P                  ! \        T4      4        R p?R # R p?ii ; ir   )r   r9   ArrowNotImplementedErrorrR   r   r6   )rm   csv_pathr0  s   && r   r   "BaseTestCompressedCSVRead.read_csv  s;    	 H%%** 	 KKA	 s   
 AAAc                   \        ^^dR7      w  r\        P                  P                  V P                  V P
                  4      pV P                  W14       V P                  V4      pVP                  RR7       VP                  VP                  8X  g   Q hVP                  V4      '       g   Q hVP                  4       VP                  4       8X  g   Q hR# )r   r  TrI  N)rG   ospathr4   r  csv_filename
write_filer   r   r   r
  r
  )rm   rB   rF   r  r   s   &    r   test_random_csv)BaseTestCompressedCSVRead.test_random_csv  s    'SA77<<T->->?&h'D!||x...||H%%%% H$6$6$8888rL   )r  N)
r~   r   r   r   r  r  r   r  r   r   r   s   @r   r  r  ~  s     A# 9 9rL   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )TestGZipCSVReadi  zcompressed.csv.gzc                    \         P                  ! VR ^4      ;_uu_ 4       pVP                  V4       RRR4       R#   + '       g   i     R# ; i)wbN)gzipopenr3   rm   r  contentsr  s   &&& r   r  TestGZipCSVRead.write_file  s2    YYtT1%%GGH &%%%s	   =A	c                   \         P                  P                  V P                  V P                  4      p\
        P                  ! VR ^4      ;_uu_ 4       pVP                  R4       RRR4       \
        P                  ! VR^4      ;_uu_ 4       pVP                  R4       RRR4       V P                  V4      pVP                  4       R. ROR. RO/8X  g   Q hR#   + '       g   i     L|; i  + '       g   i     LU; i)r  s   ab,cd
ef,gh
Nr   s   ij,kl
mn,op
r   rz  r{  )
r  r  r4   r  r  r  r  r3   r   r
  )rm   r  r  r   s   &   r   test_concatenated!TestGZipCSVRead.test_concatenated  s    77<<T->->?YYxq))QGG%& *YYxq))QGG%& *h' $$%
 
 	
 
 *)))s   CC.C+	.C>	rN   N)	r~   r   r   r   r  r  r  r   r   r   s   @r   r  r    s     &L
 
rL   r  c                   *   a  ] tR tRt o RtR tRtV tR# )TestBZ2CSVReadi  zcompressed.csv.bz2c                    \         P                  ! VR 4      ;_uu_ 4       pVP                  V4       RRR4       R#   + '       g   i     R# ; i)r   N)bz2BZ2Filer3   r  s   &&& r   r  TestBZ2CSVRead.write_file  s0    [[s##qGGH $###s	   <A	rN   N)r~   r   r   r   r  r  r   r   r   s   @r   r  r    s     'L rL   r  c                  p    \         P                  ! R 4      p \        V 4       V P                  '       d   Q hR# )r  N)r.   rS  r   closed)bufs    r   0test_read_csv_does_not_close_passed_file_handlesr    s(    
**+
,CSMzzz>zrL   c            
      T   \         P                  P                  . RO. RO.RR.4      p V P                  ^R7      ^ ,          pW3 F  p\        P
                  ! 4       p\        W#\        RR7      4       VP                  ^ 4       V \        V4      8X  g   Q h\        P
                  ! 4       p\        W#\        RR7      4       VP                  ^ 4       \        V P                  R7      pV \        W4R7      8X  d   K  Q h	  R	R	\        RR7      3\        V P                  R7      R	\        RR7      3R	\        R
R7      \        RR
R7      3\        V P                  R7      \        RR7      \        RRR7      33 EF  w  rEp\        P
                  ! 4       p\        W0P                  VR7      ;_uu_ 4       pVP                  V 4       R	R	R	4       VP                  ^ 4       V \        W4VR7      8X  g   Q h\        P
                  ! 4       p\        W0P                  VR7      ;_uu_ 4       pV P                  ^R7       F  pVP!                  V4       K  	  R	R	R	4       VP                  ^ 4       V \        W4VR7      8X  d   EK  Q h	  R	#   + '       g   i     L; i  + '       g   i     LO; i)r   c1c2)max_chunksizeT)r   Fr  r  Nr   r  )r   r   r   write_optionsr  r  )r   r   r   )r9   r<   r=   rj  r.   rS  r   r   seekr   r   rJ   r	   r   r   write_tablewrite_batch)	r  record_batchrT  r  r  r  r  writerre  s	            r   test_write_read_round_tripr    s   
i9D$<HA<<a<03L!jjl$\>?HSM!!! jjl$\?@"?HS<<<< "" 
t\67	!..	14	U	+	-	|c*	TS	9	;	!..	1		%	Ud	;	=	72] jjlsHHMBBfq! CHS+8: : 	: :jjlsHHMBBfA6""5) 7 C 	HS+8: : 	: :+	7 CB CBs   2J%+JJJ'c                     \         P                  P                  . RO. RO.RR.4      p \        P                  ! 4       p\        RR7      R3\        4       R3\        RR7      R	33 Ff  w  r#\        WP                  VR
7      ;_uu_ 4       pVP                  V 4       RRR4       VP                  4       V8X  g   Q hVP                  ^ 4       Kh  	  \         P                  P                  RR..R.4      p \        P                  ! 4       p\        RR7      R3\        RR7      \         P                  P                  33 Fh  w  r#\        WP                  VR
7      ;_uu_ 4       p VP                  V 4        RRR4       TP                  4       T8X  g   Q hTP                  ^ 4       Kj  	  R#   + '       g   i     EL; i  \         d(   p\        YS4      '       g   Q h Rp?RRR4        R# Rp?ii ; i  + '       g   i     L; i)r   Nr  r  r   )r   s   "c1","c2"
1,a
2,
,c
   "c1","c2"
1,"a"
2,
,"c"
r   s   "c1","c2"
"1","a"
"2",
,"c"
r  r)   r   r   s   "c1"
","
""""
r   r   Nr   Nr   )r9   r<   r=   r.   rS  r   r   r   r  r7   r  libr   	Exceptionrv   )r  r  r  resr  r0  s         r   test_write_quoting_styler    s   
l,<=d|LA
**,C	F	+-HI	89	K	0	,	. sHHMBBfq! C||~$$$ 	sDk]TF3A
**,C	H	-/CD	F	+RVV-@-@A sHHMBBf""1% C ||~$$$ CBB   "!)))) CB CBs<   	F* G3"F>*F;>G0		G+	G3+G0	0G33Hc                     \         P                  P                  . R
O. RO.RR.4      p \        P                  ! 4       p\        RR7      R3\        4       R3\        RR7      R33 Ff  w  r#\        WP                  VR	7      ;_uu_ 4       pVP                  V 4       RRR4       VP                  4       V8X  g   Q hVP                  ^ 4       Kh  	  R#   + '       g   i     L>; i)r   Nr  r  r   )quoting_headers   c1,c2
1,"a"
2,
,"c"
r  r   r  r  r  )r9   r<   r=   r.   rS  r   r   r   r  r7   r  )r  r  r  r  r  s        r   test_write_quoting_headerr    s    
l,<=d|LA
**,C	V	,.IJ	89	[	1	(	* sHHMBBfq! C||~$$$ CBs   	CC!c                      R  p \         P                  ! 4       ;_uu_ 4        V ! 4       pV! 4       e   Q h RRR4       R#   + '       g   i     R# ; i)c                  p    \         P                  ! R 4      p \        V 4      p\        P                  ! V4      # )r  )r.   rS  r   weakrefref)r  r   s     r   inner,test_read_csv_reference_cycle.<locals>.inner  s)    jj/0{{5!!rL   N)r   disabled_gc)r   wrs     r   test_read_csv_reference_cycler    s:    "
 
				Wt|| 
			s	   ?A	type_factoryc                  0    \         P                  ! ^^4      #    r9   r  rN   rL   r   rG  rG  $      BMM"a rL   c                  0    \         P                  ! ^&^4      # )&   r	  rN   rL   r   rG  rG  %      BMM"b!rL   c                  0    \         P                  ! ^^4      # r  r9   
decimal256rN   rL   r   rG  rG  &  r
  rL   c                  0    \         P                  ! ^L^
4      # )L   r  rN   rL   r   rG  rG  '  r  rL   c                 B   V! 4       p\         P                  ! R \         P                  ! ^^.4      P                  V4      /4      p\	        W0R,          4       \        V R,          4      pVP                  R 4      P                  V4      VP                  R 4      8X  g   Q hR# )colzout.csvN)r9   r   r:   castr   r   column)r  r  r*   r   outs   &&   r   test_write_csv_decimalr  #  s}     >DHHeRXXq!f-22489:Eei'(
6I%
&C::e!!$'5<<+>>>>rL   c                     R p  ! R R\         P                  4      p\        ^4       FI  p\        P                  ! \
        P                  4      ;_uu_ 4        \        V! V 4      4       RRR4       KK  	  R#   + '       g   i     K`  ; i)s   a,b,cc                   >   a a ] tR tRt oV 3R ltV 3R ltRtVtV ;t# )-test_read_csv_gil_deadlock.<locals>.MyBytesIOi:  c                L   < \         P                  ! R 4       \        SV `  ! V!  # gMbP?)r  r'  r  readrm   r  r  s   &*r   r  2test_read_csv_gil_deadlock.<locals>.MyBytesIO.read;  s    JJu7<&&rL   c                L   < \         P                  ! R 4       \        SV `  ! V!  # r  )r  r'  r  readintor  s   &*r   r"  6test_read_csv_gil_deadlock.<locals>.MyBytesIO.readinto?  s    JJu7#T**rL   rN   )	r~   r   r   r   r  r"  r   r   r  r  s   @@r   	MyBytesIOr  :  s     	'	+ 	+rL   r$  N)r.   rS  r   rR   rS   r9   r   r   )rT  r$  r"   s      r   test_read_csv_gil_deadlockr%  3  sZ    
 D+BJJ + 2Y]]2??++Yt_% ,+ +++s   A66Bztables,expectedc                     \         P                  ! R . /4      P                  \         P                  ! R \         P                  ! 4       3.4      4      \         P                  ! R R./4      \         P                  ! R R./4      .# col1r   r   r9   r   r  r   r   rN   rL   r   rG  rG  K  s\    62,',,RYY8M7N-OP6C5/*6C5/*,rL   s   "col1"
"a"
"b"
c                     \         P                  ! R R./4      \         P                  ! R . /4      P                  \         P                  ! R \         P                  ! 4       3.4      4      \         P                  ! R R./4      .# r'  r)  rN   rL   r   rG  rG  R  s\    6C5/*62,',,RYY8M7N-OP6C5/*,rL   c            	         \         P                  ! R R./4      \         P                  ! R R./4      \         P                  ! R . /4      P                  \         P                  ! R \         P                  ! 4       3.4      4      .# r'  r)  rN   rL   r   rG  rG  Y  s]    6C5/*6C5/*62,',,RYY8M7N-OPRrL   c                     \         P                  ! V ! 4       4      p\        P                  ! 4       p\	        W#4       VP                  ^ 4       VP                  4       pWA8X  g   Q hR# r   )r9   concat_tablesr.   rS  r   r  r  )tablesrF   combinedr  rk   s   &&   r   4test_write_csv_empty_batch_should_not_pollute_outputr0  H  sK    0 )H
**,ChHHQKXXZFrL   )r   r   z
T)Hr   r  r   r   decimalr   r  r  r.   r1   r  r+   r8  r  r(  r   r  r/  r  unittestr  rR   pyarrowr9   pyarrow.csvr   r   r   r	   r
   r   r   r   r   r   pyarrow.testsr   r   r#   r%   rG   rK   r^   rf   rh   r   r   r   r   r   ABCr   rF  rL  rT  rZ  r  rC  r  r  TestCaser  r  r  r  r  r  r  parametrizer  r%  r0  rN   rL   r   <module>r9     s  $  
 #  	  	  	            4 4 4 !"$#,00- -$&@>FE?P_AD?BXK#'' XKv
T{ Tn- / @,; @,F
!5  #7  9 92
/1B1B 
*.0A0A ):XB	  ! !	* ??&* *	, 			, 			R 		!- ./.rL   