
    ɯei                        d dl Z d dlZd dlmZmZmZ d dlZd dlmc m	c m
c mc mZ
 d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ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)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 d dl1m2Z2m3Z3m4Z4m5Z5m6Z6 d dl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ d dlAmBZBmCZCmDZDmEZEmFZFmGZG d dlHmIZImJZJmKZKmLZLmMZMmNZNmOZO d d	lPmQZQmRZRmSZSmTZT d d
lUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z] d dl^m_Z_m`Z` e j                  dk  rd dlmbZb nd dlcmbZb deeJdf   dedddfdZedeMdedddfdZfdeLdedddfdZgdeeLehf   dedddfdZi G d d      Zj G d dej      Zk ejd      Zl ejd      Zm ejd      Zn ejd      Zo ejd      Zpelj                          eW       emj                          eX       enj                          eZeYj                        eoj                          eZeYj                        epj                          eX       iZuy)    N)AnyOptionalUnion)AddAnd
BitwiseAnd	BitwiseOr
BitwiseXorDivideEqualNullSafeEqualToGreaterThanGreaterThanOrEqualLessThanLessThanOrEqualMultiply
NotEqualToOrPow	RemainderSubtract)CaseWhenCollate
ExpressionInExpressionLikeLiteralMultipleExpressionNamedExpressionRegExpScalarSubqueryStarSubfieldIntSubfieldStringUnresolvedAttribute	AttributeWithinGroup)	Ascending
Descending
NullsFirst	NullsLast	SortOrder)	AliasCastIsNaN	IsNotNullIsNullNot
UnaryMinusUnresolvedAlias_InternalAlias)build_expr_from_python_val-build_expr_from_snowpark_column_or_python_val*build_expr_from_snowpark_column_or_sql_strcreate_ast_for_columnsnowpark_expression_to_astwith_src_position)$VALID_PYTHON_TYPES_FOR_LITERAL_VALUEColumnOrLiteralColumnOrLiteralStrColumnOrNameColumnOrSqlExprLiteralTypetype_string_to_type_object)parse_positional_args_to_list	publicapi
quote_name#split_snowflake_identifier_with_dot)DataTypeIntegerType
StringTypeTimestampTimeZoneTimestampType	ArrayTypeMapType
StructType)Window
WindowSpec)   	   )Iterablecolsnowflake.snowpark.DataFrame	func_namereturnColumnc                     t        | t        t        j                  j                  t
        t        t        f      r| S t        | t              rt        t        |       d      S t        d| dt        |              )NF	_emit_ast'z<' expected Column, DataFrame, Iterable or LiteralType, got: )
