+
    nDj`t                        ^ RI t  ^ RIt^ RIt^ RIHt ] P                  P                  t
RRRR/t ^ RIH	t RKR lt ! R R]4      t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      RLR l4       t] P"                  ! R	R
7      RLR l4       t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      R 4       t] P"                  ! R	R
7      R 4       t RR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, t0R- t1R. t2R/ t3R0 t4R1 t5R2 t6R3 t7R4 t8R5 t9R6 t:R7 t;R8 t<R9 t=R: t>R; t?] P                  P                  R< 4       t@] P                  P                  R= 4       tAR> tBR? tC] P                  P                  R@ 4       tD] P                  P                  RA 4       tE] P                  P                  RB 4       tF] P                  P                  RC 4       tGRD tHRE tI] P                  P                  RF 4       tJ] P                  P                  RG 4       tK] P                  P                  RH 4       tM] P                  P                  RI 4       tN] P                  P                  RJ 4       tOR#   ] d    Rt ELii ; i  ] d    Rt ELLi ; i)M    N)computesummary descriptionc                 F    ^ RI Hp V! \        P                  ! 4       V 4      # )r   )_get_udf_context)pyarrow._computer   padefault_memory_pool)batch_lengthr   s   & P/data/cameron/venvs/s3viz/lib/python3.14/site-packages/pyarrow/tests/test_udf.pymock_udf_contextr   )   s    1B224lCC    c                       ] tR t^.tRtR# )MyError N)__name__
__module____qualname____firstlineno____static_attributes__r   r   r   r   r   .   s    r   r   session)scopec                     R p Rp\         p\        P                  ! V VVR\        P                  ! 4       /\        P                  ! 4       4       W3# )z,
Register a unary aggregate function (mean)
c                 V    \         P                  ! \        P                  ! V4      4      # N)r
   scalarnpnansum)ctxxargss   &&*r   func"sum_agg_func_fixture.<locals>.func7   s    yy1&&r   sum_udfr!   )empty_udf_docpcregister_aggregate_functionr
   float64r#   	func_namefunc_docs      r   sum_agg_func_fixturer-   2   sN    
' IH""4#,#+'*BJJL$% $&::<% ?r   c                      R  p Rp\         p\        P                  ! V VVR\        P                  ! 4       /\        P                  ! 4       4       W3# )c                     \        R 4      h)Oops)RuntimeErrorr
   r   lenr    r!   s   &&r   r#   (exception_agg_func_fixture.<locals>.funcJ   s    6""r   y=exception_len(x)r!   r&   r'   r(   r
   int64r*   s      r   exception_agg_func_fixturer8   H   sN    ! %IH""4#,#+'*BHHJ$% $&88:% ?r   c                     R  pRp\         p\        P                  ! VVVR\        P                  ! 4       /\        P                  ! 4       4       W3# )c                 h    \         P                  ! \        V4      \         P                  ! 4       4      # r   )r
   r   r2   int32r3   s   &&r   r#   1wrong_output_dtype_agg_func_fixture.<locals>.func^   s    yyQ,,r   y=wrong_output_dtype(x)r!   r6   r   r#   r+   r,   s   &   r   #wrong_output_dtype_agg_func_fixturer?   \   sN    - *IH""4#,#+'*BHHJ$% $&88:% ?r   c                     R  pRp\         p\        P                  ! VVVR\        P                  ! 4       /\        P                  ! 4       4       W3# )c                     \        V4      # r   )r2   r3   s   &&r   r#   0wrong_output_type_agg_func_fixture.<locals>.funcq   s    1vr   y=wrong_output_type(x)r!   r6   r>   s   &   r   "wrong_output_type_agg_func_fixturerD   o   sN     )IH""4#,#+'*BHHJ$% $&88:% ?r   c            
         R p RpRRRR/p\         P                  ! V VVR\        P                  ! 4       R\        P                  ! 4       /\        P                  ! 4       4       W3# )z$
Register a binary scalar function.
c                 J    \         P                  ! R W.V P                  R7      # )multiplymemory_poolr'   call_functionrI   )r    mr!   s   &&&r   binary_function,binary_func_fixture.<locals>.binary_function   s"    
QF,/OO= 	=r   zy=mxr   r   zfind y from y = mxrL   r!   r'   register_scalar_functionr
   r7   )rM   r+   
binary_docs      r   binary_func_fixturerR      sg    
= IV!57J ) *!$bhhj!$bhhj!# !#
, %%r   c                     R p RRRR/pRp\         P                  ! V VVR\        P                  ! 4       R\        P                  ! 4       R\        P                  ! 4       /\        P                  ! 4       4       W3# )	z%
Register a ternary scalar function.
c                     \         P                  ! R W.V P                  R7      p\         P                  ! RWC.V P                  R7      # )rG   rH   addrJ   )r    rL   r!   cmxs   &&&& r   ternary_function.ternary_func_fixture.<locals>.ternary_function   s?    j1&*-//;w,/OO= 	=r   r   zy=mx+cr   zfind y from y = mx + carray1array2array3rO   )rX   ternary_docr+   s      r   ternary_func_fixturer^      ss    
=
 h ":<KI 0 ) +$,bhhj$,bhhj$,bhhj!"
 !#
, &&r   c            
         R p RpRRRR/p\         P                  ! V VVR\        P                  ! 4       R\        P                  ! 4       /\        P                  ! 4       4       W3# )zA
Register a varargs scalar function with at least two arguments.
c                 d    TpV F'  p\         P                  ! R W4.V P                  R7      pK)  	  V# )rU   rH   rJ   )r    firstvaluesaccvals   &&*  r   varargs_function.varargs_func_fixture.<locals>.varargs_function   s6    C""53*/2@C  
r   z	z=ax+by+cr   r   zfind z from z = ax + by + crZ   r[   rO   )re   r+   varargs_docs      r   varargs_func_fixturerh      sj    
 Ik "?K  0 ) +$,bhhj$,bhhj!" !#
, &&r   c                 x    R p RRRR/pRp\         P                  ! V VV/ \        P                  ! 4       4       W3# )z%
Register a nullary scalar function.
c                     \         P                  ! ^*.V P                  ,          \         P                  ! 4       V P                  R7      # *   typerI   r
   arrayr   r7   rI   contexts   &r   nullary_func*nullary_func_fixture.<locals>.nullary_func   3    xxw333"((*$+$7$79 	9r   r   random functionr   generates a random valuetest_nullary_funcrO   rs   r,   r+   s      r   nullary_func_fixturerz      sP    
9
 	$1H $I ) ( " "
	, ""r   c                 v    R p RRRR/pRp\         P                  ! V VV/ \        P                  ! 4       4       V# )z
Register a nullary scalar function with an ephemeral Python function.
This stresses that the Python function object is properly kept alive by the
registered function.
c                     \         P                  ! ^*.V P                  ,          \         P                  ! 4       V P                  R7      # rk   ro   rq   s   &r   rs   4ephemeral_nullary_func_fixture.<locals>.nullary_func   ru   r   r   rv   r   rw   test_ephemeral_nullary_funcrO   ry   s      r   ephemeral_nullary_func_fixturer      sM    9
 	$1H .I ) ( " "
	, r   c                 |    R p Rp/ p\         P                  ! 4       pRRRR/p\        P                  ! WVW#4       W3# )z]
Register a scalar function which returns something that is neither
a Arrow scalar or array.
c                     ^*# )rl   r   r    s   &r   wrong_output_type9wrong_output_type_func_fixture.<locals>.wrong_output_type   s    r   test_wrong_output_typer   zreturn wrong output typer   r   r
   r7   r'   rP   )r   r+   in_typesout_typedocs        r   wrong_output_type_func_fixturer      sQ     )IHxxzH-rC  1c (4''r   c                     R p RpR\         P                  ! 4       /p\         P                  ! 4       pRRRR/p\        P                  ! WVW#4       W3# )ze
Register a scalar function whose actual output DataType doesn't
match the declared output DataType.
c                 4    \         P                  ! R V^.4      # rU   r'   rK   )r    rp   s   &&r   wrong_output_datatypeAwrong_output_datatype_func_fixture.<locals>.wrong_output_datatype  s    qz22r   test_wrong_output_datatyperp   r   zreturn wrong output datatyper   r   )r
   r7   int16r'   rP   )r   r+   r   r   r   s        r   "wrong_output_datatype_func_fixturer     sZ    3,I$HxxzH1rC  5# (4 ++r   c                 |    R p Rp/ p\         P                  ! 4       pRRRR/p\        P                  ! WVW#4       W3# )z6
Register a scalar function with the wrong signature.
c                  X    \         P                  ! ^\         P                  ! 4       R7      # )   rn   )r
   r   r7   r   r   r   wrong_signature5wrong_signature_func_fixture.<locals>.wrong_signature*  s    yy,,r   test_wrong_signaturer   zUDF with wrong signaturer   r   r   )r   r+   r   r   r   s        r   wrong_signature_func_fixturer   $  sP    - 'IHxxzH-rC C (4%%r   c                 v    R p RpRRRR/p\         P                  ! WV/ \        P                  ! 4       4       W3# )z=
Register a scalar function which raises a custom exception.
c                     \        R 4      h)error raised by scalar UDF)r   r   s   &r   raising_func*raising_func_fixture.<locals>.raising_func>  s    233r   
test_raiser   zraising functionr   r   rO   )r   r+   r   s      r   raising_func_fixturer   9  sF    
4I%rC  "BHHJ0""r   c                     R p Rp\         p\        P                  ! WVR\        P                  ! 4       /\        P                  ! 4       4       W3# )z
Register a vector function
c                     \         P                  ! VP                  4       P                  4       P	                  R R7      4      # )T)pct)r
   rp   	to_pandascopyrankr3   s   &&r   pct_rank+unary_vector_func_fixture.<locals>.pct_rankO  s.    xx**,11d1;<<r   y=pct_rank(x)r!   )r&   r'   register_vector_functionr
   r)   )r   r+   r   s      r   unary_vector_func_fixturer   J  sJ    
=  I
CS #RZZ\;346JJLB r   c                 z   R p Rp\         p\        P                  ! WVR\        P                  ! 4       R\        P
                  ! 4       R\        P                  ! 4       /\        P                  ! R\        P                  ! 4       3R\        P
                  ! 4       3R\        P
                  ! 4       3.4      4       W3# )z8
Register a vector function that returns a struct array
c                    \         P                  P                  WV.. ROR7      P                  4       pVP	                  RRR R7      P                  4       p\         P                  P                  V4      P                  4       # )kvrV   names)columnsrb   index)r   r   rV   )r
   RecordBatchfrom_arraysr   pivotreset_indexfrom_pandasto_struct_array)r    r   r   rV   dfdf_pivots   &&&&  r   r   )struct_vector_func_fixture.<locals>.pivot`  sc    ^^''q	'ISSU88C38?KKM~~))(3CCEEr   
