
    q-Ph$1                    x   U d dl mZ d dlZ ej        e          5  d dlmZ ddd           n# 1 swxY w Y   d dlZd dlm	Z	 d dl
mZmZmZ er2d dlZej        dk    rd dl
mZ nd dlmZ  ed          Z ed	          Z G d
 d          Zded<   	  e            Zn# eef$ rZdZY dZ[ndZ[ww xY wddZdS )    )annotationsN)
PyOptFlags)wraps)TYPE_CHECKINGCallableTypeVar)   
   )	ParamSpecPTc                     e Zd ZdZddddddddddd
d3dZed4d            Zeddddddddddd
d5d            Zddddddddddd
d5dZ	ed6d            Z
d6dZd6dZd7dZed8d            Zej        d9d            Zed8d            Zej        d9d             Zed8d!            Zej        d9d"            Zed8d#            Zej        d9d$            Zed8d%            Zej        d9d&            Zed8d'            Zej        d9d(            Zed8d)            Zej        d9d*            Zed8d+            Zej        d9d,            Zed8d-            Zej        d9d.            Zed8d/            Zej        d9d0            Zd:d2ZdS );QueryOptFlagsz
    The set of the optimizations considered during query optimization.

    .. warning::
        This functionality is considered **unstable**. It may be changed
        at any point without it being considered a breaking change.
    N
predicate_pushdownprojection_pushdownsimplify_expressionslice_pushdowncomm_subplan_elimcomm_subexpr_elimcluster_with_columnscollapse_joinscheck_order_observefast_projectionr   None | boolr   r   r   r   r   r   r   r   r   returnNonec       
        t    t          j                    | _        |                     |||||||||	|

  
         d S )Nr   )r   default_pyoptflagsupdateselfr   r   r   r   r   r   r   r   r   r   s              Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/lazyframe/opt_flags.py__init__zQueryOptFlags.__init__!   sX     &-//1 3 3)//!5) 3+ 	 	
 	
 	
 	
 	
    
pyoptflagsr   c                >    |                      |           }||_        |S N)__new__r    )r#   r'   optflagss      r$   _from_pyoptflagszQueryOptFlags._from_pyoptflags=   s     <<%%)r&   c        
            t                      }
|
                                 |
                    | |||||||||	
  
        S )'Create new empty set off optimizations.r   )r   no_optimizationsr!   )r   r   r   r   r   r   r   r   r   r   r+   s              r$   nonezQueryOptFlags.noneC   sX     !??!!###1 3 3)//!5) 3+  
 
 	
r&   c       
            ||| _         ||| _        ||| _        ||| _        ||| _        ||| _        ||| _        ||| _        |	|	| _        |