isinstancerX   	snowflakesnowpark	DataFramelisttuplesetr<   r   	TypeErrortyperT   rV   s     [/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/snowflake/snowpark/column.py_to_col_if_litrh   p   sl     #	 2 2 < <dE3OP
	C=	>gcle44	{VW[\_W`Vab
 	
    c                     t        | t              r| S t        | t              rt        j                  |       S t	        d| dt        |              )Nr\   z1' expected Column or str as SQL expression, got: )r]   rX   str_exprrd   re   rf   s     rg   _to_col_if_sql_exprrm   }   sM    #v
	C	||C  	{KDQTI;W
 	
ri   c                     t        | t              r| S t        | t              rt        | d       S t        d|j	                          dt        |              )N_caller_namer\   z' expected Column or str, got: )r]   rX   rk   rd   upperre   rf   s     rg   _to_col_if_strrr      sR    #v
	C	c--	!""A$s)M
 	
ri   c                     t        | t              r| S t        | t              rt        | d       S t        | t              rt        t	        |       d      S t        d|j                          dt        |              )Nro   FrZ   r\   z$' expected Column, int or str, got: )r]   rX   rk   intr   rd   rq   re   rf   s     rg   _to_col_if_str_or_intru      sm    #v
	C	c--	C	gcle44	!""FtCykR
 	
ri   c                      e Zd ZdZe	 	 	 	 djdddeeef   dee   dee	j                     d	ed
ee   deddfd       ZdedefdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fdZdeeef   dd fd Z deeef   dd fd!Z!deeef   dd fd"Z"deeef   dd fd#Z#defd$Z$dkd%Z%dld&Z&d' Z'edd(d)ee(e)e(   d e)d    d*f   d	edd fd+       Z*e	 dmd,eeef   d-eeef   d	edd fd.       Z+e	 dmdeeef   d	edd fd/       Z,e	 dmdeeef   d	edd fd0       Z-e	 dmdeeef   d	edd fd1       Z.dnd2Z/edmdd d	edd fd3       Z0edmd	edd fd4       Z1edmd	edd fd5       Z2edmd	edd fd6       Z3ded ef   dd fd7Z4ded ef   dd fd8Z5ded ef   dd fd9Z6ded ef   dd fd:Z7dnd;Z8	 	 	 	 dod<eee9f   d=ed>ed?ed	edd fd@Z:e	 	 	 dpd<eee9f   d>ed?ed	edd f
dA       Z;e	 	 	 dpd<eee9f   d>ed?ed	edd f
dB       Z<edmd	edd fdC       Z=edmd	edd fdD       Z>edmd	edd fdE       Z?edmd	edd fdF       Z@edmd	edd fdG       ZAedmd	edd fdH       ZBedmdIeCd	edd fdJ       ZDe	 	 dqdIeCdKeeC   d	edd fdL       ZEedmdeCd	edd fdM       ZFedmdeCd	edd fdN       ZGe	 dmdOed ef   dPed ef   d	edd fdQ       ZHedmdRed	edd fdS       ZIedmdTeJd	edd fdU       ZKdee   fdVZLdW ZMdX ZNedmdYed	edd fdZ       ZOedmdYed	edd fd[       ZPdYedd fd\ZQe	 	 drdYed]eRj                  d^   d	edd fd_       ZTe	 dqd`eeU   d	edd fda       ZVedd(dbeeJe)eJ   f   d	edd fdc       ZWdeXfddZYeZdeeeef   defdf       Z[eZdldgedhee	j                     dd fdi       Z\e*Z]e;Z^eEZ_eHZ`e,Zae-Zbe.Zce3Zde2Zee0ZfeLZgeZheZiy)srX   a;  Represents a column or an expression in a :class:`DataFrame`.

    To access a Column object that refers a column in a :class:`DataFrame`, you can:

        - Use the column name.
        - Use the :func:`functions.col` function.
        - Use the :func:`DataFrame.col` method.
        - Use the index operator ``[]`` on a dataframe object with a column name.
        - Use the dot operator ``.`` on a dataframe object with a column name.

        >>> from snowflake.snowpark.functions import col
        >>> df = session.create_dataframe([["John", 1], ["Mike", 11]], schema=["name", "age"])
        >>> df.select("name").collect()
        [Row(NAME='John'), Row(NAME='Mike')]
        >>> df.select(col("name")).collect()
        [Row(NAME='John'), Row(NAME='Mike')]
        >>> df.select(df.col("name")).collect()
        [Row(NAME='John'), Row(NAME='Mike')]
        >>> df.select(df["name"]).collect()
        [Row(NAME='John'), Row(NAME='Mike')]
        >>> df.select(df.name).collect()
        [Row(NAME='John'), Row(NAME='Mike')]

        Snowflake object identifiers, including column names, may or may not be case sensitive depending on a set of rules.
        Refer to `Snowflake Object Identifier Requirements <https://docs.snowflake.com/en/sql-reference/identifiers-syntax.html>`_ for details.
        When you use column names with a DataFrame, you should follow these rules.

        The returned column names after a DataFrame is evaluated follow the case-sensitivity rules too.
        The above ``df`` was created with column name "name" while the returned column name after ``collect()`` was called became "NAME".
        It's because the column is regarded as ignore-case so the Snowflake database returns the upper case.

    To create a Column object that represents a constant value, use :func:`snowflake.snowpark.functions.lit`:

        >>> from snowflake.snowpark.functions import lit
        >>> df.select(col("name"), lit("const value").alias("literal_column")).collect()
        [Row(NAME='John', LITERAL_COLUMN='const value'), Row(NAME='Mike', LITERAL_COLUMN='const value')]

    This class also defines utility functions for constructing expressions with Columns.
    Column objects can be built with the operators, summarized by operator precedence,
    in the following table:

    ==============================================  ==============================================
    Operator                                        Description
    ==============================================  ==============================================
    ``x[index]``                                    Index operator to get an item out of a Snowflake ARRAY or OBJECT
    ``**``                                          Power
    ``-x``, ``~x``                                  Unary minus, unary not
    ``*``, ``/``, ``%``                             Multiply, divide, remainder
    ``+``, ``-``                                    Plus, minus
    ``&``                                           And
    ``|``                                           Or
    ``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``    Equal to, not equal to, less than, less than or equal to, greater than, greater than or equal to
    ==============================================  ==============================================

        The following examples demonstrate how to use Column objects in expressions:

            >>> df = session.create_dataframe([[20, 5], [1, 2]], schema=["a", "b"])
            >>> df.filter((col("a") == 20) | (col("b") <= 10)).collect()  # use parentheses before and after the | operator.
            [Row(A=20, B=5), Row(A=1, B=2)]
            >>> df.filter((df["a"] + df.b) < 10).collect()
            [Row(A=1, B=2)]
            >>> df.select((col("b") * 10).alias("c")).collect()
            [Row(C=50), Row(C=20)]

        When you use ``|``, ``&``, and ``~`` as logical operators on columns, you must always enclose column expressions
        with parentheses as illustrated in the above example, because their order precedence is higher than ``==``, ``<``, etc.

        Do not use ``and``, ``or``, and ``not`` logical operators on column objects, for instance, ``(df.col1 > 1) and (df.col2 > 2)`` is wrong.
        The reason is Python doesn't have a magic method, or dunder method for them.
        It will raise an error and tell you to use ``|``, ``&`` or ``~``, for which Python has magic methods.
        A side effect is ``if column:`` will raise an error because it has a hidden call to ``bool(a_column)``, like using the ``and`` operator.
        Use ``if a_column is None:`` instead.

    To access elements of a semi-structured Object and Array, use ``[]`` on a Column object:

        >>> from snowflake.snowpark.types import StringType, IntegerType
        >>> df_with_semi_data = session.create_dataframe([[{"k1": "v1", "k2": "v2"}, ["a0", 1, "a2"]]], schema=["object_column", "array_column"])
        >>> df_with_semi_data.select(df_with_semi_data["object_column"]["k1"].alias("k1_value"), df_with_semi_data["array_column"][0].alias("a0_value"), df_with_semi_data["array_column"][1].alias("a1_value")).collect()
        [Row(K1_VALUE='"v1"', A0_VALUE='"a0"', A1_VALUE='1')]
        >>> # The above two returned string columns have JSON literal values because children of semi-structured data are semi-structured.
        >>> # The next line converts JSON literal to a string
        >>> df_with_semi_data.select(df_with_semi_data["object_column"]["k1"].cast(StringType()).alias("k1_value"), df_with_semi_data["array_column"][0].cast(StringType()).alias("a0_value"), df_with_semi_data["array_column"][1].cast(IntegerType()).alias("a1_value")).collect()
        [Row(K1_VALUE='v1', A0_VALUE='a0', A1_VALUE=1)]

    This class has methods for the most frequently used column transformations and operators. Module :mod:`snowflake.snowpark.functions` defines many functions to transform columns.
    NTF_is_qualified_nameexpr1expr2_astr[   rp   rx   rW   c                J   || _         || _        || _        	 d
dt        dt        t           dt
        fd}|t        |t              rt        |t              st        d      |dk(  rt        g |      | _	        n,|r |||      | _	        nt        t        |      |      | _	        | j                   |rt        |||      | _         nt        |t              r`|dk(  rt        g       | _	        n)|r ||      | _	        nt        t        |            | _	        | j                   t|rrt        |d |      | _         n_t        |t              rD|| _	        | j                   <|r:t        |d      r|j                   | _         nt        |      | _         nt        d	      | j                  J y )Nexprdf_aliasrW   c           
          t        |       }t        |      dk(  rt        t        |d         |      S t        t        |d          ddj	                  d |dd D               d|	      S )
z[Note that this method does not work for full column name like <db>.<schema>.<table>.column.   r   r~   :.c              3   6   K   | ]  }t        |d         yw)T)	keep_caseN)rE   ).0parts     rg   	<genexpr>zFColumn.__init__.<locals>.derive_qualified_name_expr.<locals>.<genexpr>  s     6n\`z$RV7W7W6ns   NT)is_sql_textr~   )rF   lenr%   rE   join)r}   r~   partss      rg   derive_qualified_name_exprz3Column.__init__.<locals>.derive_qualified_name_expr  sv     8=E5zQ*:eAh+?(SS +!%(+,Achh6ndijkjldm6n.n-op $% ri   zAWhen Column constructor gets two arguments, both need to be <str>*r   r{   z2Column constructor only accepts str or expression.N)r{   _expr1_expr2rk   r   r%   r]   
ValueErrorr"   _expressionrE   r9   r   hasattrr:   rd   )selfry   rz   r{   r[   rp   rx   r   s           rg   __init__zColumn.__init__   s    	 26		!)#	 	  uc*z%/E W  |#'U#; ##=eU#K #6u%$  yy Y1%M	s#|#'8 ##=e#D #6z%7H#I yy Y1%|L	z*$Dyy Y5&) %

DI :5 ADI PQQ+++ri   otherc                 d    t        |t        t        f      r|j                  y| j                  duS )zHelper function to determine without a session whether AST should be generated or not based on
        checking whether self and other have an AST.NF)r]   rX   r   r{   )r   r   s     rg   __should_emit_ast_for_binaryz#Column.__should_emit_ast_for_binaryK  s.     efj12uzz7Iyy$$ri   fieldc                 t   | j                   du}d}t        |t              ry|rUt        j                         }t        |j                        }|j                  j                  | j                          ||_	        t        t        | j                  |      ||      S t        |t              ry|rUt        j                         }t        |j                        }|j                  j                  | j                          ||_        t        t!        | j                  |      ||      S t#        dt%        |             )z_Accesses an element of ARRAY column by ordinal position, or an element of OBJECT column by key.Nr{   r[   zUnexpected item type: )r{   r]   rk   protoExprr;   column_apply__stringrT   CopyFromr   rX   r$   r   rt   column_apply__intidxr#   rd   re   )r   r   r[   r}   asts        rg   __getitem__zColumn.__getitem__R  s     IIT)	eS!zz|'(A(AB  +!	t//7di  s#zz|'(>(>?  +D,,e449  4T%[MBCCri   c                 b   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        j                  |      }t        t        | j                  |      ||      S )z	Equal to.Nr   )#_Column__should_emit_ast_for_binaryr   r   r;   eqlhsr   r{   r7   rhsrX   _to_exprr   r   r   r   r}   r[   r   rights         rg   __eq__zColumn.__eq__l  s    99%@@9@::<D#DGG,CGGTYY'9#''5I&gd..6TYWWri   c                 b   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        j                  |      }t        t        | j                  |      ||      S )zNot equal to.Nr   )r   r   r   r;   neqr   r   r{   r7   r   rX   r   r   r   r   s         rg   __ne__zColumn.__ne__x  s    99%@@9@::<D#DHH-CGGTYY'9#''5I&t''/di
 	
ri   c                 ^   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )zGreater than.Nr   )r   r   r   r;   gtr   r   r{   r7   r   rX   r   r   r   r   r   r}   r[   r   s        rg   __gt__zColumn.__gt__  s    99%@@9@::<D#DGG,CGGTYY'9#''5I((&//%*@A
 	
ri   c                 ^   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )z
Less than.Nr   )r   r   r   r;   ltr   r   r{   r7   r   rX   r   r   r   r   s        rg   __lt__zColumn.__lt__  s    99%@@9@::<D#DGG,CGGTYY'9#''5IT%%vu'=>
 	
ri   c                 ^   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )zGreater than or equal to.Nr   )r   r   r   r;   geqr   r   r{   r7   r   rX   r   r   r   r   s        rg   __ge__zColumn.__ge__  s    99%@@9@::<D#DHH-CGGTYY'9#''5It//1GH
 	
ri   c                 ^   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )zLess than or equal to.Nr   )r   r   r   r;   leqr   r   r{   r7   r   rX   r   r   r   r   s        rg   __le__zColumn.__le__  s    99%@@9@::<D#DHH-CGGTYY'9#''5ID,,fooe.DE
 	
ri   c                 ^   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )zPlus.Nr   )r   r   r   r;   addr   r   r{   r7   r   rX   r   r   r   r   s        rg   __add__zColumn.__add__      99%@@9@::<D#DHH-CGGTYY'9#''5I  &//%"89
 	
ri   c                 ^   d }| j                  |      x}rdt        j                         }t        |j                        }t        |j                  |       |j                  j                  | j                         t        t        t        j                  |      | j                        ||      S Nr   )r   r   r   r;   r   r7   r   r   r   r{   rX   r   r   r   r   s        rg   __radd__zColumn.__radd__      99%@@9@::<D#DHH-C9#''5IGGTYY'&(8(89
 	
ri   c                 ^   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )zMinus.Nr   )r   r   r   r;   subr   r   r{   r7   r   rX   r   r   r   r   s        rg   __sub__zColumn.__sub__      99%@@9@::<D#DHH-CGGTYY'9#''5IT%%vu'=>
 	
ri   c                 ^   d }| j                  |      x}rdt        j                         }t        |j                        }t        |j                  |       |j                  j                  | j                         t        t        t        j                  |      | j                        ||      S r   )r   r   r   r;   r   r7   r   r   r   r{   rX   r   r   r   r   s        rg   __rsub__zColumn.__rsub__      99%@@9@::<D#DHH-C9#''5IGGTYY'V__U+T-=-=>
 	
ri   c                 ^   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )z	Multiply.Nr   )r   r   r   r;   mulr   r   r{   r7   r   rX   r   r   r   r   s        rg   __mul__zColumn.__mul__  r   ri   c                 ^   d }| j                  |      x}rdt        j                         }t        |j                        }t        |j                  |       |j                  j                  | j                         t        t        t        j                  |      | j                        ||      S r   )r   r   r   r;   r   r7   r   r   r   r{   rX   r   r   r   r   s        rg   __rmul__zColumn.__rmul__  r   ri   c                 ^   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )zDivide.Nr   )r   r   r   r;   divr   r   r{   r7   r   rX   r   r   r   r   s        rg   __truediv__zColumn.__truediv__  s    99%@@9@::<D#DHH-CGGTYY'9#''5I4##V__U%;<
 	
ri   c                 ^   d }| j                  |      x}rdt        j                         }t        |j                        }t        |j                  |       |j                  j                  | j                         t        t        t        j                  |      | j                        ||      S r   )r   r   r   r;   r   r7   r   r   r   r{   rX   r   r   r   r   s        rg   __rtruediv__zColumn.__rtruediv__  s    99%@@9@::<D#DHH-C9#''5IGGTYY'6??5)4+;+;<
 	
ri   c                 ^   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )z
Remainder.Nr   )r   r   r   r;   modr   r   r{   r7   r   rX   r   r   r   r   s        rg   __mod__zColumn.__mod__*  s    99%@@9@::<D#DHH-CGGTYY'9#''5Id&&(>?
 	
ri   c                 ^   d }| j                  |      x}rdt        j                         }t        |j                        }t        |j                  |       |j                  j                  | j                         t        t        t        j                  |      | j                        ||      S r   )r   r   r   r;   r   r7   r   r   r   r{   rX   r   r   r   r   s        rg   __rmod__zColumn.__rmod__8  s    99%@@9@::<D#DHH-C9#''5IGGTYY'fooe,d.>.>?
 	
ri   c                 ^   d}| j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )zPower.Nr   )r   r   r   r;   powr   r   r{   r7   r   rX   r   r   r   r   s        rg   __pow__zColumn.__pow__E  r   ri   c                 ^   d }| j                  |      x}rdt        j                         }t        |j                        }t        |j                  |       |j                  j                  | j                         t        t        t        j                  |      | j                        ||      S r   )r   r   r   r;   r   r7   r   r   r   r{   rX   r   r   r   r   s        rg   __rpow__zColumn.__rpow__S  r   ri   c                     t        d      )NzCannot convert a Column object into bool: please use '&' for 'and', '|' for 'or', '~' for 'not' if you're building DataFrame filter expressions. For example, use df.filter((col1 > 1) & (col2 > 2)) instead of df.filter(col1 > 1 and col2 > 2).rd   r   s    rg   __bool__zColumn.__bool__`  s    n
 	
ri   c                     t        d      )NzColumn is not iterable. This error can occur when you use the Python built-ins for sum, min and max. Please make sure you use the corresponding function from snowflake.snowpark.functions.r   r   s    rg   __iter__zColumn.__iter__f  s     J
 	
ri   c                     t        d      )NzColumn cannot be rounded. This error can occur when you use the Python built-in round. Please make sure you use the snowflake.snowpark.functions.round function instead.r   )r   ns     rg   	__round__zColumn.__round__k  s     w
 	
ri   c                 ,    t        | j                        S r   )hashr   r   s    rg   __hash__zColumn.__hash__p  s    D$$%%ri   rZ   valsrU   c                   t        | }|s`d}|rEt        j                         }|j                  }|j                  j                  | j                         t        t        d      ||      S |D cg c]  }t        |d       }}t        | j                  t              rt        | j                  j                        ndfd}|D cg c]
  } ||       }}t        |      dk7  st        |d   t              sdt         ffd	|D ]
  }	 |	        d}|rt        j                         }|j                  }|j                  j                  | j                         |D ]h  }
|j"                  j%                         }t        |
t&        j(                  j*                  j,                        r|
j/                  |       ]t1        ||
       j t        t3        | j                  |      ||      S c c}w c c}w )
a  Returns a conditional expression that you can pass to the :meth:`DataFrame.filter`
        or where :meth:`DataFrame.where` to perform the equivalent of a WHERE ... IN query
        with a specified list of values. You can also pass this to a
        :meth:`DataFrame.select` call.

        The expression evaluates to true if the value in the column is one of the values in
        a specified sequence.

        For example, the following code returns a DataFrame that contains the rows where
        the column "a" contains the value 1, 2, or 3. This is equivalent to
        ``SELECT * FROM table WHERE a IN (1, 2, 3)``.

        :meth:`isin` is an alias for :meth:`in_`.

        Examples::

            >>> from snowflake.snowpark.functions import lit
            >>> df = session.create_dataframe([[1, "x"], [2, "y"] ,[4, "z"]], schema=["a", "b"])
            >>> # Basic example
            >>> df.filter(df["a"].in_(lit(1), lit(2), lit(3))).collect()
            [Row(A=1, B='x'), Row(A=2, B='y')]

            >>> # Check in membership for a DataFrame that has a single column
            >>> df_for_in = session.create_dataframe([[1], [2] ,[3]], schema=["col1"])
            >>> df.filter(df["a"].in_(df_for_in)).sort(df["a"].asc()).collect()
            [Row(A=1, B='x'), Row(A=2, B='y')]

            >>> # Use in with a select method call
            >>> df.select(df["a"].in_(lit(1), lit(2), lit(3)).alias("is_in_list")).collect()
            [Row(IS_IN_LIST=True), Row(IS_IN_LIST=True), Row(IS_IN_LIST=False)]

            >>> # Use in with column object
            >>> df2 = session.create_dataframe([[1, 1], [2, 4] ,[3, 0]], schema=["a", "b"])
            >>> df2.select(df2["a"].in_(df2["b"]).alias("is_a_in_b")).collect()
            [Row(IS_A_IN_B=True), Row(IS_A_IN_B=False), Row(IS_A_IN_B=False)]

        Args:
            vals: The literal values, the columns in the same DataFrame, or a :class:`DataFrame` instance to use
                to check for membership against this column.
        NFr   in_r   c                 ,   t        | t        t        t        f      rUt	        |       k(  r,t        | D cg c]  }t        j                  |       c}      S t        dt	        |        d d      t        | t        j                  j                        rft	        | j                  j                        k(  rt        | j                        S t        dt	        | j                  j                         d d      t        j                  |       S c c}w )NzThe number of values z& does not match the number of columns r   )r]   rb   rc   ra   r   r   rX   r   r   r^   r_   r`   schemafieldsr!   _plan)valuevcolumn_counts     rg   value_mapperz Column.in_.<locals>.value_mapper  s    %%d!34u:--5.Qavq/A.QRR$/E