y=pivot(x)r   r   rV   v1v2)r&   r'   r   r
   r7   r)   utf8struct)r   r+   r   s      r   struct_vector_func_fixturer   [  s    
F
 I
C#	bhhj#rzz|S"'')<
		C$tRZZ\&:T2::<<PQR r   run_in_datasetTr   c                &   V w  rEVfE   RpV F2  p\        V\        P                  4      '       g   K%  Rp\        V4      pK4  	  V'       d   ^p\        P
                  ! V4      pVP                  V8X  g   Q h\        P                  ! WQVR7      p	V! \        V4      .VO5!  p
W8X  g   Q hV'       d   V UUu. uF
  w  rRV 2NK  	  ppp\        P                  P                  W4      p\        P                  ! V4      pV Uu. uF  p\        P                  ! V4      NK  	  ppVP                  R\        P                  ! R4      P                  VV4      /R7      pVP!                  ^ 4      P"                  ^ ,          V
8X  g   Q hR # R # u uppi u upi )NTFlengthfieldresultr   )r   )
isinstancer
   Arrayr2   r'   get_functionnamerK   r   Tabler   dsdatasetr   to_table_callcolumnchunks)func_fixtureinputsr   r   functionr   
all_scalarargr#   r   expected_outputr   in_arrfield_namestabler   
field_name	func_argsresult_tables   &&$$               r   check_scalar_functionr   p  sa    "NH
C#rxx(("
"3x  L??4 D99d<@F/=GGO$$$ <BCF=5ugFC$$V9**U#<GHKjRXXj)K	H''rxx|11$	BC ( E""1%,,Q/?BBB C Is   6FFc                 t    \        V \        P                  ! ^
^.\        P                  ! 4       4      .4       R# 
   Nr   r
   rp   r7   )unary_func_fixtures   &r   test_udf_array_unaryr     s*    , hhBx<r   c           	          \        V \        P                  ! ^
