
    ch!?                     ,   S SK JrJrJr  S SKJrJr   S SKJrJ	r	J
r
JrJrJrJrJrJr   S SKJr  S SKJr  SS jrSSS
S\S4S jrS
\4S jrS r\4S jrSS jrg! \ a  r\" S\" \5       S35      SeSrCff = f! \ a     " S S	5      r\r N[f = f)    )TableRecordBatcharray)
Expressionfield)	DeclarationExecNodeOptionsTableSourceNodeOptionsFilterNodeOptionsProjectNodeOptionsAggregateNodeOptionsOrderByNodeOptionsHashJoinNodeOptionsAsofJoinNodeOptionsz@The pyarrow installation is not built with support for 'acero' ()N)ScanNodeOptionsc                   <    \ rS rSr " S S5      r " S S5      rSrg)DatasetModuleStub2   c                       \ rS rSrSrg)DatasetModuleStub.Dataset3    N__name__
__module____qualname____firstlineno____static_attributes__r       `C:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\pyarrow/acero.pyDatasetr   3       r    r"   c                       \ rS rSrSrg)!DatasetModuleStub.InMemoryDataset6   r   Nr   r   r    r!   InMemoryDatasetr%   6   r#   r    r'   r   N)r   r   r   r   r"   r'   r   r   r    r!   r   r   2   s    	 		 	r    r   TFc           	      ~   [        S[        XUS95      nU R                  R                   Vs/ s H  n[	        U5      PM     nn[         R
                  " U[        S[        U5      5      /5      nU R                  R                  S5      nUb+  [         R
                  " U[        S[        U5      5      /5      nU$ s  snf )Nscanuse_threadsimplicit_orderingprojectfilter)
r   r   schemanamesr   from_sequencer   _scan_optionsgetr   )datasetr+   r,   declfprojectionsfilter_exprs          r!   _dataset_to_declr9   ;   s    v+ - .D &-^^%9%9:%958%9K:$$	{9&8&EFGD ''++H5K ((;x):;)GHI
 K ;s   B:c                    [        U[        [        R                  45      (       d  [	        S[        U5       35      e[        U[        [        R                  45      (       d  [	        S[        U5       35      e0 n[        U[        [        45      (       d  U/n[        U5       H	  u  pXU'   M     0 n[        U[        [        45      (       d  U/n[        U5       H	  u  pXU'   M     UR                  R                  nUR                  R                  nU S:X  d  U S:X  a  / nOVU S:X  d  U S:X  a  / nOGU S:X  d  U S:X  a  U Vs/ s H  nUU;  d  M  UPM     nnO U S:X  a  U Vs/ s H  nUU;  d  M  UPM     nn0 n[        U5       H  u  nnUU;   d  M  UUU'   M     0 n[        U5       H  u  nnUU;   d  M  UUU'   M     [        U[        R                  5      (       a
  [        XS	9nO[        S
[        U5      5      n[        U[        R                  5      (       a
  [        X7S	9nO[        S
[        U5      5      nU(       a!  [        XXOUU=(       d    SU=(       d    SU
S9nO[        XUU=(       d    SU=(       d    SU
S9n[        SUUU/S9nU(       Gam  U S:X  Gaf  [        U5      n[        U5      n[!        U5      n/ n/ n[        UU-   5       GH   u  nnU[!        U5      :  av  UU;   ap  UR#                  U5        UXKU         nUR#                  [$        R&                  " S[$        R(                  " U5      [$        R(                  " UU-   5      /5      5        M  UU:  a  UU;   a  M  U(       a  UU:  a  UU;   a  UU-  nU(       a  UU:  a  UU;   a  UU-  nUR#                  U5        UR#                  [$        R(                  " U5      5        GM     [        S[+        UU5      5      n[        R,                  " UU/5      nUR/                  US	9n U	[        :X  a  U $ U	[        R0                  :X  a  [        R0                  " U 5      $ [	        S5      es  snf s  snf )aE  
Perform join of two tables or datasets.

The result will be an output table with the result of the join operation

Parameters
----------
join_type : str
    One of supported join types.
left_operand : Table or Dataset
    The left operand for the join operation.
left_keys : str or list[str]
    The left key (or keys) on which the join operation should be performed.
right_operand : Table or Dataset
    The right operand for the join operation.
right_keys : str or list[str]
    The right key (or keys) on which the join operation should be performed.
left_suffix : str, default None
    Which suffix to add to left column names. This prevents confusion
    when the columns in left and right operands have colliding names.
right_suffix : str, default None
    Which suffix to add to the right column names. This prevents confusion
    when the columns in left and right operands have colliding names.
use_threads : bool, default True
    Whether to use multithreading or not.
coalesce_keys : bool, default False
    If the duplicated keys should be omitted from one of the sides
    in the join result.
output_type: Table or InMemoryDataset
    The output type for the exec plan result.
filter_expression : pyarrow.compute.Expression
    Residual filter which is applied to matching row.

Returns
-------
result_table : Table or InMemoryDataset
Expected Table or Dataset, got z	left semiz	left antiz
right semiz
right antiinnerz
left outerzright outerr+   table_source )output_suffix_for_leftoutput_suffix_for_rightfilter_expressionhashjoinoptionsinputsz
full outercoalescer-   Unsupported output type)
isinstancer   dsr"   	TypeErrortypetuplelist	enumerater/   r0   r9   r   r
   r   setlenappendr   _call_fieldr   r1   to_tabler'   )!	join_typeleft_operand	left_keysright_operand
right_keysleft_suffixright_suffixr+   coalesce_keysoutput_typerB   left_keys_orderidxkeyright_keys_orderleft_columnsright_columnscolleft_column_keys_indicescolnameright_column_keys_indicesleft_sourceright_source	join_optsr5   left_columns_setright_columns_setright_operand_indexprojected_col_namesr7   right_key_index
projectionresult_tables!                                    r!   _perform_joinrs   R   s}   T lUBJJ$7889$|:L9MNOOmeRZZ%8999$}:M9NOPP Oi%//K	i(" ) j4-00 \
j) # *  &&,,L!((..M K9#;	l	"i<&?	g	l!:(
(CC7G,GC= 	 
 
m	#'
'C3o+EC< 	 
  "!,/Wi03$W- 0 !#!-0Wj 14%g. 1
 ,

++&|M!.2H2VW-,,'O"2=A
 '*M#.#4"$0$6B/	
	 (*#.#4"$0$6B/	
	 I{L.ID l2 |,.!,/ !,">?HCS&&32J+J#**3/
 #<s34#6""$$Z"))#.
0A0A/?1A2  ++7P0P  C*=$=00;&C S,?%?//<'C#**3/""%%c*E @J !)+7JK

 (($
);<==[=9Le	**	*!!,//122Y

s   
QQ$
Q2Qc	                 (   [        U [        [        R                  45      (       d  [	        S[        U 5       35      e[        U[        [        R                  45      (       d  [	        S[        U5       35      e[        U[        [        45      (       d  U/n[        U[        [        45      (       d  U/nUR                  R                   V	s/ s H  n	X/U-   ;  d  M  U	PM     n
n	[        U R                  R                  5      [        U
5      -  nU(       a  [        SU S35      e[        U [        R                  5      (       a  [        U USS9nO[        S[        U 5      5      n[        U[        R                  5      (       a  [        X7SS9nO[        S[        U5      5      n[        XXEU5      n[        SXU/S9nUR!                  US	9nU[        :X  a  U$ U[        R"                  :X  a  [        R"                  " U5      $ [	        S
5      es  sn	f )a  
Perform asof join of two tables or datasets.

The result will be an output table with the result of the join operation

Parameters
----------
left_operand : Table or Dataset
    The left operand for the join operation.
left_on : str
    The left key (or keys) on which the join operation should be performed.
left_by: str or list[str]
    The left key (or keys) on which the join operation should be performed.
right_operand : Table or Dataset
    The right operand for the join operation.
right_on : str or list[str]
    The right key (or keys) on which the join operation should be performed.
right_by: str or list[str]
    The right key (or keys) on which the join operation should be performed.
tolerance : int
    The tolerance to use for the asof join. The tolerance is interpreted in
    the same units as the "on" key.
output_type: Table or InMemoryDataset
    The output type for the exec plan result.

Returns
-------
result_table : Table or InMemoryDataset
r;   zColumns zE present in both tables. AsofJoin does not support column collisions.Tr*   r>   asofjoinrD   r=   rH   )rI   r   rJ   r"   rK   rL   rM   rN   r/   r0   rP   
ValueErrorr9   r   r
   r   rU   r'   )rW   left_onleft_byrY   right_onright_by	tolerancer+   r^   re   rd   columns_collisionsri   rj   rk   r5   rr   s                    r!   _perform_join_asofr}     s   B lUBJJ$7889$|:L9MNOOmeRZZ%8999$}:M9NOPPgt}--)h..: %++111j8++ 	1   \00667#m:LL)* +; ;
 	
 ,

++&#"$
 "2<@
 -,,'"$ #2=A
 $(iI IL.ID ==[=9Le	**	*!!,//122Ys   HHc           	         Sn[        U [        5      (       a  [        R                  " U /5      n Sn[        R
                  " [	        S[        U 5      S9[	        S[        U5      S9/5      nUR                  SS9nU(       a  UR                  S:  a#  UR                  5       R                  5       S   nU$ UR                   Vs/ s H  n[        / UR                  S9PM     nn[        R                  " XdR                  S	9nU$ s  snf )
a\  Filter rows of a table based on the provided expression.

The result will be an output table with only the rows matching
the provided expression.

Parameters
----------
table : Table or RecordBatch
    Table that should be filtered.
expression : Expression
    The expression on which rows should be filtered.

Returns
-------
Table or RecordBatch
FTr>   )rE   r.   r=   r   )rL   )r/   )rI   r   r   from_batchesr   r1   r
   r   rU   num_rowscombine_chunks
to_batchesr/   r   rL   from_arrays)table
expressionis_batchr5   resultr   arrayss          r!   _filter_tabler   b  s    " H%%%""E7+$$N,B5,IJH&7
&CD& D ]]t],F??Q**,779!<F M ?EmmLmUeBUZZ0mFL ,,VMMJFM Ms   Dc                 z   [        U [        R                  5      (       a  [        U SS9nO[	        S[        U 5      5      n[	        S[        U40 UD65      n[        R                  " XE/5      nUR                  SS9nU[        :X  a  U$ U[        R                  :X  a  [        R                  " U5      $ [        S5      e)NTr=   r>   order_byrH   )rI   rJ   r"   r9   r   r
   r   r1   rU   r   r'   rK   )table_or_dataset	sort_keysr^   kwargsdata_sourcer   r5   rr   s           r!   _sort_sourcer     s    "BJJ//&'7TJ!23CD
 :'9)'Nv'NOH$$k%<=D==T=2Le	**	*!!,//122r    c                     [         R                  " [        S[        U 5      5      [        S[        XS95      /5      nUR	                  US9$ )Nr>   	aggregate)keysr=   )r   r1   r
   r   rU   )r   
aggregatesr   r+   r5   s        r!   	_group_byr     sJ    $$N$:5$ABK!5j!LM& D ==[=11r    )TF)T) pyarrow.libr   r   r   pyarrow.computer   r   pyarrow._aceror   r	   r
   r   r   r   r   r   r   ImportErrorexcstrpyarrow.datasetr4   rJ   pyarrow._datasetr   r   r9   rs   r}   r   r   r   r   r    r!   <module>r      s   2 2 1 -
 
 
"
 02 #"%#t	r3n /3#(X3v!H ;@ 3,2i  

J3s8*TUV    
Bs(   A A> A;#A66A;>BB