|;abnaoopq  E9#5#5#?#?@u||**+|;)%++66$/ELL4G4G0H/IIop|o}}~  u-- /Rs   Dr   
value_exprc                     t        | t        t        t        t        f      ry t        | t
              r| j                  D ]
  } |        y t        dt        |        d      )Nr\   z' is not supported for the values parameter of the function in(). You must either specify a sequence of literals or a DataFrame that represents a subquery.)	r]   r   r&   r%   r.   r   expressionsrd   re   )r   r}   validate_values     rg   r   z"Column.in_.<locals>.validate_value  sn    )5H$ O 
,>? * 6 6 -&t,-#D,- .1 2 ri   )rC   r   r   	column_inrT   r   r{   rX   r   rh   r]   r   r   r   r   r!   r   valuesr   r^   r_   	dataframer`   _set_ast_refr6   r   )r   r[   r   colsr   	proto_astrT   r   value_expressionsvevalval_astr   r   s               @@rg   r   z
Column.in_s  s   j -d3 CjjlMM	&&tyy1'%.siHH6:;ssE*;; $**,>?   ,,- 		.$ ;??3\#.??t9>,=a,@.!Q: " ( #r"# **,CIMM""499- =#**..0c9#5#5#?#?#I#IJ$$W-.w<= ))+<=
 	
} <4 @s   1G/
G4lower_boundupper_boundc                    d}|r| j                   zt        j                         }t        |j                        }|j
                  j                  | j                          t        |j                  |       t        |j                  |       t        j                  |      | k  | t        j                  |      k  z  }||_         |S )z$Between lower bound and upper bound.N)r{   r   r   r;   column_betweenrT   r   r7   r  r  rX   r   )r   r  r  r[   r}   r   rets          rg   betweenzColumn.between  s     .::<D#D$7$78CGGTYY'9#//;W9#//;W{+t3FOOK00
 
