§
    !P„j=  ã                   ó6  — d dl mZmZmZ d dlmZmZ 	 d dlmZm	Z	m
Z
mZmZmZmZmZmZ n&# e$ rZ ed ee¦  «        › d�¦  «        d‚dZ[ww xY w	 d dlmZ d dlmZ n# e$ r  G d„ d	¦  «        ZeZY nw xY wdd„Zddd
dedfd„Zd
efd„Zd„ Zefd„Zdd„ZdS )é    )Ú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                   óB   — e Zd Z G d„ d¦  «        Z G d„ d¦  «        ZdS )ÚDatasetModuleStubc                   ó   — e Zd ZdS )úDatasetModuleStub.DatasetN©Ú__name__Ú
__module__Ú__qualname__© ó    úR/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/pyarrow/acero.pyÚDatasetr   3   ó   € € € € € ØˆDr   r   c                   ó   — e Zd ZdS )ú!DatasetModuleStub.InMemoryDatasetNr   r   r   r   ÚInMemoryDatasetr!   6   r   r   r"   N)r   r   r   r   r"   r   r   r   r   r   2   sd   € € € € € ð	ð 	ð 	ð 	ð 	ñ 	ô 	ð 	ð	ð 	ð 	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	r   r   TFc           	      ón  — t          dt          | ||¬¦  «        ¦  «        }d„ | j        j        D ¦   «         }t          j        |t          dt          |¦  «        ¦  «        g¦  «        }| j                             d¦  «        }|�1t          j        |t          dt          |¦  «        ¦  «        g¦  «        }|S )NÚscan©Úuse_threadsÚimplicit_orderingc                 ó,   — g | ]}t          |¦  «        ‘ŒS r   )r   )Ú.0Úfs     r   ú
<listcomp>z$_dataset_to_decl.<locals>.<listcomp>B   s   € Ð:Ð:Ð: •5˜‘8”8Ð:Ð:Ð:r   ÚprojectÚfilter)	r   r   ÚschemaÚnamesÚfrom_sequencer   Ú_scan_optionsÚgetr   )Údatasetr&   r'   ÚdeclÚprojectionsÚfilter_exprs         r   Ú_dataset_to_declr7   ;   sÇ   € Ý�v�Ø˜[Ø+ð -ñ  -ô  -ñ .ô .€Dð ;Ð: W¤^Ô%9Ð:Ñ:Ô:€KÝÔ$Ø	�{˜9Õ&8¸Ñ&EÔ&EÑFÔFÐGñô €Dð Ô'×+Ò+¨HÑ5Ô5€KØÐõ Ô(Ø•;˜xÕ):¸;Ñ)GÔ)GÑHÔHÐIñ
ô 
ˆð €Kr   c                 óª  ‡‡ — t          |t          t          j        f¦  «        st	          dt          |¦  «        › �¦  «        ‚t          |t          t          j        f¦  «        st	          dt          |¦  «        › �¦  «        ‚i Št          |t          t          f¦  «        s|g}t          |¦  «        D ]
\  }}|‰|<   Œi Š t          |t          t          f¦  «        s|g}t          |¦  «        D ]
\  }}|‰ |<   Œ|j	        j
        }|j	        j
        }| dk    s| dk    rg }n>| dk    s| dk    rg }n/| dk    s| dk    rˆ fd„|D ¦   «         }n| d	k    rˆfd
„|D ¦   «         }i }t          |¦  «        D ]\  }}||v r|||<   Œi }t          |¦  «        D ]\  }}||v r|||<   Œt          |t          j        ¦  «        rt          ||¬¦  «        }nt          dt          |¦  «        ¦  «        }t          |t          j        ¦  «        rt          ||¬¦  «        }nt          dt          |¦  «        ¦  «        }|rt          | |||||pd|pd|
¬¦  «        }nt          | |||pd|pd|
¬¦  «        }t          d|||g¬¦  «        }|�r�| dk    �rzt          |¦  «        }t          |¦  «        }t!          |¦  «        }g }g }t          ||z   ¦  «        D �]\  }}|t!          |¦  «        k     r||v r{|                     |¦  «         ||‰|                           }|                     t%          j        dt%          j        |¦  «        t%          j        ||z   ¦  «        g¦  «        ¦  «         Œ˜||k    r||v rŒ£|r||k     r	||v r||z  }|r||k    r	||v r||z  }|                     |¦  «         |                     t%          j        |¦  «        ¦  «         �Œt          dt+          ||¦  «        ¦  «        }t          j        ||g¦  «        }|                     |¬¦  «        }|	t          k    r|S |	t          j        k    rt          j        |¦  «        S t	          d¦  «        ‚)aÉ  
    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 outerc                 ó   •— g | ]}|‰v¯|‘Œ	S r   r   )r)   ÚcolÚright_keys_orders     €r   r+   z!_perform_join.<locals>.<listcomp>˜   s+   ø€ ð 