^.\        P                  ! 4       4      \        P                  ! ^^.\        P                  ! 4       4      .4       R# r   r   )rR   s   &r   test_udf_array_binaryr     sB    - hhBx< hh1vrxxz:r   c           
          \        V \        P                  ! ^
^.\        P                  ! 4       4      \        P                  ! ^^.\        P                  ! 4       4      \        P                  ! ^^
.\        P                  ! 4       4      .4       R# r   r   )r^   s   &r   test_udf_array_ternaryr     sZ    . hhBx< hh1vrxxz: hh2w
;r   c                    \        V \        P                  ! ^^.\        P                  ! 4       4      \        P                  ! ^
^.\        P                  ! 4       4      \        P                  ! ^^.\        P                  ! 4       4      \        P                  ! ^^.\        P                  ! 4       4      \        P                  ! ^^
.\        P                  ! 4       4      .4       R# )   Nr   )rh   s   &r   test_udf_array_varargsr     s    . hh1vrxxz: hhBx< hh1vrxxz: hhBx< hh2w
;r   c            	      0   R RRR/p R\         P                  ! 4       /p\         P                  ! 4       pR p\        P                  ! \        4      ;_uu_ 4        \
        P                  ! VRWV4       RRR4       \        P                  ! \        RR7      ;_uu_ 4        \
        P                  ! RR	WV4       RRR4       R