ri   c                 T   d}|rp| j                   dt        j                         }t        |j                        }|j
                  j                  | j                          t        |j                  |       t        t        t        j                  |      | j                        ||      S )zBitwise and.Nr   )r{   r   r   r;   bit_andr   r   r7   r   rX   r   r   r   r   r   r[   r}   r   s        rg   bitandzColumn.bitand  ~    
 .::<D#DLL1CGGTYY'9#''5Ivu-t/?/?@
 	
ri   c                 T   d}|rp| j                   dt        j                         }t        |j                        }|j
                  j                  | j                          t        |j                  |       t        t        t        j                  |      | j                        ||      S )zBitwise or.Nr   )r{   r   r   r;   bit_orr   r   r7   r   rX   r	   r   r   r  s        rg   bitorzColumn.bitor  s~    
 .::<D#DKK0CGGTYY'9#''5Ifooe,d.>.>?
 	
ri   c                 T   d}|rp| j                   dt        j                         }t        |j                        }|j
                  j                  | j                          t        |j                  |       t        t        t        j                  |      | j                        ||      S )zBitwise xor.Nr   )r{   r   r   r;   bit_xorr   r   r7   r   rX   r
   r   r   r  s        rg   bitxorzColumn.bitxor0  r  ri   c                    d}| j                   du}|rNt        j                         }t        |j                        }|j
                  j                  | j                          t        t        | j                        ||      S )zUnary minus.Nr   )