ð 
ð 
Ø¨CÐ7GÐ,GÐ,GˆCÐ,GÐ,GÐ,Gr   zright outerc                 ó   •— g | ]}|‰v¯|‘Œ	S r   r   )r)   r<   Úleft_keys_orders     €r   r+   z!_perform_join.<locals>.<listcomp>œ   s*   ø€ ð 
ð 
ð 
Ø¨3°oÐ+EÐ+EˆCÐ+EÐ+EÐ+Er   ©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.   r/   r7   r   r
   r   ÚsetÚlenÚappendr   Ú_callÚ_fieldr   r0   Úto_tabler"   )!Ú	join_typeÚleft_operandÚ	left_keysÚright_operandÚ
right_keysÚleft_suffixÚright_suffixr&   Úcoalesce_keysÚoutput_typerE   ÚidxÚkeyÚleft_columnsÚright_columnsÚleft_column_keys_indicesÚcolnameÚright_column_keys_indicesÚleft_sourceÚright_sourceÚ	join_optsr4   Úleft_columns_setÚright_columns_setÚright_operand_indexÚprojected_col_namesr5   r<   Úright_key_indexÚ
projectionÚresult_tabler?   r=   s!                                  @@r   Ú_perform_joinrs   R   s®  øø€ õT �l¥U­B¬JÐ$7Ñ8Ô8ð PÝÐN½$¸|Ñ:LÔ:LÐNÐNÑOÔOÐOÝ�m¥e­R¬ZÐ%8Ñ9Ô9ð QÝÐO½$¸}Ñ:MÔ:MÐOÐOÑPÔPÐPð €OÝ�i¥%­ Ñ/Ô/ð  Ø�Kˆ	Ý˜iÑ(Ô(ð #ð #‰ˆˆSØ"ˆ˜ÑÐàÐÝ�j¥4­ -Ñ0Ô0ð "Ø �\ˆ
Ý˜jÑ)Ô)ð $ð $‰ˆˆSØ #Ð˜ÑÐð  Ô&Ô,€LØ!Ô(Ô.€Mð �KÒÐ 9°Ò#;Ð#;ØˆˆØ	�lÒ	"Ð	" i°<Ò&?Ð&?ØˆˆØ	�gÒ	Ð	 ¨lÒ!:Ð!:ð
ð 
ð 
ð 
Ø(ð
ñ 
ô 
ˆˆð 
�mÒ	#Ð	#ð
ð 
ð 
ð 
Ø'ð
ñ 
ô 
ˆð  "ÐÝ! ,Ñ/Ô/ð 4ð 4‰ˆˆWØ�iÐÐØ03Ð$ WÑ-øØ "ÐÝ! -Ñ0Ô0ð 5ð 5‰ˆˆWØ�jÐ Ð Ø14Ð% gÑ.øõ �,¥¤
Ñ+Ô+ð XÝ& |ÀÐMÑMÔMˆˆå! .Õ2HÈÑ2VÔ2VÑWÔWˆÝ�-¥¤Ñ,Ô,ð 
Ý'¨À;ÐOÑOÔOˆˆå"ØÕ2°=ÑAÔAñ
ô 
ˆð ð 
Ý'Ø�y *¨l¸MØ#.Ð#4°"Ø$0Ð$6°BØ/ð	
ñ 
ô 
ˆ	ˆ	õ (Ø�y *Ø#.Ð#4°"Ø$0Ð$6°BØ/ð	
ñ 
ô 
ˆ	õ Ø˜I¨{¸LÐ.Iðñ ô €Dð ñ 2=˜ lÒ2Ñ2õ ˜|Ñ,Ô,ÐÝ Ñ.Ô.Ðå! ,Ñ/Ô/ÐØ ÐØˆÝ! ,°Ñ">Ñ?Ô?ð $	ñ $	‰HˆC�Ø•S˜Ñ&Ô&Ò&Ð&¨3Ð2JÐ+JÐ+Jà#×*Ò*¨3Ñ/Ô/Ð/ð
 #<Ø˜¨sÔ3Ô4ô#6�à×"Ò"ÝÔ$ ZÝ"Ô)¨#Ñ.Ô.µ
Ô0AØ/°Ñ?ñ1Aô 1Að2ñ ô ñô ð ð ð Ð+Ò+Ð+°Ð7PÐ0PÐ0Pàð  ð'Ø$'Ð*=Ò$=Ð$=ØÐ0Ð0Ð0à˜;Ñ&�Cà ð(Ø%(Ð,?Ò%?Ð%?ØÐ/Ð/Ð/à˜<Ñ'�CØ#×*Ò*¨3Ñ/Ô/Ð/Ø×"Ò"ÝÔ% cÑ*Ô*ñô ð ñ õ !ØÕ)¨+Ð7JÑKÔKñ
ô 
ˆ
õ Ô(¨$°
Ð);Ñ<Ô<ˆà—=’=¨[�=Ñ9Ô9€Là•eÒÐØÐØ	�Ô*Ò	*Ð	*ÝÔ! ,Ñ/Ô/Ð/åÐ1Ñ2Ô2Ð2r   c	                 óR  ‡‡— t          | t          t          j        f¦  «        st	          dt          | ¦  «        › �¦  «        ‚t          |t          t          j        f¦  «        st	          dt          |¦  «        › �¦  «        ‚t          |t          t          f¦  «        s|g}t          ‰t          t          f¦  «        s‰gŠˆˆfd„|j        j	        D ¦   «         }	t          | j        j	        ¦  «        t          |	¦  «        z  }
|
rt          d|
› d�¦  «        ‚t          | t          j        ¦  «        rt          | |d¬¦  «        }nt          dt          | ¦  «        ¦  «        }t          |t          j        ¦  «        rt          ||d¬¦  «        }nt          dt          |¦  «        ¦  «        }t          ||‰‰|¦  «        }t          d|||g¬	¦  «        }|                     |¬
¦  «        }|t          k    r|S |t          j        k    rt          j        |¦  «        S t	          d¦  «        ‚)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
    r9   c                 ó$   •— g | ]}|‰g‰z   v¯