p\        P                  ! \        VR7      ;_uu_ 4        \
        P                  ! VRWR4       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \
        P                  ! VRV RV4       RRR4       \
        P                  ! VRV / V4       Rp\        P                  ! \        VR7      ;_uu_ 4        \
        P                  ! VRV / V4       RRR4       R#   + '       g   i     ELM; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)r   ztest udf inputr   zparameters are validatedr   c                 0    \         P                  ! ^
.4      # r   )r
   rp   rq   s   &r   test_reg_function3test_registration_errors.<locals>.test_reg_function  s    xx~r   Nzfunc must be a callablematchtest_none_function)DataType expected, got <class 'NoneType'>test_output_functionz)in_types must be a dictionary of DataTypetest_input_functionr   z?Already have a function registered with name: test_reg_function)r
   r7   pytestraises	TypeErrorr'   rP   KeyError)r   r   r   r   expected_exprs        r   test_registration_errorsr     s    	#1C "((*%HxxzH 
y	!	!
##$5$(#$,	. 
" 
y(A	B	B
##D*>$,	. 
C
 @M	y	6	6
##$5$:C$(	* 
7 @M	y	6	6
##$5$93$,	. 
7  1 3S" (*M	x}	5	5
##$5$7b$,	. 
6	5A 
"	!	! 
C	B	B 
7	6 
7	6 
6	5	5s<   F6G
&G.G1H6G	
G	G.	1H	H	c                     V w  rR p\         P                  ! \        VR7      ;_uu_ 4        \        P                  ! V^*.4       RRR4       R#   + '       g   i     R# ; i)z9VarArgs function 'z=ax\+by\+c' needs at least 2 argumentsr   N)r   r   
ValueErrorr'   rK   )rh   _r+   	error_msgs   &   r    test_varargs_function_validationr    s@    'LALI	z	3	3
RD) 
4	3	3	3s   AA	c            	         R \         P                  ! 4       /p \         P                  ! 4       pRR/pR p\        P                  ! \        RR7      ;_uu_ 4        \
        P                  ! VRW V4       RRR4       RR	/p\        P                  ! \        R
R7      ;_uu_ 4        \
        P                  ! VRW V4       RRR4       R#   + '       g   i     L\; i  + '       g   i     R# ; i)r   r   descc                 4    \         P                  ! R V^.4      # r   r   )r    r   s   &&r   	add_const/test_function_doc_validation.<locals>.add_const  s    {33r   z#Function doc must contain a summaryr   test_no_summaryNr   ztest summaryz'Function doc must contain a descriptiontest_no_desc)r
   r7   r   r   r  r'   rP   )r   r   r,   r	  s       r   test_function_doc_validationr    s    "((*%HxxzH 	vH4 
zB
D 
D
##I/@$,$,	.
D 	>H 
zF
H 
H
##I~$,$,	.
H 
H
D 
D
H 
H 
Hs   C"CC	C*	c                 $    \        V . R ^R7       R# )F)r   r   N)r   )rz   s   &r   test_nullary_functionr    s     .5'(*r   c                 l    T p\         P                  ! V. ^R7      pVP                  4       ^*.8X  g   Q hR# )r   r   N)r'   rK   	to_pylist)r   r   r   s   &  r   test_ephemeral_functionr    s4    )DdBq1F"%%%r   c                     V w  r\         P                  ! \        R R7      ;_uu_ 4        \        P                  ! V. ^R7       RRR4       R#   + '       g   i     R# ; i)zUnexpected output type: intr   r   Nr   r   r   r'   rK   )r   r  r+   s   &  r   r   r     sF    1LA	y:
< 
<
Bq1
< 
< 
< 
<   AA	c           	          V w  rR p\         P                  ! \        VR7      ;_uu_ 4        \        P                  ! V\
        P                  ! ^^.4      .4       RRR4       R#   + '       g   i     R# ; i)zDExpected output datatype int16, but function returned datatype int64r   N)r   r   r   r'   rK   r
   rp   )r   r  r+   r   s   &   r   r   r   &  sR    5LA<M 