r{   r   r   r;   negoperandr   rX   r3   r   r   r}   r[   r   s       rg   __neg__zColumn.__neg__C  sc     IIT)	::<D#DHH-CKK  +j!1!12SSri   c                 f   d}|xr | j                  |      x}rdt        j                         }t        |j                        }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )z@Equal to. You can use this for comparisons against a null value.Nr   )r   r   r   r;   column_equal_nullr   r   r{   r7   r   rX   r   r   r   r  s        rg   
equal_nullzColumn.equal_nullO  s     !Nd&G&G&NN9N::<D#D$:$:;CGGTYY'9#''5I$**FOOE,BC
 	
ri   c                     d}|rZ| j                   Nt        j                         }t        |j                        }|j
                  j                  | j                          t        t        | j                        ||      S )zIs NaN.Nr   )
r{   r   r   r;   column_equal_nanrT   r   rX   r/   r   r   r[   r}   r   s       rg   	equal_nanzColumn.equal_nan^  s`     .::<D#D$9$9:CGGTYY'eD,,-DINNri   c                     d}|rZ| j                   Nt        j                         }t        |j                        }|j
                  j                  | j                          t        t        | j                        ||      S )zIs null.Nr   )
r{   r   r   r;   column_is_nullrT   r   rX   r1   r   r!  s       rg   is_nullzColumn.is_nullh  s`     .::<D#D$7$78CGGTYY'fT--.TYOOri   c                     d}|rZ| j                   Nt        j                         }t        |j                        }|j
                  j                  | j                          t        t        | j                        ||      S )zIs not null.Nr   )
r{   r   r   r;   column_is_not_nullrT   r   rX   r0   r   r!  s       rg   is_not_nullzColumn.is_not_nullr  s`     .::<D#D$;$;<CGGTYY'i 0 01	RRri   c                 ^   d}| j                  |      x}rdt        j                         }t        t	        |d            }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )zAnd.Nandr   )r   r   r   r;   getattrr   r   r{   r7   r   rX   r   r   r   r   s        rg   __and__zColumn.__and__}  s    99%@@9@::<D#GD%$89CGGTYY'9#''5I  &//%"89
 	
ri   c                 ^   d }| j                  |      x}rdt        j                         }t        t	        |d            }t        |j                  |       |j                  j                  | j                         t        t        t        j                  |      | j                        ||      S )Nr*  r   r   r   r   r;   r+  r7   r   r   r   r{   rX   r   r   r   r   s        rg   __rand__zColumn.__rand__  s    99%@@9@::<D#GD%$89C9#''5IGGTYY'&(8(89
 	
ri   c                 ^   d}| j                  |      x}rdt        j                         }t        t	        |d            }|j
                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )zOr.Norr   )r   r   r   r;   r+  r   r   r{   r7   r   rX   r   r   r   r   s        rg   __or__zColumn.__or__  s    99%@@9@::<D#GD$$78CGGTYY'9#''5It!78ty
 	
ri   c                 ^   d }| j                  |      x}rdt        j                         }t        t	        |d            }t        |j                  |       |j                  j                  | j                         t        t        t        j                  |      | j                        ||      S )Nr1  r   r.  r   s        rg   __ror__zColumn.__ror__  s    99%@@9@::<D#GD$$78C9#''5IGGTYY'&(8(89
 	
ri   c                    d}| j                   du}|rNt        j                         }t        t	        |d            }|j
                  j                  | j                          t        t        | j                        ||      S )z
Unary not.Nnotr   )
r{   r   r   r;   r+  r  r   rX   r2   r   r  s       rg   
__invert__zColumn.__invert__  sd    IIT)	::<D#GD%$89CKK  +c$**+$)LLri   totry_rename_fields
add_fieldsc           	         |r|rt        d      t        |t              rt        |      }t        |t        t
        t        f      r|j                         }| j                  d}d }|rwt        j                         }t        |r|j                  n|j                        }|j                  j                  | j                         |j!                  |j"                         t%        t'        | j(                  ||||      ||      S )Nz;is_add and is_rename cannot be set to True at the same timeFr   )r   r]   rk   rB   rL   rM   rN   
_as_nestedr{   r   r   r;   column_try_castcolumn_castrT   r   	_fill_astr8  rX   r.   r   )r   r8  r9  r:  r;  r[   r}   r   s           rg   _castzColumn._cast  s     -M  b#+B/Bb9gz:;B99I::<D#DD$8$8dFVFVWCGGTYY'LL !!2t]JG
 	
ri   c                 .    | j                  |d|||      S )zCasts the value of the Column to the specified data type.
        It raises an error when  the conversion can not be performed.
        Fr:  r;  r[   rA  r   r8  r:  r;  r[   s        rg   castzColumn.cast  s)     zz'!  
 	
ri   c                 .    | j                  |d|||      S )zTries to cast the value of the Column to the specified data type.
        It returns a NULL value instead of raising an error when the conversion can not be performed.
        TrC  rD  rE  s        rg   try_castzColumn.try_cast  s)     zz'!  
 	
ri   c                    d}|r_t        j                         }t        |j                        }|j                  j                  | j                         d|j                  _        t        t        | j                  t                     ||      S )zCReturns a Column expression with values sorted in descending order.NTr   )r   r   r;   column_descrT   r   r{   
null_ordernull_order_defaultrX   r,   r   r)   r!  s       rg   desczColumn.desc  sl     ::<D#D$4$45CGGTYY'04CNN-d&&
5DI
 	
ri   c                 .   d}|r_t        j                         }t        |j                        }|j                  j                  | j                         d|j                  _        t        t        | j                  t               t                     ||      S )zwReturns a Column expression with values sorted in descending order
        (null values sorted before non-null values).NTr   )r   r   r;   rJ  rT   r   r{   rK  null_order_nulls_firstrX   r,   r   r)   r*   r!  s       rg   desc_nulls_firstzColumn.desc_nulls_first  sr     ::<D#D$4$45CGGTYY'48CNN1d&&
jlC
 	
ri   c                 .   d}|r_t        j                         }t        |j                        }|j                  j                  | j                         d|j                  _        t        t        | j                  t               t                     ||      S )zvReturns a Column expression with values sorted in descending order
        (null values sorted after non-null values).NTr   )r   r   r;   rJ  rT   r   r{   rK  null_order_nulls_lastrX   r,   r   r)   r+   r!  s       rg   desc_nulls_lastzColumn.desc_nulls_last!  sr     ::<D#D$4$45CGGTYY'37CNN0d&&
ikB
 	
ri   c                    d}|r_t        j                         }t        |j                        }|j                  j                  | j                         d|j                  _        t        t        | j                  t                     ||      S )zBReturns a Column expression with values sorted in ascending order.NTr   )r   r   r;   
column_ascrT   r   r{   rK  rL  rX   r,   r   r(   r!  s       rg   ascz
Column.asc1  sj     ::<D#DOO4CGGTYY'04CNN-d&&	449
 	
ri   c                 .   d}|r_t        j                         }t        |j                        }|j                  j                  | j                         d|j                  _        t        t        | j                  t               t                     ||      S )zvReturns a Column expression with values sorted in ascending order
        (null values sorted before non-null values).NTr   )r   r   r;   rU  rT   r   r{   rK  rO  rX   r,   r   r(   r*   r!  s       rg   asc_nulls_firstzColumn.asc_nulls_first>  sp     ::<D#DOO4CGGTYY'48CNN1d&&	Z\B
 	
ri   c                 .   d}|r_t        j                         }t        |j                        }|j                  j                  | j                         d|j                  _        t        t        | j                  t               t                     ||      S )zuReturns a Column expression with values sorted in ascending order
        (null values sorted after non-null values).NTr   )r   r   r;   rU  rT   r   r{   rK  rR  rX   r,   r   r(   r+   r!  s       rg   asc_nulls_lastzColumn.asc_nulls_lastN  sp     ::<D#DOO4CGGTYY'37CNN0d&&	Y[A
 	
ri   patternc                 <   d}|rdt        j                         }t        |j                        }|j                  j                  | j                         t        |j                  |       t        t        | j                  t        j                  |            ||      S )a  Allows case-sensitive matching of strings based on comparison with a pattern.

        Args:
            pattern: A :class:`Column` or a ``str`` that indicates the pattern.
                A ``str`` will be interpreted as a literal value instead of a column name.

        For details, see the Snowflake documentation on
        `LIKE <https://docs.snowflake.com/en/sql-reference/functions/like.html#usage-notes>`_.
        Nr   )r   r   r;   column_string_likerT   r   r{   r7   r[  rX   r   r   r   )r   r[  r[   r}   r   s        rg   likezColumn.like^  sw     ::<D#D$;$;<CGGTYY'9#++wO!!6??7#;<
 	
ri   
parametersc           	         d}|r|t        j                         }t        |j                        }|j                  j                  | j                         t        |j                  |       |t        |j                  |       t        t        | j                  t        j                  |      |dnt        j                  |            ||      S )a  Returns true if this Column matches the specified regular expression.

        Args:
            pattern: A :class:`Column` or a ``str`` that indicates the pattern.
                A ``str`` will be interpreted as a literal value instead of a column name.

        For details, see the Snowflake documentation on
        `regular expressions <https://docs.snowflake.com/en/sql-reference/functions-regexp.html#label-regexp-general-usage-notes>`_.

        :meth:`rlike` is an alias of :meth:`regexp`.

        Nr   )r   r   r;   column_regexprT   r   r{   r7   r[  r_  rX   r    r   r   )r   r[  r_  r[   r}   r   s         rg   regexpzColumn.regexpu  s    & ::<D#D$6$67CGGTYY'9#++wO%=NNJ   ("*
0K
 
 	
ri   c                    d}|rdt        j                         }t        |j                        }|j                  j                  | j                         t        |j                  |       t        |t              r|n(t        j                  j                  j                  |      }t        t        j                  j                  j                  | |      j                   ||      S )a  Returns true if this Column starts with another string.

        Args:
            other: A :class:`Column` or a ``str`` that is used to check if this column starts with it.
                A ``str`` will be interpreted as a literal value instead of a column name.
        Nr   )r   r   r;   column_string_starts_withrT   r   r{   r7   prefixr]   rX   r^   r_   	functionslit