|‘ŒS r   r   )r)   r<   Úright_byÚright_ons     €€r   r+   z&_perform_join_asof.<locals>.<listcomp>3  s5   ø€ ð ð ð ØØ�x�j 8Ñ+Ð+Ð+ð 	Ø+Ð+Ð+r   zColumns zE present in both tables. AsofJoin does not support column collisions.Tr%   rA   ÚasofjoinrG   r@   rK   )rL   r   rM   r   rN   rO   rP   rQ   r.   r/   rS   Ú
ValueErrorr7   r   r
   r   rX   r"   )rZ   Úleft_onÚleft_byr\   rw   rv   Ú	tolerancer&   ra   re   Úcolumns_collisionsri   rj   rk   r4   rr   s       ``          r   Ú_perform_join_asofr~     ss  øø€ õB �l¥U­B¬JÐ$7Ñ8Ô8ð PÝÐN½$¸|Ñ:LÔ:LÐNÐNÑOÔOÐOÝ�m¥e­R¬ZÐ%8Ñ9Ô9ð QÝÐO½$¸}Ñ:MÔ:MÐOÐOÑPÔPÐPå�g¥¥t˜}Ñ-Ô-ð Ø�)ˆÝ�h¥­ Ñ.Ô.ð Ø�:ˆðð ð ð ð Ø$Ô+Ô1ðñ ô €Mõ ˜\Ô0Ô6Ñ7Ô7½#¸mÑ:LÔ:LÑLÐØð 
Ýð;Ð)ð ;ð ;ð ;ñ
ô 
ð 	
õ �,¥¤
Ñ+Ô+ð 
Ý&ØØ#Ø"ð$ñ $ô $ˆˆõ
 "ØÕ2°<Ñ@Ô@ñ