|
| _	        | S )z&Update the current optimization flags.r   r"   s              r$   r!   zQueryOptFlags.updatea   s     )&8D#*':D$*':D$%"0D(%6D"(%6D"+(<D%%"0D*':D$&#2D r&   c                 p    t                      } |                                  d| j        _        d| _        | S )r.   T)r   r/   r    eagerr   )r+   s    r$   _eagerzQueryOptFlags._eager   s7     !??!!###%)"'+$r&   c                d    t                               | j                                                  S r)   r   r,   r    copyr#   s    r$   __copy__zQueryOptFlags.__copy__   %    --d.>.C.C.E.EFFFr&   c                d    t                               | j                                                  S r)   r6   r8   s    r$   __deepcopy__zQueryOptFlags.__deepcopy__   r:   r&   c                8    | j                                          dS )zRemove selected optimizations.N)r    r/   r8   s    r$   r/   zQueryOptFlags.no_optimizations   s    ))+++++r&   boolc                    | j         j        S )z3Only read columns that are used later in the query.r    r   r8   s    r$   r   z!QueryOptFlags.projection_pushdown        33r&   valuec                    || j         _        d S r)   r@   r#   rB   s     r$   r   z!QueryOptFlags.projection_pushdown       /4,,,r&   c                    | j         j        S )z.Apply predicates/filters as early as possible.r    r   r8   s    r$   r   z QueryOptFlags.predicate_pushdown   s     22r&   c                    || j         _        d S r)   rG   rD   s     r$   r   z QueryOptFlags.predicate_pushdown   s    .3+++r&   c                    | j         j        S )z=Cluster sequential `with_columns` calls to independent calls.r    r   r8   s    r$   r   z"QueryOptFlags.cluster_with_columns   s     44r&   c                    || j         _        d S r)   rJ   rD   s     r$   r   z"QueryOptFlags.cluster_with_columns   s    05---r&   c                    | j         j        S )z9Run many expression optimization rules until fixed point.r    r   r8   s    r$   r   z!QueryOptFlags.simplify_expression   rA   r&   c                    || j         _        d S r)   rM   rD   s     r$   r   z!QueryOptFlags.simplify_expression   rE   r&   c                    | j         j        S )zPushdown slices/limits.r    r   r8   s    r$   r   zQueryOptFlags.slice_pushdown        ..r&   c                    || j         _        d S r)   rP   rD   s     r$   r   zQueryOptFlags.slice_pushdown       */'''r&   c                    | j         j        S )z/Elide duplicate plans and caches their outputs.r    r   r8   s    r$   r   zQueryOptFlags.comm_subplan_elim        11r&   c                    || j         _        d S r)   rU   rD   s     r$   r   zQueryOptFlags.comm_subplan_elim       -2***r&   c                    | j         j        S )z5Elide duplicate expressions and caches their outputs.r    r   r8   s    r$   r   zQueryOptFlags.comm_subexpr_elim   rV   r&   c                    || j         _        d S r)   rZ   rD   s     r$   r   zQueryOptFlags.comm_subexpr_elim   rX   r&   c                    | j         j        S )z5Collapse slower joins with filters into faster joins.r    r   r8   s    r$   r   zQueryOptFlags.collapse_joins   rQ   r&   c                    || j         _        d S r)   r]   rD   s     r$   r   zQueryOptFlags.collapse_joins   rS   r&   c                    | j         j        S )z9Do not maintain order if the order would not be observed.r    r   r8   s    r$   r   z!QueryOptFlags.check_order_observe   rA   r&   c                    || j         _        d S r)   r`   rD   s     r$   r   z!QueryOptFlags.check_order_observe   rE   r&   c                    | j         j        S )z]Replace simple projections with a faster inlined projection that skips the expression engine.r    r   r8   s    r$   r   zQueryOptFlags.fast_projection   s     //r&   c                    || j         _        d S r)   rc   rD   s     r$   r   zQueryOptFlags.fast_projection   s    +0(((r&   strc                   d                     g d| j        j         d| j        j         d| j         d| j         d| j         d| j         d| j         d	| j	         d
| j
         d| j         d| j         d| j         d| j        j         d| j        j         d| j        j         d                                          S )N z$
QueryOptFlags {
    type_coercion: z
    type_check: z

    predicate_pushdown: z
    projection_pushdown: z
    simplify_expression: z
    slice_pushdown: z
    comm_subplan_elim: z
    comm_subexpr_elim: z
    cluster_with_columns: z
    collapse_joins: z
    check_order_observe: z
    fast_projection: z

    eager: z
    old_streaming: z
    streaming: z
}
        )joinr    type_coercion
type_checkr   r   r   r   r   r   r   r   r   r   r3   old_streaming	streamingstripr8   s    r$   __str__zQueryOptFlags.__str__   s        $2    !,   
 0    2    2    (    .    .     4    (    2    *     "!   " $2#   $  *%     ( EGG)	r&   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r'   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   )r   r   )r   r>   )rB   r>   r   r   )r   re   )__name__
__module____qualname____doc__r%   classmethodr,   staticmethodr0   r!   r4   r9   r<   r/   propertyr   setterr   r   r   r   r   r   r   r   r   rn    r&   r$   r   r      s&         +/+/+/&*)-)-,0&*+/'+
 
 
 
 
 
8    [
  +/+/+/&*)-)-,0&*+/'+
 
 
 
 
 \
@ +/+/+/&*)-)-,0&*+/'+$ $ $ $ $ $L    \G G G GG G G G, , , , 4 4 4 X4 5 5 5  5 3 3 3 X3 4 4 4 4 5 5 5 X5  6 6 6 ! 6 4 4 4 X4 5 5 5  5 / / / X/ 0 0 0 0 2 2 2 X2 3 3 3 3 2 2 2 X2 3 3 3 3 / / / X/ 0 0 0 0 4 4 4 X4 5 5 5  5 0 0 0 X0 1 1 1 1     r&   r   DEFAULT_QUERY_OPT_FLAGSrw   r   *Callable[[Callable[P, T]], Callable[P, T]]c                     dddd	dd
ddfdfdfdfdfdfdfdfdfdfdfdfdfdddfd} | S ) z8Decorator to mark to forward the old optimization flags.fr   
field_namere   rB   r>   r   c                (    t          | ||           | S r)   )setattrr{   r|   rB   s      r$   helperz%forward_old_opt_flags.<locals>.helper  s    :u%%%r&   c                2    t          | j        ||           | S r)   )r~   r    r   s      r$   helper_hiddenz,forward_old_opt_flags.<locals>.helper_hidden  s    z5111r&   c                <    |rt                                           S | S r)   )r   r0   r{   rB   s     r$   clear_optimizationsz2forward_old_opt_flags.<locals>.clear_optimizations  s!     	 %%'''Hr&   c                <    |rt                                           S | S r)   )r   r4   r   s     r$   r3   z$forward_old_opt_flags.<locals>.eager$  s!     	 '')))Hr&   c                     | |          S r)   rw   )r{   vr   s     r$   <lambda>z'forward_old_opt_flags.<locals>.<lambda>+  s    (;(;Aq(A(A r&   c                     | |          S r)   rw   )r{   r   r3   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>,  s    uuQ{{ r&   c                     | d|          S )Nri   rw   r{   r   r   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>-  s    mmA&J&J r&   c                     | d|          S )Nrj   rw   r   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>.  s    MM!\1$E$E r&   c                     | d|          S )Nr   rw   r{   r   r   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>/  s    66!5I1+M+M r&   c                     | d|          S )Nr   rw   r   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>0      FF16KQ,O,O r&   c                     | d|          S )Nr   rw   r   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>1  r   r&   c                     | d|          S )Nr   rw   r   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>2      vva1A1'E'E r&   c                     | d|          S )Nr   rw   r   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>3      &&4G*K*K r&   c                     | d|          S )Nr   rw   r   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>4  r   r&   c                     | d|          S )Nr   rw   r   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>5  s    VVA7Mq-Q-Q r&   c                     | d|          S )Nr   rw   r   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>6  r   r&   c                     | d|          S )Nr   rw   r   s     r$   r   z'forward_old_opt_flags.<locals>.<lambda>7  s    VVA/Da%H%H r&   )no_optimizationr4   ri   _type_checkr   r   r   r   r   r   r   r   _check_orderfunctionCallable[P, T]c                t     t                     d fd            }t          j                   |_        |S )	NargsP.argskwargsP.kwargsr   r   c                 j   |                     dt                    }|                                }t          |                                          D ]U}                     |          }|<ddlm} d| d} ||t                      |||                    |                    }V||d<    | i |S )Noptimizationsr   )issue_warningzoptimization flag `zT` is deprecated. Please use `optimizations` parameter
(Deprecated in version 1.30.0))	getrx   r9   listkeyspolars._utils.variousr   DeprecationWarningpop)	r   r   r+   keycbr   messageOLD_OPT_PARAMETERS_MAPPINGr   s	          r$   wrapperz8forward_old_opt_flags.<locals>.decorate.<locals>.wrapper;  s    &,jj!8' 'H  ((**HFKKMM** = =/33C88>CCCCCC OC  O  O  OG!M'+=>>>!r(FJJsOO<<H&.F?#8T,V,,,r&   )r   r   r   r   r   r   )r   inspect	signature__signature__)r   r   r   s   ` r$   decoratez'forward_old_opt_flags.<locals>.decorate:  sQ    	x	- 	- 	- 	- 	- 	- 
	-" !( 1( ; ;r&   )r{   r   r|   re   rB   r>   r   r   )r{   r   rB   r>   r   r   )r   r   r   r   rw   )r   r   r   r3   r   r   s    @@@@@r$   forward_old_opt_flagsr     s(                BAAA****JJJJEEEEMMMMOOOOOOOOEEEEKKKKKKKK Q Q Q QEEEEHHHH" "      , Or&   )r   ry   )
__future__r   
contextlibsuppressImportErrorpolars.polarsr   r   	functoolsr   typingr   r   r   sysversion_infor   typing_extensionsr   r   r   __annotations__rx   	NameError_r   rw   r&   r$   <module>r      s   " " " " " " "    Z%% ) )(((((() ) ) ) ) ) ) ) ) ) ) ) ) ) )        3 3 3 3 3 3 3 3 3 3 	JJJ
7""$$$$$$$//////	#AAq q q q q q q qh ' & & &!+mooY ! ! ! != = = = = =s$   /33
B   B3'B..B3