y	6	6
RXXr2h%7$89 
7	6	6	6s   /A$$A5	c                     V w  rR p\         P                  ! \        VR7      ;_uu_ 4        \        P                  ! V. ^R7       RRR4       R#   + '       g   i     R# ; i)z@wrong_signature\(\) takes 0 positional arguments but 1 was givenr   r   Nr  )r   r  r+   r   s   &   r   r   r   0  sD    /LA'M 
y	6	6
Bq1 
7	6	6	6s   AA 	c            	          R  p RpR\         P                  ! 4       /p/ pRRRR/p\        P                  ! \        RR7      ;_uu_ 4        \
        P                  ! WWBV4       R	R	R	4       R	#   + '       g   i     R	# ; i)
c                     V# r   r   r    rd   s   &&r   identity1test_wrong_datatype_declaration.<locals>.identity;      
r   test_wrong_datatype_declarationrp   r   ztest output valuer   ztest outputz%DataType expected, got <class 'dict'>r   Nr
   r7   r   r   r   r'   rP   r  r+   r   r   r   s        r   r  r  :  s}     2I$HH&}C 
yD
F 
F
##H$'8	=
F 
F 
F 
F   	A,,A=	c            	          R  p RpRR/p\         P                  ! 4       pRRRR/p\        P                  ! \        RR	7      ;_uu_ 4        \
        P                  ! WVW#4       RRR4       R#   + '       g   i     R# ; i)
c                     V# r   r   r  s   &&r   r  3test_wrong_input_type_declaration.<locals>.identityL  r  r   !test_wrong_input_type_declarationrp   Nr   ztest invalid input typer   zinvalid input functionr   r   r  r   s        r   r%  r%  K  s}     4IHxxzH,/C 
yH
J 
J
##H$,	8
J 
J 
J 
Jr!  c                    \         P                  ! \         P                  ! 4       4      pV w  r#\        P                  ! V\         P
                  ! ^.R,          \         P                  ! 4       R7      .VR7      pV\         P
                  ! ^.R,          \         P                  ! 4       R7      8X  g   Q hVP                  4       R8X  g   Q hRpVP                  4       ^ 8X  g   Q hR# )r     r   rH   N@  )r
   proxy_memory_poolr   r'   rK   rp   r7   bytes_allocated)r   
proxy_poolr  r+   ress   &    r   test_scalar_udf_contextr-  \  s    %%b&<&<&>?J%LA


9HHaS4ZbhhjAB'13C "((A3:BHHJ7777%%'8333
C%%'1,,,r   c                     V w  r\         P                  ! \        R R7      ;_uu_ 4        \        P                  ! V. ^R7       RRR4       R#   + '       g   i     R# ; i)r   r   r   N)r   r   r   r'   rK   )r   r  r+   s   &  r   test_raising_funcr/  k  s=    'LA	w&B	C	C
Bq1 
D	C	C	Cr  c                     V w  r\         P                  ! V\        P                  ! ^
4      .4      pV\        P                  ! ^4      8X  g   Q hR# r   )r'   rK   r
   r   )r   r   r+   r,  s   &   r   test_scalar_inputr1  q  s<    ,H


9ryy}o
6C"))B-r   c                    V w  r\         P                  ! \         P                  ! 4       4      pVP                  4       ^ 8X  g   Q h\         P                  ! ^.R,          \         P
                  ! 4       VR7      pVP                  4       R8X  g   Q h\        P                  ! W$.4       VP                  4       R8X  g   Q hRpVP                  4       ^ 8X  g   Q hR# )r   r'  rm   Nr(  )r
   r)  r   r*  rp   r7   r'   rK   )r   r   r+   r+  r   s   &    r   test_input_lifetimer3  w  s    ,H%%b&<&<&>?J%%'1,,,