startswithr   r  s        rg   rh  zColumn.startswith  s     ::<D#D$B$BCCGGTYY'9#**eL %( ##--11%8 	
 ((33D%@LL
 	
ri   c                    d}|rdt        j                         }t        |j                        }|j                  j                  | j                         t        |j                  |       t        |t              r|n(t        j                  j                  j                  |      }t        t        j                  j                  j                  | |      j                   ||      S )a  Returns true if this Column ends with another string.

        Args:
            other: A :class:`Column` or a ``str`` that is used to check if this column ends with it.
                A ``str`` will be interpreted as a literal value instead of a column name.
        Nr   )r   r   r;   column_string_ends_withrT   r   r{   r7   suffixr]   rX   r^   r_   rf  rg  endswithr   r  s        rg   rl  zColumn.endswith  s     ::<D#D$@$@ACGGTYY'9#**eL %( ##--11%8 	
 ((11$>JJ
 	
ri   	start_poslengthc                    d}|rzt        j                         }t        |j                        }|j                  j                  | j                         t        |j                  |       t        |j                  |       t        t        j                  j                  j                  | ||      j                  ||      S )aD  Returns a substring of this string column.

        Args:
            start_pos: The starting position of the substring. Please note that the first character has position 1 instead of 0 in Snowflake database.
            length: The length of the substring.

        :meth:`substring` is an alias of :meth:`substr`.
        Nr   )r   r   r;   column_string_substrrT   r   r{   r7   posr   rX   r^   r_   rf  	substringr   )r   rm  rn  r[   r}   r   s         rg   substrzColumn.substr  s     ::<D#D$=$=>CGGTYY'9#''9M9#''6J((224FKWW
 	
ri   collation_specc                    d}|rdt        j                         }t        |j                        }|j                  j                  | j                         t        |j                  |       t        t        | j                  |      ||      S )ac  Returns a copy of the original :class:`Column` with the specified ``collation_spec``
        property, rather than the original collation specification property.

        For details, see the Snowflake documentation on
        `collation specifications <https://docs.snowflake.com/en/sql-reference/collation.html#label-collation-specification>`_.
        Nr   )r   r   r;   column_string_collaterT   r   r{   r7   rt  rX   r   r   )r   rt  r[   r}   r   s        rg   collatezColumn.collate  ss     ::<D#D$>$>?CGGTYY'9""N D$$n5DI
 	
ri   stringc                 R   d}|rdt        j                         }t        |j                        }|j                  j                  | j                         t        |j                  |       t        t        j                  j                  j                  | |      j                  ||      S )zReturns true if the column contains `string` for each row.

        Args:
            string: the string to search for in this column.
        Nr   )r   r   r;   column_string_containsrT   r   r{   r7   r[  rX   r^   r_   rf  containsr   )r   rx  r[   r}   r   s        rg   r{  zColumn.contains  s     ::<D#D$?$?@CGGTYY'9#++vN((11$?KK
 	
ri   c                 f    t        | j                  t              r| j                  j                  S dS )z3Returns the column name (if the column has a name).N)r]   r   r   namer   s    rg   get_namezColumn.get_name  s4     $**O< !!	
 	
