K i=ddlZddlZddlZejj dZejj dZejj dZejj dZ ejjddZ ejj d Z ejj d Z ejj d Zejj d Zejj d Zejj dZejj dZy)Nc<ddlm}|j}tjdtj }tjdtj }tj ||g}tjdtj }|j|}|j|}|j|jk(sJ|jd||gtj}|j|||tj } |j| |} | jjtj k(sJ|jd} |j!|| gtj"d| } | j$j'd d k7sJtj(gd tj } tj(gd tj }tj(gdtj }tj*j-| |gddg}| j/|\}|j1|sJy)Nrabres greater_thanTdump_irNONE@expr_) type)rr)r rrrnames)pyarrow.gandivagandivaTreeExprBuilderpafieldint32schema make_field return_typer make_functionbool_make_ifmake_expressionresult Configurationmake_projectordefault_memory_poolllvm_irfindarray RecordBatch from_arraysevaluateequals)rbuilderfield_afield_br field_resultnode_anode_b conditionif_nodeexprconfig projectorrre input_batchrs `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pyarrow/tests/test_gandiva.pytest_tree_exp_builderr>s%%%'GhhsBHHJ'GhhsBHHJ'G YY) *F88E288:.L    (F    (F    7<< // /%%nvv6F&(hhj2IooiDG  " "7L 9D ;;=   ++ +  " "4 " 0F&&..0&&BI    ! !( +r 11 1 ! 3A rxxz2A ! 3A..,,aVC:,FK   K (BA 88A;;c2ddlm}tjj tj ddgtj ddggddg}|j }|j|jjd}|j|jjd}|jd||gtj}tjd tj}|j||}|j|j|gtj}|j|j!d\} tj dd g} | j#| sJy) Nr?@@g@rraddcg@)rrrTabler,r*rrrrr float64r#r&r'r- to_batchesr.) rtabler/r3r4sumr2r7r9r<r:s r= test_tablerKBs@% HH "((C:"6#s8L!M"%s -E%%'G    2 23 7 8F    2 23 7 8F   '7 FC88C.L  " "3 5D&& tfb4468I   E,,.q1 2BA #sA 88A;;r?c ddlm}tjj tj t dDcgc]}d|z c}gdg}|j}|j|jjd}|jdtj}|jd||gtj}|j|}|j!j"tjk(sJ|j%d}|j'|j||} | j(j+d d k7sJ| j-|j/dtj0} | j3j5tj t d tj6 sJycc}w) Nri'rArg@@ less_thanTrr r ir)rrrrFr,r*rangerrrr make_literalrGr r!make_conditionr$rr% make_filterr(r)r-rHr'to_arrayr.uint32) rirIr/r3thousandcondr5r8filterr$s r= test_filterrX]s}% HH "((U5\+JC!G+J"K!L"% (E%%'G    2 23 7 8F##FBJJL9H  vx.@"((* MD&&t,I     " "bhhj 00 0  " "4 " 0F  y& AF >>  x (B .. . __U--/2B4J4J4L MF ??  # #BHHU4[ryy{$K LL L#,Ks G3 cddlm}tjgd}tjj |gdg}|j }|j|jjd}|j|ddgtj}|j|}|j|j|}|j|jdtj }|j#j%tjddgtj&sJtjgd }tjj |j)tj*gdg}|j|jjd}|j|dd gtj*}|j|}|j|j|}|j|jdtj }|j#j%tjgd tj&sJtjgd }tjj |gdg}|j|jjd}|j|dd gtj,}|j|}|j|j|}|j|jdtj }|j#j%tjgd tj&sJy) Nr)gaannddiivvarr[r\r) r`r`r rarrcr)r`rbrc)rrrr*rFr,rrrrmake_in_expressionstringrPrQr-rHr'rRr.rScastrint64) rarrrIr/r3rVr5rWr$s r= test_in_exprrlus% ((7 8C HH # .E%%'G    2 23 7 8F  % %ftTlBIIK HD&&t,I  y 9F __U--/2B4J4J4L MF ??  # #BHHaV"))+$F GG G ((1 2C HH #((288:"6!7# ?E    2 23 7 8F  % %fq!fbhhj AD&&t,I  y 9F __U--/2B4J4J4L MF ??  # #BHH\ $L MM M ((1 2C HH # .E    2 23 7 8F  % %fq!fbhhj AD&&t,I  y 9F __U--/2B4J4J4L MF ??  # #BHH\ $L MM Mr?z>Gandiva C++ did not have *real* binary, time and date support.)reasonc ddlm}tjgd}tjj |gdg}|j }|j|jjd}|j|ddgtj}|j|}|j|j|}|j|jdtj }|j#j%tjddgtj&sJt(j(j+d } t(j(j+d } t(j(j+d } tj| | | g}tjj |gdg}|j }|j|jjd}|j|| gtj,d }|j|}|j|j|}|j|jdtj }t/|j#dgk(sJ| j1} | j1} | j1}tj| | |g}tjj |gdg}|j }|j|jjd}|j|| gtj2d }|j|}|j|j|}|j|jdtj }t/|j#dgk(sJ| j5}| j5}| j5}tj|||g}tjj |gdg}|j }|j|jjd}|j||gtj6}|j|}|j|j|}|j|jdtj }t/|j#dgk(sJy) Nr)sgaanndsdisivsvarrorpr`rarg,Ag,Ag+Ams)rrrr*rFr,rrrrrgbinaryrPrQr-rHr'rRr.rSdatetimeutcfromtimestamp timestamplisttimetime64datedate32)rrkrIr/r3rVr5rWr$ datetime_1 datetime_2 datetime_3time_1time_2time_3date_1date_2date_3s r=test_in_expr_todors5& ((= >C HH # .E%%'G    2 23 7 8F  % %fuenbiik JD&&t,I  y 9F __U--/2B4J4J4L MF ??  # #BHHaV"))+$F GG G""334EFJ""334EFJ""334EFJ ((J J7 8C HH # .E%%'G    2 23 7 8F  % %fzlBLLFF3C#%88:/F  " ";0@"((* MF ??G,,ff-=>G HD&&t,I  y 9F __U--/2B4J4J4L MF ??  # #BHHYRYY[$I JJ Jr?cddlm}|j}|jdt j |jdt j |jdt j|jdt j|jdt j|jdt j|jdt j|jdt j|jd t j|jd t j|jd t j|jd t j |jd t j"|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jd d|jd d|jd d|jd d|jd dt%j&t(5|jd t jdddt%j&t(5|jdddddy#1swY>xYw#1swYyxYw)NrTr`rarbrcrreg @g"@hellosworldbooluint8uint16rSuint64int8int16rrjfloat32rGrhrr)rrrrOrr!rrrSrrrrrjrrGrhrrpytestraises TypeError)rr/s r= test_literalsrsn%%%'G rxxz* BHHJ' BIIK( BIIK( BIIK( BGGI& BHHJ' BHHJ' BHHJ' bjjl+ bjjl+ "))+. 299;/ v& G$ H% H% H% F# G$ G$ G$ i( i( (+ 8, y !2Wbhhj12 y !)T4())22))s.%M4MMM%cRddlm}gd}tj|tj}tj j |gdg}|j}|j|jjd}|jdtj}|jd||gtj}tjdtj}|j||} |j|j| gtj } | j#|j%d\} tjgd tj} | j'| sJy) Nr)parksparklezbright spark and firesparkrrrz%spark%liker)FTTT)rrrr*rhrFr,rrrrrOr r!r#r&r'r-rHr.) relementsdatarIr/r3regexrr2r7r9r<rs r= test_regexr's7%DH 88H299; /D HH $u 5E%%'G    2 23 7 8F  BIIK 8E  &%"((* ED88C,L  " "4 6D&& tfb4468I   E,,.q1 2BA * Loo/$fbhhj:G  " "7L 9D /? @F&& tfeX/Iu'7'7'9!'288: .C 88C==r?c ddlm}|j}t|j dt j jdsJt|j dt jdk(sJt|jt jdt j dk(sJt|jt jdt jd k(sJ|jt jd t j}|jd |gt j}t|d k(sJ|jt jdt j}|j||g}t|d k(sJy)NrrBz(const double) 2 raw(raz(const int64) 2xz (double) xyz (string) yznotzbool not((bool) z)zbool not((bool) z) && (bool) y)rrrstrrOrrG startswithrjrrrhr!r r)rr/field_z func_nodefield_yand_nodes r=test_to_stringrxsh%%%'G w##C6 34 55 5 w##Arxxz2 37H HH H w!!"((3 "=> ?< OO O w!!"((3 "<= >, NN N  #rxxz!:;G%%egY CI y>1 11 1  #rxxz!:;GG 45H x=< << rKrXrlskiprrrrrrrrr?r=rs$ &&R4MM.!N!NH23E*3E*PKK4$)$)N.**++\==&%*%*r?