!t"((**EA%%'8333Y$%%'8333A%%'1,,,r   c           	          \        V4       UUu. uF6  w  r#\        P                  ! \        V4      W,          P                  R 7      NK8  	  ppp\        P
                  P                  W@R7      # u uppi )r   arraysschema)	enumerater
   rp   listrn   r   r   )r7  itersir   r6  s   &*   r   _record_batch_from_itersr<    s[    #E*,*$! hhtAwVY^^4*  ,>>%%V%CC,s   <A.c           	      l    \        V \        W^
,           4      \        V^,           V^,           4      4      # r   )r<  range)r7  ns   &&r   _record_batch_for_ranger@    s/    #F$)!V$4$)!a%R$8: :r   c                    a a VV 3R  lpV# )c                 .   <  ! VV3R  lR4      pV! 4       # )c                   6   <a  ] tR tRt o R tVV3R ltRtV tR# ),make_udt_func.<locals>.udf_func.<locals>.UDTi  c                    R V n         R # r   callerselfs   &r   __init__5make_udt_func.<locals>.udf_func.<locals>.UDT.__init__  s	    "r   c           	       <  V P                   f   S! V4      P                  R uV n         pV P                  V4      pVP                  4       #   \         dk    S Uu. uF%  p\        P                  ! . TP
                  R7      NK'  	  Mu upi pp\        P                  P                  TSR7      p TP                  4       # i ; i)Nr   r5  )	rG  sendStopIterationr
   rp   rn   r   r   r   )rI  r    batchr   r6  	batch_genr7  s   &&   r   __call__5make_udt_func.<locals>.udf_func.<locals>.UDT.__call__  s    6{{*+4S>+>+>(S KK,E ,,.. % 6+13+1% !hhr

;+13F 3NN66%f 7 6E,,..6s   9A C+B)C CrF  Nr   r   r   r   rJ  rQ  r   __classdictcell__)__classdict__rP  r7  s   @r   UDTrD    s     #
/ 
/r   rV  r   )r    rV  rP  r7  s   & r   udf_funcmake_udt_func.<locals>.udf_func  s    	/ 	/ ur   r   )r7  rP  rW  s   ff r   make_udt_funcrY    s    " Or   c                 @   a a \        4       o ! V3R lR4      o V 3R l# )zA short datasetc                   4   <a  ] tR tRt o R tV3R ltRtV tR# )%datasource1_direct.<locals>.Generatori  c                    ^V n         R#    Nr?  rH  s   &r   rJ  .datasource1_direct.<locals>.Generator.__init__  s	    DFr   c                   < V P                   ^ 8X  d   \        S. . 4      pVP                  4       # V ;P                   ^,          un         \        SV P                   4      pVP                  4       # )r   )r?  r<  r@  r   )rI  r    rO  r7  s   && r   rQ  .datasource1_direct.<locals>.Generator.__call__  s[    vv{0R@ ((** !/?((**r   r`  NrS  )rU  r7  s   @r   	Generatorr\    s     		+ 	+r   rd  c                    < S! 4       # r   r   )r    rd  s   &r   <lambda>$datasource1_direct.<locals>.<lambda>  s    y{r   )datasource1_schema)rd  r7  s   @@r   datasource1_directri    s    !F
+ 
+ #"r   c                  <   a \        4       oV3R  lp \        SV 4      # )c              3   b   <"   \        ^^ R4       F  p\        SV^,
          4      x  K  	  R# 5i)r_  N)r>  r@  r    r?  r7  s   & r   rP  (datasource1_generator.<locals>.batch_gen  s)     q!RA)&!a%88 !s   ,/rh  rY  rP  r7  s    @r   datasource1_generatorrq    s    !F9 ++r   c                  <   a \        4       oV3R  lp \        SV 4      # )c              3   t   <"   \        ^^ R4       F  p\        SV^,
          4      x  K  	  \        R4      h5i)r_  datasource1_exceptionrl  )r>  r@  r1   rm  s   & r   rP  (datasource1_exception.<locals>.batch_gen  s7     q!RA)&!a%88 ! 233s   58ro  rp  s    @r   rt  rt    s    !F4
 ++r   c                      \         P                  ! R \         P                  ! 4       3R \         P                  ! 4       3.4      # )r   )r
   r7  r;   r   r   r   rh  rh    s,    99r288:&RXXZ(89::r   c                     R V R2RR/p/ p\         P                  ! R\         P                  ! 4       3R\         P                  ! 4       3.4      pWW#V3# )r   z UDTr   ztest {func_name} UDTr   )r
   r   r;   )r#   r+   r,   r   r   s   &&   r   datasource1_argsrx    sV    i[-57HHyy2rxxz*R,<=>HH88r   c                     \        4       pV ! 4       pV P                  p\        W#4      p\        P                  ! V!   ^p\        P
                  ! V4       F  pV^,          pV\        W4      8X  d   K  Q h	  R# r^  )rh  r   rx  r'   register_tabular_functioncall_tabular_functionr@  )
func_makerr7  r#   r+   r   r?  items   &      r   _test_datasource1_udtr~    sk    !F<D##I 1I  ),	A((3	Q.v9999 4r   c                  $    \        \        4       R # r   )r~  ri  r   r   r   test_udt_datasource1_directr    s    ,-r   c                  $    \        \        4       R # r   )r~  rq  r   r   r   test_udt_datasource1_generatorr    s    /0r   c                      \         P                  ! \        R R7      ;_uu_ 4        \        \        4       RRR4       R#   + '       g   i     R# ; i)rt  r   N)r   r   r1   r~  rt  r   r   r   test_udt_datasource1_exceptionr    s-    	|+B	C	C34 
D	C	C	Cs	   ?A	c                     \         P                  ! . RO\         P                  ! 4       4      p\        P                  ! RV.4      p\         P
                  ! R4      pW#8X  g   Q hR# )      $@      >@mean_udfNr  g      4@r  g      D@g      I@)r
   rp   r)   r'   rK   r   )unary_agg_func_fixturearrr   expecteds   &   r   test_scalar_agg_basicr    sF    