ri   c                 "    d| j                    dS )NzColumn[]r   r   s    rg   __str__zColumn.__str__      ))*!,,ri   c                 "    d| j                    dS )NzColumn()r  r   s    rg   __repr__zColumn.__repr__  r  ri   aliasc                 *    | j                  |d|      S )4Returns a new renamed Column. Alias of :func:`name`.as_variantr[   r}  r   r  r[   s      rg   r  z
Column.as_"  s     yyyCCri   c                 *    | j                  |d|      S )r  r  r  r  r  s      rg   r  zColumn.alias'  s     yy9yEEri   c                 *    | j                  |dd      S )zRReturns a new renamed Column called by functions that internally alias the result._aliasFr  r  )r   r  s     rg   r  zColumn._alias,  s    yyEyBBri   r  )r  r  r}  c                 2   | j                   }t        |t              r|j                  }d}|r| j                  t        j                         }t        |j                        }|j                  j                  | j                         ||_        |dk(  rd|j                  _        n-|dk(  rd|j                  _        n|dk(  rd|j                  _        |dk(  r!t!        t#        |t%        |            ||      S t!        t        |t%        |            ||      S )zReturns a new renamed Column.Nr  Tr  r}  r  r   )r   r]   r-   childr{   r   r   r;   column_aliasrT   r   r}  fncolumn_alias_fn_ascolumn_alias_fn_aliascolumn_alias_fn_namerX   r5   rE   )r   r  r  r[   r}   ast_exprr   s          rg   r}  zColumn.name0  s     dE"::D.zz|H#H$9$9:CGGTYY'CH%,0)G#/3,F".2+htZ%67# 
 $
5)*Y
 	
ri   windowc                 \   d}|rut        j                         }t        |j                        }|j                  j                  | j                         |r%|j                  j                  |j                         |st        j                         }|j                  | j                  ||      S )zp
        Returns a window frame, based on the specified :class:`~snowflake.snowpark.window.WindowSpec`.
        N)r   r[   )r   r   r;   column_overrT   r   r{   window_specrO   _spec_with_aggregater   )r   r  r[   r   r}   s        rg   overzColumn.overR  s     **,C$S__5DHHdii(  ))&++6\\^F%%d&6&6C9%UUri   r   c          	      p   d}|rt        j                         }t        |j                        }|j                  j                  | j                         t        |      dk(  xr t        |d   t        t        t        f       |j                  _        g }t        | D ]  }t        |t              rQ|r=|j                  J j                  j                   j#                  |j                         |j#                  |       dt        |t$              rR|r5j                  j                   j'                         }||j(                  _        |j#                  t        |             t-        dt/        |              t        t1        | j2                  |D cg c]  }|j2                   c}      ||      S c c}w )a  
        Returns a Column expression that adds a WITHIN GROUP clause
        to sort the rows by the specified columns.

        This method is supported on Column expressions returned by some
        of the aggregate functions, including :func:`functions.array_agg`,
        :func:`functions.listagg`, PERCENTILE_CONT(), and PERCENTILE_DISC().
        For details, see the Snowflake documentation for the aggregate function
        that you are using (e.g. `ARRAY_AGG <https://docs.snowflake.com/en/sql-reference/functions/array_agg.html>`_).

        Examples::

            >>> from snowflake.snowpark.functions import array_agg, col
            >>> from snowflake.snowpark import Window

            >>> df = session.create_dataframe([(3, "v1"), (1, "v3"), (2, "v2")], schema=["a", "b"])
            >>> # create a DataFrame containing the values in "a" sorted by "b"
            >>> df.select(array_agg("a").within_group(col("b").asc()).alias("new_column")).show()
            ----------------
            |"NEW_COLUMN"  |
            ----------------
            |[             |
            |  3,          |
            |  2,          |
            |  1           |
            |]             |
            ----------------
            <BLANKLINE>
            >>> # create a DataFrame containing the values in "a" grouped by "b"
            >>> # and sorted by "a" in descending order.
            >>> df_array_agg_window = df.select(array_agg("a").within_group(col("a").desc()).over(Window.partitionBy(col("b"))).alias("new_column"))
            >>> df_array_agg_window.show()
            ----------------
            |"NEW_COLUMN"  |
            ----------------
            |[             |
            |  3           |
            |]             |
            |[             |
            |  1           |
            |]             |
            |[             |
            |  2           |
            |]             |
            ----------------
            <BLANKLINE>
        Nr   r   z,'WITHIN_GROUP' expected Column or str, got: r   )r   r   r;   column_within_grouprT   r   r{   r   r]   ra   rb   rc   r   variadicrC   rX   argsappendrk   r   
string_valr   rd   re   r'   r   )	r   r[   r   r}   r   order_by_colsrT   col_astorder_by_cols	            rg   within_groupzColumn.within_groupf  sn   h ::<D#D$<$<=CGGTYY'D	QJ:d1geS7I#J!CHH
 0$7 	C#v&88///HHMM((2$$S)C%!hhmm//1G+.G&&($$VC[1B49+N 	    >KLl))L 
 	
 Ms   F3c                 x    t        | j                  t              r| j                  S t        | j                        S r   )r]   r   r   r4   r   s    rg   _namedzColumn._named  s/    d&&8###"4#3#344ri   r}   c                 l    t        ||       r|j                  S t        |t              r|S t        |      S )a;  
        Convert a Column object, or an literal value to an expression.
        If it's a Column, get its expression.
        If it's already an expression, return it directly.
        If it's a literal value (here we treat str as literal value instead of column name),
        create a Literal expression.
        )r]   r   r   r   )clsr}   s     rg   r   zColumn._to_expr  s3     dC ###j)K4= ri   er   c                 ,     | t        |d      |      S )NT)r   r{   )r%   )r  r  r   s      rg   rl   zColumn._expr  s    &qd;#FFri   )NNTrX   )rW   Nr   T)rW   rX   )FFFT)FFTNT)r}  T)j__name__
__module____qualname____doc__rD   r   rk   r   r   r   r   boolr   r   r   rt   r   r=   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rA   rS   r   r  r  r  r  r  r  r"  r%  r(  r,  r/  r2  r4  r7  rG   rA  rF  rH  rM  rP  rS  rV  rX  rZ  r>   r^  rb  rh  rl  rs  rw  r?   r{  r~  r  r  r  r  r  typingr   r}  rP   r  r  r   r  classmethodr   rl   isinastyperlikerr  
bitwiseAnd	bitwiseOR
bitwiseXOR	isNotNullisNull
eqNullSafegetNamegetItemgetField ri   rg   rX   rX      s
   Uz   $%)&.J, $)J,S*_%J, }J, uzz"	J,
 J, smJ, !J, 