ô 
ˆõ �-¥¤Ñ,Ô,ð 
Ý'Ø {Ø"ð$ñ $ô $ˆˆõ #ØÕ2°=ÑAÔAñ
ô 
ˆõ $Ø�˜( H¨iñô €Iõ Ø˜I¨{¸LÐ.Iðñ ô €Dð —=’=¨[�=Ñ9Ô9€Là•eÒÐØÐØ	�Ô*Ò	*Ð	*ÝÔ! ,Ñ/Ô/Ð/åÐ1Ñ2Ô2Ð2r   c           	      óö  — d}t          | t          ¦  «        rt          j        | g¦  «        } d}t	          j        t	          dt          | ¦  «        ¬¦  «        t	          dt          |¦  «        ¬¦  «        g¦  «        }|                     d¬¦  «        }|rd|j	        dk    r-| 
                    ¦   «                              ¦   «         d         }n,d„ |j        D ¦   «         }t          j        ||j        ¬	¦  «        }|S )
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
    FTrA   )rH   r-   r@   r   c                 ó:   — g | ]}t          g |j        ¬ ¦  «        ‘ŒS ))rO   )r   rO   )r)   r   s     r   r+   z!_filter_table.<locals>.<listcomp>�  s'   € ÐLÐLÐL°U•e˜B U¤ZÐ0Ñ0Ô0ÐLÐLÐLr   )r.   )rL   r   r   Úfrom_batchesr   r0   r
   r   rX   Únum_rowsÚcombine_chunksÚ
to_batchesr.   Úfrom_arrays)ÚtableÚ
expressionÚis_batchr4   ÚresultÚarrayss         r   Ú_filter_tabler‹   b  sû   € ð" €HÝ�%�Ñ%Ô%ð ÝÔ" E 7Ñ+Ô+ˆØˆåÔ$Ý�NÕ,BÀ5Ñ,IÔ,IÐJÑJÔJÝ�HÕ&7¸
Ñ&CÔ&CÐDÑDÔDð&ñ ô €Dð �]Š] tˆ]Ñ,Ô,€FØð KØŒ?˜QÒÐØ×*Ò*Ñ,Ô,×7Ò7Ñ9Ô9¸!Ô<ˆFˆFàLÐL¸f¼mÐLÑLÔLˆFÝ Ô,¨V¸F¼MÐJÑJÔJˆFØ€Mr   c                 ó¢  — t          | t          j        ¦  «        rt          | d¬¦  «        }nt	          dt          | ¦  «        ¦  «        }t	          dt          |fi |¤Ž¦  «        }t	          j        ||g¦  «        }|                     d¬¦  «        }|t          k    r|S |t          j
        k    rt          j
        |¦  «        S t          d¦  «        ‚)NTr@   rA   Úorder_byrK   )rL   rM   r   r7   r   r
   r   r0   rX   r   r"   rN   )Útable_or_datasetÚ	sort_keysra   ÚkwargsÚdata_sourcer�   r4   rr   s           r   Ú_sort_sourcer’   †  sÓ   € åÐ"¥B¤JÑ/Ô/ð 
Ý&Ð'7ÀTÐJÑJÔJˆˆå!ØÕ2Ð3CÑDÔDñ
ô 
ˆõ ˜:Õ'9¸)Ð'NÐ'NÀvÐ'NÐ'NÑOÔO€HåÔ$ k°8Ð%<Ñ=Ô=€DØ—=’=¨T�=Ñ2Ô2€Là•eÒÐØÐØ	�Ô*Ò	*Ð	*ÝÔ! ,Ñ/Ô/Ð/åÐ1Ñ2Ô2Ð2r   c           
      óÊ   — t          j        t          dt          | ¦  «        ¦  «        t          dt          ||¬¦  «        ¦  «        g¦  «        }|                     |¬¦  «        S )NrA   Ú	aggregate)Úkeysr@   )r   r0   r
   r   rX   )r†   Ú
aggregatesr•   r&   r4   s        r   Ú	_group_byr—   œ  s`   € åÔ$Ý�NÕ$:¸5Ñ$AÔ$AÑBÔBÝ�KÕ!5°jÀtÐ!LÑ!LÔ!LÑMÔMð&ñ ô €Dð �=Š= [ˆ=Ñ1Ô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.datasetr3   rM   Úpyarrow._datasetr   r   r7   rs   r~   r‹   r’   r—   r   r   r   ú<module>r       s$  ðð2 2Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -ðð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
øð ð ð ð Ø
ˆ+ØVÈ3È3ÈsÉ8Ì8ÐVÐVÐVñô àðøøøøðøøøð
Ø Ð Ð Ð Ð Ð Ø0Ð0Ð0Ð0Ð0Ð0Ð0øØð ð ð ðð ð ð ð ñ ô ð ð 
€B€B€Bðøøøðð ð ð ð2 #°Ø"°%Ø#°tð	r3ð r3ð r3ð r3ðn /3Ø#(ðX3ð X3ð X3ð X3ðv!ð !ð !ðH ;@ð 3ð 3ð 3ð 3ð,2ð 2ð 2ð 2ð 2ð 2s&   ”+ «A°A	Á	AÁA ÁA6Á5A6