((12::<
@Cj3%0FyyHr   c                     \         P                  ! . \         P                  ! 4       4      p\        P                  ! \         P
                  R R7      ;_uu_ 4        \        P                  ! RV.4       RRR4       R#   + '       g   i     R# ; i)zempty inputsr   r  N)r
   rp   r)   r   r   ArrowInvalidr'   rK   )r  emptys   & r   test_scalar_agg_emptyr    sN    HHR&E	rn	=	=
eW- 
>	=	=	=s   A<<B	c                 $   \         P                  ! . RO\         P                  ! 4       4      p\        P                  ! \         P
                  RR7      ;_uu_ 4        \        P                  ! RV.4       RRR4       R#   + '       g   i     R# ; i)r   output datatyper   r=   Nr         (   2   r
   rp   r7   r   r   ArrowTypeErrorr'   rK   )r?   r  s   & r   "test_scalar_agg_wrong_output_dtyper    sT    
(('
4C	r((0A	B	B
2SE: 
C	B	B	B   A>>B	c                 $   \         P                  ! . RO\         P                  ! 4       4      p\        P                  ! \         P
                  RR7      ;_uu_ 4        \        P                  ! RV.4       RRR4       R#   + '       g   i     R# ; i)r   output typer   rC   Nr  r  )rD   r  s   & r   !test_scalar_agg_wrong_output_typer  	  sR    
(('
4C	r((	>	>
1C59 
?	>	>	>r  c                 "   \         P                  ! . RO\         P                  ! 4       4      p\         P                  ! . RO\         P                  ! 4       4      p\        P
                  ! RW.4      p\         P                  ! R4      pW48X  g   Q hR# )r   sum_meang     @@Nr  )      ?       @      @      @g      @)r
   rp   r7   r)   r'   rK   r   )varargs_agg_func_fixturearr1arr2r   r  s   &    r   test_scalar_agg_varargsr    sb    88("((*5D88-rzz|<DTLF yyHr   c                    \         P                  ! . RO\         P                  ! 4       4      p\        P                  ! \
        RR7      ;_uu_ 4        \        P                  ! RV.4       RRR4       R#   + '       g   i     R# ; i)r   r0   r   r5   N)r   r  r  r  r  <   )r
   rp   r7   r   r   r1   r'   rK   )r8   r  s   & r   test_scalar_agg_exceptionr    sL    
((+RXXZ
8C	|6	2	2
-u5 
3	2	2	2s   A44B	c                    \         P                  ! . RO\         P                  ! 4       4      p\         P                  ! . RO\         P                  ! 4       4      p\         P                  ! . RO\         P                  ! 4       4      p\         P                  ! . R	O\         P                  ! 4       4      p\         P                  ! W!.RR.R7      p\         P                  ! WC.RR.R7      p\         P
                  ! WV.4      pVP                  R4      P                  R
.4      pVP                  R4      P                  R.4      P                  RR.4      p	VP                  R4      V	P                  R4      8X  g   Q hR# )r  idvaluer   value_mean_udfNr     r   r   r   r   )g      N@g     Q@g      T@g     V@g      Y@)   r   r   r  r   r  r  )r  mean)
r
   rp   r)   r;   r   concat_tablesgroup_by	aggregaterename_columnssort_by)
r  r  r  arr3arr4table1table2r   r   r  s
   &         r   test_hash_agg_basicr  #  s   882BJJLAD88ORXXZ0D883RZZ\BD88ORXXZ0DXXtl4/:FXXtl4/:Ff-.E^^D!++-B,CDF~~d#--	+^T3C,DE  >>$8#3#3D#9999r   c                    \         P                  ! . \         P                  ! 4       4      p\         P                  ! . \         P                  ! 4       4      p\         P                  ! W!.R R.R7      pVP                  R 4      P                  R.4      p\         P                  ! \         P                  ! . \         P                  ! 4       4      \         P                  ! . \         P                  ! 4       4      .R R.R7      pWE8X  g   Q hR# )r  r  r   r  Nr  )r
   rp   r)   r;   r   r  r  )r  r  r  r   r   r  s   &     r   test_hash_agg_emptyr  6  s    88B

%D88B
#DHHd\$9E^^D!++-B,CDFxx"bhhj1288
BJJL4 #')9":<H r   c                    \         P                  ! . RO\         P                  ! 4       4      p\         P                  ! . RO\         P                  ! 4       4      p\         P                  ! W!.RR.R7      p\
        P                  ! \         P                  RR7      ;_uu_ 4        VP                  R4      P                  R	.4       RRR4       R#   + '       g   i     R# ; i)
r   r  r  r   r  r   Nr  r  )r  r=   
r
   rp   r7   r;   r   r   r   r  r  r  )r?   r  r  r   s   &   r    test_hash_agg_wrong_output_dtyper  C  s    88("((*5D88ORXXZ0DHHd\$9E	r((0A	B	Bt&&(L'MN 
C	B	B	B   ""CC	c                    \         P                  ! . RO\         P                  ! 4       4      p\         P                  ! . RO\         P                  ! 4       4      p\         P                  ! W!.RR.R7      p\
        P                  ! \         P                  RR7      ;_uu_ 4        VP                  R4      P                  R	.4       RRR4       R#   + '       g   i     R# ; i)
r   r  r  r   r  r   Nr  r  )r  rC   r  )rD   r  r  r   s   &   r   test_hash_agg_wrong_output_typer  L  s    88("((*5D88ORXXZ0DHHd\$9E	r((	>	>t&&(K'LM 
?	>	>	>r  c                    \         P                  ! . RO\         P                  ! 4       4      p\         P                  ! . RO\         P                  ! 4       4      p\         P                  ! W!.RR.R7      p\
        P                  ! \        RR7      ;_uu_ 4        VP                  R4      P                  R	.4       RRR4       R#   + '       g   i     R# ; i)
r   r  r  r   r0   r   Nr  r  )r  r5   )
r
   rp   r7   r;   r   r   r   r1   r  r  )r8   r  r  r   s   &   r   test_hash_agg_exceptionr  U  s    88("((*5D88ORXXZ0DHHd\$9E	|6	2	2t&&(G'HI 
3	2	2	2s   "CC	c                D   RpRp\         P                  ! \        P                  ! ^V4      \         P                  ! 4       4      p\         P                  ! \        P
                  P                  W!4      \         P                  ! 4       4      p\         P                  ! WC.RR.R7      pVP                  R4      P                  R.4      pVP                  R4      P                  R	.4      P                  RR.4      pVP                  R4      VP                  R4      8X  g   Q hR# )
z2Test hash aggregate udf with randomly sampled datai@B r'  r  r  r   value_sum_udfN)r  r%   )r  sum)r
   rp   r   repeatr)   randomchoicer;   r   r  r  r  r  )r-   	value_num	group_numr  r  r   r   r  s   &       r   test_hash_agg_randomr  _  s     II88BIIa+RZZ\:D88BII$$Y:BHHJGDHHd\$9E^^D!++-A,BCF~~d#--	*ND/+BC  >>$8#3#3D#9999r   c                     \         P                  ! . RO\         P                  ! 4       4      p\        P                  ! RV.4      pV ^ ,          ! RV4      pW#8X  g   Q hR# )r  r   Nr  r
   rp   r)   r'   rK   r   r  r   r  s   &   r   test_vector_basicr  r  sJ    