J, J,X%# %$ %DsCx DX D4
XE/:"=> 
X8 
X
E/:"=> 
8 

E/:"=> 
8 

E/:"=> 
8 

E/:"=> 
8 

E/:"=> 
8 

U?J#>? 
H 

eOZ$?@ 
X 

U?J#>? 
H 

eOZ$?@ 
X 

U?J#>? 
H 

eOZ$?@ 
X 


'B!C 
 

%(C"D 
 

U?J#>? 
H 

eOZ$?@ 
X 

U?J#>? 
H 

eOZ$?@ 
X 

$ 




&  B
[!X*	,
B
 B
 
B
 B
H 
 	?J67 ?J67 	
 
 * KO
?J67
DH
	
 
  KO
?J67
DH
	
 
  KO
?J67
DH
	
 
$
T 
 
T 
X 
 
 O4 O8 O O P P P P ST SX S S
U8S=1 
h 

eHcM2 
x 


E(C-0 

X 


U8S=1 
h 
	M # 
#x- 
 
 	

 
 
 

B  $ 
#x- 
 
 	

 
 

 
$  $ 
#x- 
 
 	

 
 

 
$ 

d 

h 

 

 
$ 
( 
 
 
 
 
 
 

T 

X 

 

 
 
 
 
 
 
 
 
 
. 
4 
8 
 
,  48	%
#%
 /0%
 	%

 
%
 %
N 
 2 
t 
x 
 
0 
0 
T 
X 
 
2 
 	
3'
 hm$
 	

 

 
8 
c 
d 
h 
 
& 
| 
 
 
 
$
(3- 
-- D D D D D F3 F4 F8 F FCC CH C  ;A	

  67
 	

 

 
B EIVz*V>BV	V V& TXU
<,)??@U
MQU
	U
 U
n5 5 !E/:"=> !: ! ! Gc G 4 G G G DFEIJIJIFJGGHri   c                        e Zd ZdZe	 	 ddddedeej                     de	de	d	df
 fd
       Z
e	 ddedede	d	d fd       Zeddede	d	d fd       ZeZ xZS )CaseExpra#  
    Represents a `CASE <https://docs.snowflake.com/en/sql-reference/functions/case.html>`_
    expression.

    To construct this object for a CASE expression, call the :func:`functions.when`
    specifying a condition and the corresponding result for that condition.
    Then, call :func:`when` and :func:`otherwise` methods to specify additional conditions
    and results.

    Examples::

        >>> from snowflake.snowpark.functions import when, col, lit

        >>> df = session.create_dataframe([[None], [1], [2]], schema=["a"])
        >>> df.select(when(col("a").is_null(), lit(1)) \
        ...     .when(col("a") == 1, lit(2)) \
        ...     .otherwise(lit(3)).alias("case_when_column")).collect()
        [Row(CASE_WHEN_COLUMN=1), Row(CASE_WHEN_COLUMN=2), Row(CASE_WHEN_COLUMN=3)]
    NFrw   r}   r{   r[   rx   rW   c                N    t         |   ||||       |j                  | _        y )N)rx   r{   r[   )superr   branches	_branches)r   r}   r{   r[   rx   	__class__s        rg   r   zCaseExpr.__init__  s.     	%7di 	 	
 ri   	conditionr   c           	      |   |rct        | j                  j                  j                  j	                               }t        |j                  |       t        |j                  |       t        t        g | j                  t        |d      j                  t        j                  |      f      | j                  |      S )aC  
        Appends one more WHEN condition to the CASE expression.

        Args:
            condition: A :class:`Column` expression or SQL text representing the specified condition.
            value: A :class:`Column` expression or a literal value, which will be returned
                if ``condition`` is true.
        whenr   )r;   r{   column_case_exprcasesr   r8   r  r7   r   r  r   r  rm   r   rX   r   )r   r  r   r[   	case_exprs        rg   r  zCaseExpr.when  s     )$))*D*D*J*J*N*N*PQI6y7J7JIV9)//5Q^^ ,Iv>JJ. 
 	
ri   c                    |rMt        | j                  j                  j                  j	                               }t        |j                  |       t        t        | j                  t        j                  |            | j                        S )zsSets the default result for this CASE expression.

        :meth:`else_` is an alias of :meth:`otherwise`.
        r  )r;   r{   r  r  r   r7   r   r  r   r  rX   r   )r   r   r[   r  s       rg   	otherwisezCaseExpr.otherwise+  sb     )$))*D*D*J*J*N*N*PQI9)//5QT^^V__U%;<499
 	
ri   r  r  )r  r  r  r  rD   r   r   r   r   r  r   r@   r=   r  r  else___classcell__)r  s   @rg   r  r    s    (  &*	' $)'' uzz"' 	' !' 
' ' TX
(
1@
MQ
	
 
> 

 

4 

: 

 

 Eri   r  zMETADATA$FILE_ROW_NUMBERzMETADATA$FILE_CONTENT_KEYzMETADATA$FILE_LAST_MODIFIEDzMETADATA$START_SCAN_TIMEzMETADATA$FILENAME)vsysr  r   r   r   snowflake.snowparkr^   4snowflake.snowpark._internal.proto.generated.ast_pb2r_   	_internalr   	generatedast_pb27snowflake.snowpark._internal.analyzer.binary_expressionr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   0snowflake.snowpark._internal.analyzer.expressionr   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   5snowflake.snowpark._internal.analyzer.sort_expressionr(   r)   r*   r+   r,   6snowflake.snowpark._internal.analyzer.unary_expressionr-   r.   r/   r0   r1   r2   r3   r4   r5   &snowflake.snowpark._internal.ast.utilsr6   r7   r8   r9   r:   r;   'snowflake.snowpark._internal.type_utilsr<   r=   r>   r?   r@   rA   rB   "snowflake.snowpark._internal.utilsrC   rD   rE   rF   snowflake.snowpark.typesrG   rH   rI   rJ   rK   rL   rM   rN   snowflake.snowpark.windowrO   rP   version_inforS   collections.abcrk   rh   rm   rr   rt   ru   rX   r  METADATA_FILE_ROW_NUMBERMETADATA_FILE_CONTENT_KEYMETADATA_FILE_LAST_MODIFIEDMETADATA_START_SCAN_TIMEMETADATA_FILENAMEr~  r  NTZLTZMETADATA_COLUMN_TYPESr  ri   rg   <module>r     s     ' '  D D D    (    $ 
 
 
    	 	 	 9
 v(

	 >>	?

LO




_ 
 
 

 
 
 


u\3%67 

C 

H 

E EP*Qv Ql ""<= "#>? $%BC !"<= ./  %%'%%''')=9J9N9N+O$$&6G6K6K(L ri   