((12::<
@Cou5F(+D#6Hr   c                     \         P                  ! ^.\         P                  ! 4       4      p\        P                  ! RV.4      pV ^ ,          ! RV4      pW#8X  g   Q hR# )r   r   Nr  r  s   &   r   test_vector_emptyr  z  sK    
((A3


%Cou5F(+D#6Hr   c                 J   \         P                  ! . RO\         P                  ! 4       4      p\         P                  ! . RO\         P                  ! 4       4      p\         P                  ! . RO4      p\        P
                  ! RWV.4      pV ^ ,          ! RWV4      pWE8X  g   Q hR# )r   r   N)r   r   r   r   )r  r  r  r  )r   r   r   r   )r
   rp   r7   r)   r'   rK   )r   r   r   rV   r   r  s   &     r   test_vector_structr    s    
bhhj	A 	bjjl	A 	 	A lQ1I6F)!,T1;Hr   r   )r   )Pr   numpyr   ImportErrorpyarrowr
   r   r'   markr   
pytestmarkr&   pyarrow.datasetr   r   r1   r   fixturer-   r8   r?   rD   rR   r^   rh   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r   r   r   r  r%  r-  r/  r1  r3  r<  r@  rY  ri  rq  rt  rh  rx  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  pandasr  r  r  r   r   r   <module>r     sI  &   ! [[  
 Br2 
D
	l 	 i  !* i  !& i  !$ i  !$ i & !&( i ' !'0 i ' !'2 i # !#, i  !0 i ( !(( i , !,( i & !&( i # !#  i  !  i  !(C)-C (,C@	/.d*.>*&2:2="8"-2 -D:*#$,,;9	:.15
   . .;:   6 6 : :$ 	 	ON J J : :$      Y  	B  	Bs"   M' M7 '	M43M47	NN