Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/sql/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/sql/__pycache__/functions.cpython-312.pyc
�

���gr���	�UdZddlmZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lmZddlm
Z
ddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$dd l%m&Z&dd!l%m'Z'dd"l%m(Z(dd#l%m)Z)dd$l%m*Z*dd%l%m+Z+dd&l%m,Z,dd'l%m-Z-dd(l%m.Z.dd)l%m/Z/dd*l%m0Z0dd+l%m1Z1dd,l%m2Z2dd-l3m4Z4dd.l3m5Z5dd/l3m6Z6dd0lm7Z7dd1lm8Z8dd2l9m:Z:d3dlmZer`dd4lm;Z;dd5lm<Z<dd6lm=Z=dd7lm>Z>dd8lm?Z?dd9lm@Z@dd:lmAZAdd;l%mBZBdd<l%mCZCdd=l%mDZDdd>lmEZEd3d?lFmGZGd3d@lHmIZId3dAlJmKZKd3dBlJmLZLd3dClMmNZNedDe�E�ZOedFe�E�ZPej�eR�ZSdGeTdH<	d�							d�dI�ZUGdJ�dKe"e+eOe4e#�ZVGdL�dMe'e�ZWGdN�dOe0eO�ZXGdP�dQ�ZYeY�ZZeYjeZ_eYdR�S�Z[GdT�dUeVeO�Z\GdV�dWe\eO�Z]eUdXe)�eUdYe,�GdZ�d[e]e^�Z_Gd\�d]e]eO�Z`Gd^�d_e]eO�ZaGd`�daeaeO�ZbGdb�dceaeO�ZcGdd�deeaeO�ZdGdf�dgeaeO�ZeGdh�die]ej�ZfGdj�dke]eg�ZhGdl�dme]e^�ZiGdn�doe]ej�ZkGdp�dqe]e^�ZlGdr�dse`ej��ZnGdt�due`ej��ZpGdv�dwe`ej�ZqGdx�dye`eg�ZrGdz�d{e`ej�ZsGd|�d}e`ej�ZtGd~�de`eg�ZuGd��d�e`ej�ZvGd��d�e`eg�ZwGd��d�e]eO�ZxGd��d�e]eO�ZyGd��d�eyeO�ZzGd��d�eyeO�Z{Gd��d�eyeO�Z|Gd��d�e]e^�Z}Gd��d�e]e^�Z~Gd��d�e]ej��Z�Gd��d�e]ej��Z�Gd��d�e]eO�Z�Gd��d�e]eO�Z�Gd��d�e]eO�Z�Gd��d�e]eg�Z�y)�z6SQL function API, factories, and built-in functions.

�)�annotationsN)�Any)�cast)�Dict)�List)�Mapping)�Optional)�overload)�Sequence)�Tuple)�Type)�
TYPE_CHECKING)�TypeVar)�Union�)�
annotation)�	coercions)�	operators)�roles)�schema)�sqltypes)�type_api)�util)�is_table_value_type)�_entity_namespace)�ColumnCollection)�
Executable)�
Generative)�HasMemoized)�_type_from_args)�BinaryExpression)�
BindParameter)�Cast)�
ClauseList)�
ColumnElement)�Extract��FunctionFilter)�Grouping)�literal_column)�NamedColumn��Over��WithinGroup)�
FromClause)�Select)�TableValuedAlias)�TableValueType)�
TypeEngine)�InternalTraversal�)�_ByArgument)�_ColumnExpressionArgument)�"_ColumnExpressionOrLiteralArgument)�#_ColumnExpressionOrStrLabelArgument)�
_StarOrOne)�_TypeEngineArgument)�_EntityNamespace)�
ClauseElement)�KeyedColumnElement)�TableValuedColumn)�OperatorType)�
Connection)�CursorResult)�_CoreMultiExecuteParams)�CoreExecuteOptionsParameter)�Self�_T)�bound�_Sz5util.defaultdict[str, Dict[str, Type[Function[Any]]]]�	_registryc��t|}t|�j�}||vr$tjdj|��|||<y)z�Associate a callable with a particular func. name.

    This is normally called by GenericFunction, but is also
    available by itself so that a non-Function construct
    can be associated with the :data:`.func` accessor (i.e.
    CAST, EXTRACT).

    zMThe GenericFunction '{}' is already registered and is going to be overridden.N)rJ�str�lowerr�warn�format)�
identifier�fn�package�regs    �I/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/sql/functions.py�register_functionrU]sP���G�
�C��Z��&�&�(�J��S���	�	�
)�)/��
�);�	
��C�
�O�c����eZdZUdZdej
fdejfdejfgZdZ	de
d<dZdZd	Z
d
e
d<de
d<de
d
<de
d<d(d�Zd	Zed)�fd��Z								d*d�Z	d+					d,d�Z						d-d�Z	d.					d/d�Zej.d0d��Zej2d0d��Zed1d��Ze		d0d��Zej<d2d��Zd	d	d	d	d�									d3d�Z 				d4d�Z!e"d5d��Z#e"						d6d��Z#				d7d�Z#						d8d �Z$ed)d!��Z%				d9d"�Z&	d.					d:d#�Z'd;d$�Z(		d.											d<d%�Z)d+d=�fd&�
Z*ed>d'��Z+�xZ,S)?�FunctionElementa�Base for SQL function-oriented constructs.

    This is a `generic type <https://peps.python.org/pep-0484/#generics>`_,
    meaning that type checkers and IDEs can be instructed on the types to
    expect in a :class:`_engine.Result` for this function. See
    :class:`.GenericFunction` for an example of how this is done.

    .. seealso::

        :ref:`tutorial_functions` - in the :ref:`unified_tutorial`

        :class:`.Function` - named SQL function.

        :data:`.func` - namespace which produces registered or ad-hoc
        :class:`.Function` instances.

        :class:`.GenericFunction` - allows creation of registered function
        types.

    �clause_expr�_with_ordinality�_table_value_type�zTuple[str, ...]�packagenamesFNzOptional[TableValueType]r�primary_key�_is_clone_ofz
Grouping[Any]c��|D�cgc]4}tjtj|t	|dd�|����6}}|j
xst
|�|_tt|tjdd���|_ycc}w)aOConstruct a :class:`.FunctionElement`.

        :param \*clauses: list of column expressions that form the arguments
         of the SQL function call.

        :param \**kwargs:  additional kwargs are typically consumed by
         subclasses.

        .. seealso::

            :data:`.func`

            :class:`.Function`

        �nameN�ra�apply_propagate_attrsT��operator�group_contents)r�expectr�ExpressionElementRole�getattr�	_has_args�boolr)r$r�comma_oprY)�self�clauses�c�argss    rT�__init__zFunctionElement.__init__�s���.�:
���

����+�+���T�6�4�0�&*�	
��	
�:
����5�4��:���#��$�	� 2� 2�4�O�
����:
s�9Bc�6��t�|�xs
t|dd�S)Nra)�super�
_proxy_keyri)rm�	__class__s �rTrtzFunctionElement._proxy_key�s����w�!�@�W�T�6�4�%@�@rVc�(�|j|||�S�N)�_execute_function)rm�
connection�distilled_params�execution_optionss    rT�_execute_on_connectionz&FunctionElement._execute_on_connection�s ���+�+��"�$5�
�	
rVc��t|||�S)a�Return a column expression that's against this
        :class:`_functions.FunctionElement` as a scalar
        table-valued expression.

        The returned expression is similar to that returned by a single column
        accessed off of a :meth:`_functions.FunctionElement.table_valued`
        construct, except no FROM clause is generated; the function is rendered
        in the similar way as a scalar subquery.

        E.g.:

        .. sourcecode:: pycon+sql

            >>> from sqlalchemy import func, select
            >>> fn = func.jsonb_each("{'k', 'v'}").scalar_table_valued("key")
            >>> print(select(fn))
            {printsql}SELECT (jsonb_each(:jsonb_each_1)).key

        .. versionadded:: 1.4.0b2

        .. seealso::

            :meth:`_functions.FunctionElement.table_valued`

            :meth:`_functions.FunctionElement.alias`

            :meth:`_functions.FunctionElement.column_valued`

        )�ScalarFunctionColumn)rmra�type_s   rT�scalar_table_valuedz#FunctionElement.scalar_table_valued�s��B$�D�$��6�6rVc��|j�}|jdd�}|jdd�}|jdd�}|r
||fz
}d|_t|�x|_|_|j
||��S)a�Return a :class:`_sql.TableValuedAlias` representation of this
        :class:`_functions.FunctionElement` with table-valued expressions added.

        e.g.:

        .. sourcecode:: pycon+sql

            >>> fn = func.generate_series(1, 5).table_valued(
            ...     "value", "start", "stop", "step"
            ... )

            >>> print(select(fn))
            {printsql}SELECT anon_1.value, anon_1.start, anon_1.stop, anon_1.step
            FROM generate_series(:generate_series_1, :generate_series_2) AS anon_1{stop}

            >>> print(select(fn.c.value, fn.c.stop).where(fn.c.value > 2))
            {printsql}SELECT anon_1.value, anon_1.stop
            FROM generate_series(:generate_series_1, :generate_series_2) AS anon_1
            WHERE anon_1.value > :value_1{stop}

        A WITH ORDINALITY expression may be generated by passing the keyword
        argument "with_ordinality":

        .. sourcecode:: pycon+sql

            >>> fn = func.generate_series(4, 1, -1).table_valued(
            ...     "gen", with_ordinality="ordinality"
            ... )
            >>> print(select(fn))
            {printsql}SELECT anon_1.gen, anon_1.ordinality
            FROM generate_series(:generate_series_1, :generate_series_2, :generate_series_3) WITH ORDINALITY AS anon_1

        :param \*expr: A series of string column names that will be added to the
         ``.c`` collection of the resulting :class:`_sql.TableValuedAlias`
         construct as columns.  :func:`_sql.column` objects with or without
         datatypes may also be used.

        :param name: optional name to assign to the alias name that's generated.
         If omitted, a unique anonymizing name is used.

        :param with_ordinality: string name that when present results in the
         ``WITH ORDINALITY`` clause being added to the alias, and the given
         string name will be added as a column to the .c collection
         of the resulting :class:`_sql.TableValuedAlias`.

        :param joins_implicitly: when True, the table valued function may be
         used in the FROM clause without any explicit JOIN to other tables
         in the SQL query, and no "cartesian product" warning will be generated.
         May be useful for SQL functions such as ``func.json_each()``.

         .. versionadded:: 1.4.33

        .. versionadded:: 1.4.0b2


        .. seealso::

            :ref:`tutorial_functions_table_valued` - in the :ref:`unified_tutorial`

            :ref:`postgresql_table_valued` - in the :ref:`postgresql_toplevel` documentation

            :meth:`_functions.FunctionElement.scalar_table_valued` - variant of
            :meth:`_functions.FunctionElement.table_valued` which delivers the
            complete table valued expression as a scalar column expression

            :meth:`_functions.FunctionElement.column_valued`

            :meth:`_sql.TableValuedAlias.render_derived` - renders the alias
            using a derived column clause, e.g. ``AS name(col1, col2, ...)``

        �with_ordinalityN�joins_implicitlyraT�rar�)�	_generate�poprZr3�typer[�alias)rm�expr�kw�new_funcr�r�ras       rT�table_valuedzFunctionElement.table_valued�s���V�>�>�#���&�&�!2�D�9���6�6�"4�d�;���v�v�f�d�#����_�&�&�D�(,�H�%�5C�T�5J�J��
��2��~�~�4�:J�~�K�KrVc�<�|j||��jS)aQReturn this :class:`_functions.FunctionElement` as a column expression that
        selects from itself as a FROM clause.

        E.g.:

        .. sourcecode:: pycon+sql

            >>> from sqlalchemy import select, func
            >>> gs = func.generate_series(1, 5, -1).column_valued()
            >>> print(select(gs))
            {printsql}SELECT anon_1
            FROM generate_series(:generate_series_1, :generate_series_2, :generate_series_3) AS anon_1

        This is shorthand for::

            gs = func.generate_series(1, 5, -1).alias().column

        :param name: optional name to assign to the alias name that's generated.
         If omitted, a unique anonymizing name is used.

        :param joins_implicitly: when True, the "table" portion of the column
         valued function may be a member of the FROM clause without any
         explicit JOIN to other tables in the SQL query, and no "cartesian
         product" warning will be generated. May be useful for SQL functions
         such as ``func.json_array_elements()``.

         .. versionadded:: 1.4.46

        .. seealso::

            :ref:`tutorial_functions_column_valued` - in the :ref:`unified_tutorial`

            :ref:`postgresql_column_valued` - in the :ref:`postgresql_toplevel` documentation

            :meth:`_functions.FunctionElement.table_valued`

        r�)r��column�rmrar�s   rT�
column_valuedzFunctionElement.column_valuedHs��R�z�z�t�6F�z�G�N�N�NrVc��|jS)aThe set of columns exported by this :class:`.FunctionElement`.

        This is a placeholder collection that allows the function to be
        placed in the FROM clause of a statement:

        .. sourcecode:: pycon+sql

            >>> from sqlalchemy import column, select, func
            >>> stmt = select(column("x"), column("y")).select_from(func.myfunction())
            >>> print(stmt)
            {printsql}SELECT x, y FROM myfunction()

        The above form is a legacy feature that is now superseded by the
        fully capable :meth:`_functions.FunctionElement.table_valued`
        method; see that method for details.

        .. seealso::

            :meth:`_functions.FunctionElement.table_valued` - generates table-valued
            SQL function expressions.

        )ro�rms rT�columnszFunctionElement.columnsss
��0�v�v�
rVc�l�t|jD�cgc]}|j|f��c}��Scc}w)z-synonym for :attr:`.FunctionElement.columns`.�r�)r�_all_selected_columns�key)rm�cols  rTrozFunctionElement.c�s6�� �/3�/I�/I�J�/I��c�g�g�s�^�/I�J�
�	
��Js�1c��t|j�r"td|jj�}|S|j	d�g}|S)N�!Sequence[KeyedColumnElement[Any]])rr�r�	_elements�label)rm�colss  rTr�z%FunctionElement._all_selected_columns�sF���t�y�y�)��3�T�Y�Y�5H�5H��D����J�J�t�$�%�D��rVc��|jSrwr�r�s rT�exported_columnsz FunctionElement.exported_columns�s���|�|�rVc�J�tt|jj�S)z}Return the underlying :class:`.ClauseList` which contains
        the arguments for this :class:`.FunctionElement`.

        )rr$rY�elementr�s rTrnzFunctionElement.clauses�s���J�� 0� 0� 8� 8�9�9rV��partition_by�order_by�rows�range_c�"�t|||||��S)aBProduce an OVER clause against this function.

        Used against aggregate or so-called "window" functions,
        for database backends that support window functions.

        The expression::

            func.row_number().over(order_by="x")

        is shorthand for::

            from sqlalchemy import over

            over(func.row_number(), order_by="x")

        See :func:`_expression.over` for a full description.

        .. seealso::

            :func:`_expression.over`

            :ref:`tutorial_window_functions` - in the :ref:`unified_tutorial`

        r�r,)rmr�r�r�r�s     rT�overzFunctionElement.over�s!��@��%����
�	
rVc��t|g|���S)a�Produce a WITHIN GROUP (ORDER BY expr) clause against this function.

        Used against so-called "ordered set aggregate" and "hypothetical
        set aggregate" functions, including :class:`.percentile_cont`,
        :class:`.rank`, :class:`.dense_rank`, etc.

        See :func:`_expression.within_group` for a full description.

        .. seealso::

            :ref:`tutorial_functions_within_group` -
            in the :ref:`unified_tutorial`


        r.)rmr�s  rT�within_groupzFunctionElement.within_group�s��$�4�+�(�+�+rVc��yrwr\r�s rT�filterzFunctionElement.filter�s��!rVc��yrwr\)rm�_FunctionElement__criterion0�	criterions   rTr�zFunctionElement.filter�s��
!rVc�"�|s|St|g|���S)a'Produce a FILTER clause against this function.

        Used against aggregate and window functions,
        for database backends that support the "FILTER" clause.

        The expression::

            func.count(1).filter(True)

        is shorthand for::

            from sqlalchemy import funcfilter

            funcfilter(func.count(1), True)

        .. seealso::

            :ref:`tutorial_functions_within_group` -
            in the :ref:`unified_tutorial`

            :class:`.FunctionFilter`

            :func:`.funcfilter`


        r')rmr�s  rTr�zFunctionElement.filter�s��:��K��d�/�Y�/�/rVc��t|||�S)asInterpret this expression as a boolean comparison between two
        values.

        This method is used for an ORM use case described at
        :ref:`relationship_custom_operator_sql_function`.

        A hypothetical SQL function "is_equal()" which compares to values
        for equality would be written in the Core expression language as::

            expr = func.is_equal("a", "b")

        If "is_equal()" above is comparing "a" and "b" for equality, the
        :meth:`.FunctionElement.as_comparison` method would be invoked as::

            expr = func.is_equal("a", "b").as_comparison(1, 2)

        Where above, the integer value "1" refers to the first argument of the
        "is_equal()" function and the integer value "2" refers to the second.

        This would create a :class:`.BinaryExpression` that is equivalent to::

            BinaryExpression("a", "b", operator=op.eq)

        However, at the SQL level it would still render as
        "is_equal('a', 'b')".

        The ORM, when it loads a related object or collection, needs to be able
        to manipulate the "left" and "right" sides of the ON clause of a JOIN
        expression. The purpose of this method is to provide a SQL function
        construct that can also supply this information to the ORM, when used
        with the :paramref:`_orm.relationship.primaryjoin` parameter. The
        return value is a containment object called :class:`.FunctionAsBinary`.

        An ORM example is as follows::

            class Venue(Base):
                __tablename__ = "venue"
                id = Column(Integer, primary_key=True)
                name = Column(String)

                descendants = relationship(
                    "Venue",
                    primaryjoin=func.instr(
                        remote(foreign(name)), name + "/"
                    ).as_comparison(1, 2)
                    == 1,
                    viewonly=True,
                    order_by=name,
                )

        Above, the "Venue" class can load descendant "Venue" objects by
        determining if the name of the parent Venue is contained within the
        start of the hypothetical descendant value's name, e.g. "parent1" would
        match up to "parent1/child1", but not to "parent2/child1".

        Possible use cases include the "materialized path" example given above,
        as well as making use of special SQL functions such as geometric
        functions to create join conditions.

        :param left_index: the integer 1-based index of the function argument
         that serves as the "left" side of the expression.
        :param right_index: the integer 1-based index of the function argument
         that serves as the "right" side of the expression.

        .. versionadded:: 1.3

        .. seealso::

            :ref:`relationship_custom_operator_sql_function` -
            example use within the ORM

        )�FunctionAsBinary)rm�
left_index�right_indexs   rT�
as_comparisonzFunctionElement.as_comparisons��V ��j�+�>�>rVc�.�|jjSrw)rn�
_from_objectsr�s rTr�zFunctionElement._from_objectscs���|�|�)�)�)rVc��y)aFor types that define their return type as based on the criteria
        within a WITHIN GROUP (ORDER BY) expression, called by the
        :class:`.WithinGroup` construct.

        Returns None by default, in which case the function's normal ``.type``
        is used.

        Nr\)rmr�s  rT�within_group_typez!FunctionElement.within_group_typegs��rVc�H�tj|||j|��S)a+
Produce a :class:`_expression.Alias` construct against this
        :class:`.FunctionElement`.

        .. tip::

            The :meth:`_functions.FunctionElement.alias` method is part of the
            mechanism by which "table valued" SQL functions are created.
            However, most use cases are covered by higher level methods on
            :class:`_functions.FunctionElement` including
            :meth:`_functions.FunctionElement.table_valued`, and
            :meth:`_functions.FunctionElement.column_valued`.

        This construct wraps the function in a named alias which
        is suitable for the FROM clause, in the style accepted for example
        by PostgreSQL.  A column expression is also provided using the
        special ``.column`` attribute, which may
        be used to refer to the output of the function as a scalar value
        in the columns or where clause, for a backend such as PostgreSQL.

        For a full table-valued expression, use the
        :meth:`_functions.FunctionElement.table_valued` method first to
        establish named columns.

        e.g.:

        .. sourcecode:: pycon+sql

            >>> from sqlalchemy import func, select, column
            >>> data_view = func.unnest([1, 2, 3]).alias("data_view")
            >>> print(select(data_view.column))
            {printsql}SELECT data_view
            FROM unnest(:unnest_1) AS data_view

        The :meth:`_functions.FunctionElement.column_valued` method provides
        a shortcut for the above pattern:

        .. sourcecode:: pycon+sql

            >>> data_view = func.unnest([1, 2, 3]).column_valued("data_view")
            >>> print(select(data_view))
            {printsql}SELECT data_view
            FROM unnest(:unnest_1) AS data_view

        .. versionadded:: 1.4.0b2  Added the ``.column`` accessor

        :param name: alias name, will be rendered as ``AS <name>`` in the
         FROM clause

        :param joins_implicitly: when True, the table valued function may be
         used in the FROM clause without any explicit JOIN to other tables
         in the SQL query, and no "cartesian product" warning will be
         generated.  May be useful for SQL functions such as
         ``func.json_each()``.

         .. versionadded:: 1.4.33

        .. seealso::

            :ref:`tutorial_functions_table_valued` -
            in the :ref:`unified_tutorial`

            :meth:`_functions.FunctionElement.table_valued`

            :meth:`_functions.FunctionElement.scalar_table_valued`

            :meth:`_functions.FunctionElement.column_valued`


        )ra�table_value_typer�)r2�
_constructr�r�s   rTr�zFunctionElement.aliasus(��R �*�*���!�Y�Y�-�	
�	
rVc�l�t|�}|jr|jdi|j��}|S)z�Produce a :func:`_expression.select` construct
        against this :class:`.FunctionElement`.

        This is shorthand for::

            s = select(function_element)

        r\)r1�_execution_optionsr{)rm�ss  rT�selectzFunctionElement.select�s6�� �����"�"�#��#�#�>�d�&=�&=�>�A��rVc	�<�td|f||jd||d�|��S)NT)�_compared_to_operator�_compared_to_type�uniquer�	expanding)r"r��rmre�objrr�r�s      rT�_bind_paramzFunctionElement._bind_param�s;�����	
�#+�"�i�i����	
��	
�		
rVc���|tjur/t|jtj
�rt
|�St�|�!|��S)N)�against)	r�getitem�
isinstancer�r�ARRAYr)rs�
self_group)rmr�rus  �rTr�zFunctionElement.self_group�sF���
�i�'�'�'�J��I�I�x�~�~�-
��D�>�!��7�%�g�%�6�6rVc�,�t|j�S)zzoverrides FromClause.entity_namespace as functions are generally
        column expressions and not FromClauses.

        )rrYr�s rT�entity_namespacez FunctionElement.entity_namespace�s��!��!1�!1�2�2rV)rn�'_ColumnExpressionOrLiteralArgument[Any]��returnr)ryrBrzrDr{rEr�zCursorResult[Any]rw)rarLr�!Optional[_TypeEngineArgument[_T]]r�zScalarFunctionColumn[_T])r�z(_ColumnExpressionOrStrLabelArgument[Any]r�rr�r2�NF)ra�
Optional[str]r�rkr�zTableValuedColumn[_T])r�z.ColumnCollection[str, KeyedColumnElement[Any]])r�r�)r�r$)
r��Optional[_ByArgument]r�r�r��-Optional[Tuple[Optional[int], Optional[int]]]r�r�r�zOver[_T])r��_ColumnExpressionArgument[Any]r�zWithinGroup[_T])r�rF)r��_ColumnExpressionArgument[bool]r�r�r�zFunctionFilter[_T])r�r�r�zUnion[Self, FunctionFilter[_T]])r��intr�r�r�r�)r�zWithinGroup[_S]r�zOptional[TypeEngine[_S]])rar�r�rkr�r2)r�zSelect[Tuple[_T]]�rerAr�rrzOptional[TypeEngine[_T]]r�rkr�rr�zBindParameter[_T])r�zOptional[OperatorType]r�r>)r�r=)-�__name__�
__module__�__qualname__�__doc__r5�dp_clauseelement�
dp_boolean�dp_has_cache_key�_traverse_internalsr]�__annotations__rjrZr[rq�_non_anon_label�propertyrtr|r�r�r�r�ro_non_memoized_propertyr��ro_memoized_propertyror�r�r�memoized_attributernr�r�r
r�r�r�r�r�r�r�r�r��
__classcell__�rus@rTrXrXus;����,
�)�:�:�;�	�.�9�9�:�	�/�@�@�A���%'�L�/�&��I���26��/�6�������
�<�O�
�A��A�
��
�2�
�7�	
�

�
�EI�!7��!7� A�!7�	!�!7�FWL�=�WL�EH�WL�	�WL�tDI�)O�!�)O�<@�)O�	�)O�V
�"�"��#��2
���
��
��	��	���	7����
�#�#�:�$�:�/3�*.�>B�@D�
&
�,�&
�(�	&
�
<�&
�>�
&
�
�&
�P,�7�,�	�,�(�!��!�
�!�5�!�4�!�
�	!��!�0�9�0�	(�0�BK?��K?�,/�K?�	�K?�Z�*��*��+��	!��DI�N
�!�N
�<@�N
�	�N
�`�$+/��
��
��
�(�	
�
�
��

�
�
�&
7��3��3rVrXc�2�eZdZUdejfdej
fdej
fdejfgZded<ded<ded<dd�Z							dd�Z
edd	��Zejdd
��Zedd��Zejdd��ZeseZeZy
y
)r��sql_functionr�r��	modifiers�FunctionElement[Any]r�c�0�tj|||�Srw)r%�_gen_cache_key)rm�anon_map�
bindparamss   rTr�zFunctionAsBinary._gen_cache_key	s���+�+�D�(�J�G�GrVc��||_||_||_tj|_tj|_d|_	d|_
i|_y)NT)r�r�r�r�function_as_comparison_oprer�BOOLEANTYPEr��negate�_is_implicitly_booleanr�)rmrQr�r�s    rTrqzFunctionAsBinary.__init__sK�����$���&���!�;�;��
��(�(��	����&*��#���rVc�b�|jjj|jdz
S�Nr�r�rnr�r�s rT�	left_exprzFunctionAsBinary.left_exprs(��� � �(�(�0�0����1�1D�E�ErVc�d�||jjj|jdz
<yr�r��rm�values  rTr�zFunctionAsBinary.left_exprs'��AF����!�!�)�)�$�/�/�A�*=�>rVc�b�|jjj|jdz
Sr��r�rnr�r�s rT�
right_exprzFunctionAsBinary.right_expr!s*��� � �(�(�0�0��1A�1A�A�1E�F�FrVc�d�||jjj|jdz
<yr�rr�s  rTrzFunctionAsBinary.right_expr%s)��BG����!�!�)�)�$�*:�*:�Q�*>�?rVN)r�rr�rr�r)rQr�r�r�r�r�)r��ColumnElement[Any])rrr��None)r�r�r�r5r��dp_plain_obj�
dp_plain_dictr�r�r�rqr�r��setterrr�left�rightr\rVrTr�r��s���	�*�;�;�<�	�(�5�5�6�	�)�6�6�7�	�'�5�5�6�	��'�&��O���H��&��47��FI���F��F����G��G��G��G����H��H������rVr�c��eZdZdZdej
fdejfdejfgZdZ	dZ
	d					d	d�Zy)
r~�scalar_function_columnrar�rQFNc�T�||_||_tj|�|_yrw)rQrar�to_instancer�)rmrQrars    rTrqzScalarFunctionColumn.__init__=s&�������	��(�(��/��	rVrw)rQzFunctionElement[_T]rarLrr�)r�r�r��__visit_name__r5�dp_anon_name�dp_typer�r��
is_literal�tablerqr\rVrTr~r~1sp��-�N�
�"�/�/�0�	�"�*�*�+�	
� �1�1�2����J��E�48�	0��0��0�1�	0rVr~c��eZdZdZd7d�Zd8d�Ze								d9d��Zed:d��Zd:d�Ze�re	d;d��Z
e	d<d��Ze	d=d	��Ze	d>d
��Z
e	d?d��Ze								d@d��Ze								dAd
��Ze								dBd��Z								dBd�Ze	dCd��Ze	dDd��Ze	dEd��Ze	dFd��Ze	dGd��Ze	dHd��Ze	dId��Ze	dJd��Ze	dKd��Ze	dLd��Ze	dMd��Ze	dNd��Ze	dOd��Ze								dPd��Ze								dQd��Ze								dRd��Z								dRd �Ze								dSd!��Ze								dTd"��Ze								dUd#��Z								dUd$�Ze	dVd%��Ze	dWd&��Z e	dXd'��Z!e	dYd(��Z"e	dZd)��Z#e	d[d*��Z$e	d\d+��Z%e	d]d,��Z&e	d^d-��Z'e	d_d.��Z(e	d`d/��Z)e								dad0��Z*e								dbd1��Z*e								dcd2��Z*								dcd3�Z*e	ddd4��Z+e	ded5��Z,y6y6)f�_FunctionGeneratora�Generate SQL function expressions.

    :data:`.func` is a special object instance which generates SQL
    functions based on name-based attributes, e.g.:

    .. sourcecode:: pycon+sql

        >>> print(func.count(1))
        {printsql}count(:param_1)

    The returned object is an instance of :class:`.Function`, and  is a
    column-oriented SQL element like any other, and is used in that way:

    .. sourcecode:: pycon+sql

        >>> print(select(func.count(table.c.id)))
        {printsql}SELECT count(sometable.id) FROM sometable

    Any name can be given to :data:`.func`. If the function name is unknown to
    SQLAlchemy, it will be rendered exactly as is. For common SQL functions
    which SQLAlchemy is aware of, the name may be interpreted as a *generic
    function* which will be compiled appropriately to the target database:

    .. sourcecode:: pycon+sql

        >>> print(func.current_timestamp())
        {printsql}CURRENT_TIMESTAMP

    To call functions which are present in dot-separated packages,
    specify them in the same manner:

    .. sourcecode:: pycon+sql

        >>> print(func.stats.yield_curve(5, 10))
        {printsql}stats.yield_curve(:yield_curve_1, :yield_curve_2)

    SQLAlchemy can be made aware of the return type of functions to enable
    type-specific lexical and result-based behavior. For example, to ensure
    that a string-based function returns a Unicode value and is similarly
    treated as a string in expressions, specify
    :class:`~sqlalchemy.types.Unicode` as the type:

    .. sourcecode:: pycon+sql

        >>> print(
        ...     func.my_string("hi", type_=Unicode)
        ...     + " "
        ...     + func.my_string("there", type_=Unicode)
        ... )
        {printsql}my_string(:my_string_1) || :my_string_2 || my_string(:my_string_3)

    The object returned by a :data:`.func` call is usually an instance of
    :class:`.Function`.
    This object meets the "column" interface, including comparison and labeling
    functions.  The object can also be passed the :meth:`~.Connectable.execute`
    method of a :class:`_engine.Connection` or :class:`_engine.Engine`,
    where it will be
    wrapped inside of a SELECT statement first::

        print(connection.execute(func.current_timestamp()).scalar())

    In a few exception cases, the :data:`.func` accessor
    will redirect a name to a built-in expression such as :func:`.cast`
    or :func:`.extract`, as these names have well-known meaning
    but are not exactly the same as "functions" from a SQLAlchemy
    perspective.

    Functions which are interpreted as "generic" functions know how to
    calculate their return type automatically. For a listing of known generic
    functions, see :ref:`generic_functions`.

    .. note::

        The :data:`.func` construct has only limited support for calling
        standalone "stored procedures", especially those with special
        parameterization concerns.

        See the section :ref:`stored_procedures` for details on how to use
        the DBAPI-level ``callproc()`` method for fully traditional stored
        procedures.

    .. seealso::

        :ref:`tutorial_functions` - in the :ref:`unified_tutorial`

        :class:`.Function`

    c� �g|_||_yrw)�_FunctionGenerator__names�opts)rmrs  rTrqz_FunctionGenerator.__init__�s��"$�����	rVc�
�|jd�r	|j|S|j	d�r|dd}tdi|j��}t|j�|gz|_|S#t$rt|��wxYw)N�__�_r���r\)	�
startswith�__dict__�KeyError�AttributeError�endswithrr�listr)rmra�fs   rT�__getattr__z_FunctionGenerator.__getattr__�s����?�?�4� �
+��}�}�T�*�*��]�]�3�
���"�:�D��+����+������&�$��/��	�����
+�$�T�*�*�
+�s�A-�-Bc��yrwr\)rmrro�kwargss    rT�__call__z_FunctionGenerator.__call__�s��rVc��yrwr\)rmror's   rTr(z_FunctionGenerator.__call__����ADrVc	��|jj�}|j|�t|j�}|dk(r|j\}}n|dk(rd|jd}}nd}|�0t
|j
j��}|�||i|��St|jdg|��dt|jdd�i|��S)Nr6r�_defaultrrr])
r�copy�update�lenrrJ�getrM�Function�tuple)rmror'�o�tokensrR�fname�funcs        rTr(z_FunctionGenerator.__call__�s����I�I�N�N���	������T�\�\�"���Q�;�!�\�\�N�G�U�
�q�[�'����a��U�G��G����W�%�)�)�%�+�+�-�8�D����Q�}�!�}�$���L�L���
�GH�
�+0����a��1C�+D�
�LM�
�	
rVc��yrwr\r�s rT�aggregate_stringsz$_FunctionGenerator.aggregate_strings����@CrVc��yrwr\r�s rT�ansifunctionz_FunctionGenerator.ansifunction�s��;>rVc��yrwr\r�s rT�	array_aggz_FunctionGenerator.array_agg�s��58rVc��yrwr\r�s rTrz_FunctionGenerator.cast����+.rVc��yrwr\r�s rT�char_lengthz_FunctionGenerator.char_length�s��47rVc��yrwr\�rmr�rpr's    rT�coalescez_FunctionGenerator.coalesce����rVc��yrwr\rCs    rTrDz_FunctionGenerator.coalesce�rErVc��yrwr\rCs    rTrDz_FunctionGenerator.coalesce�rErVc��yrwr\rCs    rTrDz_FunctionGenerator.coalesces��
rVc��yrwr\r�s rT�concatz_FunctionGenerator.concat���*-rVc��yrwr\r�s rT�countz_FunctionGenerator.counts��(+rVc��yrwr\r�s rT�cubez_FunctionGenerator.cuber?rVc��yrwr\r�s rT�	cume_distz_FunctionGenerator.cume_dist���03rVc��yrwr\r�s rT�current_datez_FunctionGenerator.current_date���69rVc��yrwr\r�s rT�current_timez_FunctionGenerator.current_timerUrVc��yrwr\r�s rT�current_timestampz$_FunctionGenerator.current_timestamp r9rVc��yrwr\r�s rT�current_userz_FunctionGenerator.current_user#rUrVc��yrwr\r�s rT�
dense_rankz_FunctionGenerator.dense_rank&���25rVc��yrwr\r�s rT�extractz_FunctionGenerator.extract)���,/rVc��yrwr\r�s rT�
grouping_setsz _FunctionGenerator.grouping_sets,���=@rVc��yrwr\r�s rT�	localtimez_FunctionGenerator.localtime/rRrVc��yrwr\r�s rT�localtimestampz!_FunctionGenerator.localtimestamp2s��:=rVc��yrwr\rCs    rT�maxz_FunctionGenerator.max:���rVc��yrwr\rCs    rTrjz_FunctionGenerator.maxBrkrVc��yrwr\rCs    rTrjz_FunctionGenerator.maxJrkrVc��yrwr\rCs    rTrjz_FunctionGenerator.maxR���
rVc��yrwr\rCs    rT�minz_FunctionGenerator.min^rkrVc��yrwr\rCs    rTrqz_FunctionGenerator.minfrkrVc��yrwr\rCs    rTrqz_FunctionGenerator.minnrkrVc��yrwr\rCs    rTrqz_FunctionGenerator.minvrorVc��yrwr\r�s rT�modez_FunctionGenerator.mode}r?rVc��yrwr\r�s rT�
next_valuez_FunctionGenerator.next_value�r^rVc��yrwr\r�s rT�nowz_FunctionGenerator.now�s��$'rVc��yrwr\r�s rT�
orderedsetaggz _FunctionGenerator.orderedsetagg�rdrVc��yrwr\r�s rT�percent_rankz_FunctionGenerator.percent_rank�rUrVc��yrwr\r�s rT�percentile_contz"_FunctionGenerator.percentile_cont�r*rVc��yrwr\r�s rT�percentile_discz"_FunctionGenerator.percentile_disc�r*rVc��yrwr\r�s rT�randomz_FunctionGenerator.random�rKrVc��yrwr\r�s rT�rankz_FunctionGenerator.rank����&)rVc��yrwr\r�s rT�rollupz_FunctionGenerator.rollup�s��/2rVc��yrwr\r�s rT�session_userz_FunctionGenerator.session_user�rUrVc��yrwr\rCs    rT�sumz_FunctionGenerator.sum�rkrVc��yrwr\rCs    rTr�z_FunctionGenerator.sum�rkrVc��yrwr\rCs    rTr�z_FunctionGenerator.sum�rkrVc��yrwr\rCs    rTr�z_FunctionGenerator.sum�rorVc��yrwr\r�s rT�sysdatez_FunctionGenerator.sysdate�rarVc��yrwr\r�s rT�userz_FunctionGenerator.user�r�rVN)rr)rarLr�r)rorr�_TypeEngineArgument[_T]r'rr�zFunction[_T])rorr'rr�z
Function[Any])r�zType[aggregate_strings])r�zType[AnsiFunction[Any]])r�zType[array_agg[Any]])r�zType[Cast[Any]])r�zType[char_length])r��ColumnElement[_T]rpr�r'rr��coalesce[_T])r��_ColumnExpressionArgument[_T]rpr�r'rr�r�)r��&_ColumnExpressionOrLiteralArgument[_T]rpr�r'rr�r�)r�zType[concat])r�zType[count])r�zType[cube[Any]])r�zType[cume_dist])r�zType[current_date])r�zType[current_time])r�zType[current_timestamp])r�zType[current_user])r�zType[dense_rank])r�z
Type[Extract])r�zType[grouping_sets[Any]])r�zType[localtime])r�zType[localtimestamp])r�r�rpr�r'rr��max[_T])r�r�rpr�r'rr�r�)r�r�rpr�r'rr�r�)r�r�rpr�r'rr��min[_T])r�r�rpr�r'rr�r�)r�r�rpr�r'rr�r�)r�zType[mode[Any]])r�zType[next_value])r�z	Type[now])r�zType[OrderedSetAgg[Any]])r�zType[percent_rank])r�zType[percentile_cont[Any]])r�zType[percentile_disc[Any]])r�zType[random])r�z
Type[rank])r�zType[rollup[Any]])r�zType[session_user])r�r�rpr�r'rr��sum[_T])r�r�rpr�r'rr�r�)r�r�rpr�r'rr�r�)r�z
Type[sysdate])r�z
Type[user])-r�r�r�r�rqr%r
r(rr�r8r;r=rrArDrJrMrOrQrTrWrYr[r]r`rcrfrhrjrqrvrxrzr|r~r�r�r�r�r�r�r�r�r�r\rVrTrrKs���W�r������5��AD��	�����D��D�
�,�
�C�
�C�	�>�
�>�	�8�
�8�	�.�
�.�	�7�
�7�
�	�"�	�;�	��		�
�	�
�	�
�	�.�	�;�	��		�
�	�
�	�
�	�7�	�;�	��		�
�	�
�	�	�7�	�;�	��		�
�	�
�-�
�-�	�+�
�+�	�.�
�.�	�3�
�3�	�9�
�9�	�9�
�9�	�C�
�C�	�9�
�9�	�5�
�5�	�/�
�/�	�@�
�@�	�3�
�3�	�=�
�=�
�	�"�	�;�	��		�
�	�
�	�
�	�.�	�;�	��		�
�	�
�	�
�	�7�	�;�	��		�
�	�
�	�	�7�	�;�	��		�
�	�
�	�"�	�;�	��		�
�	�
�	�
�	�.�	�;�	��		�
�	�
�	�
�	�7�	�;�	��		�
�	�
�	�	�7�	�;�	��		�
�	�
�.�
�.�	�5�
�5�	�'�
�'�	�@�
�@�	�9�
�9�	�D�
�D�	�D�
�D�	�-�
�-�	�)�
�)�	�2�
�2�	�9�
�9�
�	�"�	�;�	��		�
�	�
�	�
�	�.�	�;�	��		�
�	�
�	�
�	�7�	�;�	��		�
�	�
�	�	�7�	�;�	��		�
�	�
�/�
�/�	�)�
�)�crVrF)�groupc�4�eZdZUdZdZejdejfdejfdejfgzZded<ded<ded<	ed	d	d
�							dd��Z
ed	d	d
�							dd��Z
d
d
d
�							dd�Z
		d											dd�Zy
)r1a�Describe a named SQL function.

    The :class:`.Function` object is typically generated from the
    :data:`.func` generation object.


    :param \*clauses: list of column expressions that form the arguments
     of the SQL function call.

    :param type\_: optional :class:`.TypeEngine` datatype object that will be
     used as the return value of the column expression generated by this
     function call.

    :param packagenames: a string which indicates package prefix names
     to be prepended to the function name when the SQL is generated.
     The :data:`.func` generator creates these when it is called using
     dotted format, e.g.::

        func.mypackage.some_function(col1, col2)

    .. seealso::

        :ref:`tutorial_functions` - in the :ref:`unified_tutorial`

        :data:`.func` - namespace which produces registered or ad-hoc
        :class:`.Function` instances.

        :class:`.GenericFunction` - allows creation of registered function
        types.

    �functionr]rar�rLrPzTypeEngine[_T].)rr]c��yrwr\�rmrarr]rns     rTrqzFunction.__init__���rVc��yrwr\r�s     rTrqzFunction.__init__r�rVNc��|xsd|_||_tj|�|_tj|g|���y)z�Construct a :class:`.Function`.

        The :data:`.func` construct is normally used to construct
        new :class:`.Function` instances.

        r\N)r]rarrr�rXrqr�s     rTrqzFunction.__init__!s?��)�.�B�����	��(�(��/��	�� � ��0��0rVc	�P�t|j|f||j|d|d�|��S)NT)r�r�rr�r�)r"rar�r�s      rTr�zFunction._bind_param7s?����I�I��	
�#+�"�i�i����	
��	
�		
rV)rarLrnr�rrr]�Optional[Tuple[str, ...]])rarLrnr�rr�r]r�)rarLrnr�rr�r]r�r�r�)r�r�r�r�rrXr�r5r�	dp_stringrr�r
rqr�r\rVrTr1r1�sh���@ �N�)�=�=�	�*�7�7�8�	�"�,�,�-�	�"�*�*�+�A����I��O�
��� �
�25����9���	�
0�����
*-�25����:��'�	�
0����48�26�1��1�:�1�1�	1�
0�1�4+/��
��
��
�(�	
�
�
��

�
�
rVr1c�j��eZdZUdZdZdZded<dZd�fd�Ze							d	d��Z
				d
d�Z�xZS)�GenericFunctionatDefine a 'generic' function.

    A generic function is a pre-established :class:`.Function`
    class that is instantiated automatically when called
    by name from the :data:`.func` attribute.    Note that
    calling any name from :data:`.func` has the effect that
    a new :class:`.Function` instance is created automatically,
    given that name.  The primary use case for defining
    a :class:`.GenericFunction` class is so that a function
    of a particular name may be given a fixed return type.
    It can also include custom argument parsing schemes as well
    as additional methods.

    Subclasses of :class:`.GenericFunction` are automatically
    registered under the name of the class.  For
    example, a user-defined function ``as_utc()`` would
    be available immediately::

        from sqlalchemy.sql.functions import GenericFunction
        from sqlalchemy.types import DateTime


        class as_utc(GenericFunction):
            type = DateTime()
            inherit_cache = True


        print(select(func.as_utc()))

    User-defined generic functions can be organized into
    packages by specifying the "package" attribute when defining
    :class:`.GenericFunction`.   Third party libraries
    containing many functions may want to use this in order
    to avoid name conflicts with other systems.   For example,
    if our ``as_utc()`` function were part of a package
    "time"::

        class as_utc(GenericFunction):
            type = DateTime()
            package = "time"
            inherit_cache = True

    The above function would be available from :data:`.func`
    using the package name ``time``::

        print(select(func.time.as_utc()))

    A final option is to allow the function to be accessed
    from one name in :data:`.func` but to render as a different name.
    The ``identifier`` attribute will override the name used to
    access the function as loaded from :data:`.func`, but will retain
    the usage of ``name`` as the rendered name::

        class GeoBuffer(GenericFunction):
            type = Geometry()
            package = "geo"
            name = "ST_Buffer"
            identifier = "buffer"
            inherit_cache = True

    The above function will render as follows:

    .. sourcecode:: pycon+sql

        >>> print(func.geo.buffer())
        {printsql}ST_Buffer()

    The name will be rendered as is, however without quoting unless the name
    contains special characters that require quoting.  To force quoting
    on or off for the name, use the :class:`.sqlalchemy.sql.quoted_name`
    construct::

        from sqlalchemy.sql import quoted_name


        class GeoBuffer(GenericFunction):
            type = Geometry()
            package = "geo"
            name = quoted_name("ST_Buffer", True)
            identifier = "buffer"
            inherit_cache = True

    The above function will render as:

    .. sourcecode:: pycon+sql

        >>> print(func.geo.buffer())
        {printsql}"ST_Buffer"()

    Type parameters for this class as a
    `generic type <https://peps.python.org/pep-0484/#generics>`_ can be passed
    and should match the type seen in a :class:`_engine.Result`. For example::

        class as_utc(GenericFunction[datetime.datetime]):
            type = DateTime()
            inherit_cache = True

    The above indicates that the following expression returns a ``datetime``
    object::

        connection.scalar(select(func.as_utc()))

    .. versionadded:: 1.3.13  The :class:`.quoted_name` construct is now
       recognized for quoting when used with the "name" attribute of the
       object, so that quoting can be forced on or off for the function
       name.


    Trk�	_registerc���tj|jvr&|j|j|j
�t�|��yrw)r�	Annotated�__mro__�_register_generic_functionr�rrs�__init_subclass__)�clsrus �rTr�z!GenericFunction.__init_subclass__�s8������s�{�{�2��*�*�3�<�<����F�
��!�#rVc��|jd|�x|_}|jd|�x|_}|jdd�}d|vr
|d|_t	|dd�|_|j
rt
|||�yd|_y)NrarPrRr,�__return_type__r�T)r0rarPr�rir�rU)r��clsname�clsdictrarPrRs      rTr�z*GenericFunction._register_generic_function�s���"�+�+�f�g�6�6���4�&-�k�k�,��&E�E�����+�+�i��4����'��0�1�C�H� ��[�$�7��
��=�=��j�#�w�7�!�C�MrVc	��|jdd�}|�>|D�cgc]3}tjtj||j
|����5}}|jxst|�|_d|_tt|tjdd���|_
tj|jdd�xs
t!|dd��|_ycc}w)N�_parsed_argsrbr\Trdrr�)r�rrgrrhrarjrkr]r)r$rrlrYrrrir�)rmrpr'�parsed_argsros     rTrqzGenericFunction.__init__�s����j�j���6�������A�
� � ��/�/�����*.�	��
�����<�4��+<������#��CN��+�+�D�
�
����(�(��J�J�w��%�D���v�t�)D�
��	��%s�8C)r�r)r�rLr�zMapping[str, Any]r�r�rpr�r'r)
r�r�r�r��coerce_arguments�
inherit_cacher�rar��classmethodr�rqr�r�s@rTr�r�Ksg���l�\���M��O��D�$�
�!��!�$5�!�	
�!��!�(
�<�
�HK�
rVr�rr`c�v�eZdZdZej
�ZdZdejfgZ
dd�Zdd�Ze
d	d��Zy)
rxaRepresent the 'next value', given a :class:`.Sequence`
    as its single argument.

    Compiles into the appropriate function on each backend,
    or will raise NotImplementedError if used on a backend
    that does not provide support for sequences.

    �sequencec��t|tj�sJd��||_t	j
|jxs
t|dd��|_y)Nz0next_value() accepts a Sequence object as input.r�)	r�rrr�rr�	data_typerir�)rm�seqr�s   rTrqznext_value.__init__sU�������
�	>�=�	>�
���
��(�(��M�M�8�W�T�6�4�8�
��	rVc��t|t�xr-|jj|jjk(Srw)r�rxr�ra)rm�otherr�s   rT�compareznext_value.compares2���u�j�)�
:��
�
�"�"�e�n�n�&9�&9�9�	
rVc��gSrwr\r�s rTr�znext_value._from_objectss���	rVN)r�zschema.Sequencer�r)r�rr�rr�rkr�)r�r�r�r�r�Integerr�rar5�dp_named_ddl_elementr�rqr�r�r�r\rVrTrxrx�sU����8����D��D�
�&�;�;�<���
�
����rVrxc��eZdZdZdZdd�Zy)�AnsiFunctionzEDefine a function in "ansi" format, which doesn't render parenthesis.Tc�6�tj|g|��i|��yrw)r�rq)rmrpr's   rTrqzAnsiFunction.__init__%s��� � ��7��7��7rVN�rpr�r'r)r�r�r�r�r�rqr\rVrTr�r� s��O��M�8rVr�c���eZdZdZdZe						dd��Ze						dd��Ze						d	d��Z				d
�fd�Z�xZS)�ReturnTypeFromArgszADefine a function whose return type is the same as its arguments.Tc��yrwr\rCs    rTrqzReturnTypeFromArgs.__init__3���rVc��yrwr\rCs    rTrqzReturnTypeFromArgs.__init__;r�rVc��yrwr\rCs    rTrqzReturnTypeFromArgs.__init__Cr�rVc	����|D�cgc]3}tjtj||j|����5}}|jdt
|��||d<t�|� |i|��ycc}w)Nrbrr�)	rrgrrhra�
setdefaultr rsrq)rmrpr'ro�fn_argsrus     �rTrqzReturnTypeFromArgs.__init__Ks�����1
���

����+�+���Y�Y�&*�	
��	�1
�	���'�?�7�#;�<�!(��~��
���'�,�V�,��1
s�8A0)r�r�rpr�r'r)r�r�rpr�r'r)r�r�rpr�r'rr�)r�r�r�r�r�r
rqr�r�s@rTr�r�)s����K��M���
��7���	�����
*��7���	�����
3��7���	���-�<�-�HK�-�-rVr�c��eZdZdZdZy)rDTN)r�r�r�rjr�r\rVrTrDrD\s���I��MrVrDc��eZdZdZdZy)rjz!The SQL MAX() aggregate function.TN�r�r�r�r�r�r\rVrTrjrja�
��+��MrVrjc��eZdZdZdZy)rqz!The SQL MIN() aggregate function.TNr�r\rVrTrqrqgr�rVrqc��eZdZdZdZy)r�z!The SQL SUM() aggregate function.TNr�r\rVrTr�r�mr�rVr�c�6�eZdZdZej
�ZdZy)rzz�The SQL now() datetime function.

    SQLAlchemy dialects will usually render this particular function
    in a backend-specific way, such as rendering it as ``CURRENT_TIMESTAMP``.

    TN�r�r�r�r�r�DateTimer�r�r\rVrTrzrzss����8����D��MrVrzc�6�eZdZdZej
�ZdZy)rJa*The SQL CONCAT() function, which concatenates strings.

    E.g.:

    .. sourcecode:: pycon+sql

        >>> print(select(func.concat("a", "b")))
        {printsql}SELECT concat(:concat_2, :concat_3) AS concat_1

    String concatenation in SQLAlchemy is more commonly available using the
    Python ``+`` operator with string datatypes, which will render a
    backend-specific concatenation operator, such as :

    .. sourcecode:: pycon+sql

        >>> print(select(literal("a") + "b"))
        {printsql}SELECT :param_1 || :param_2 AS anon_1


    TN�r�r�r�r�r�Stringr�r�r\rVrTrJrJs���*�8�?�?��D��MrVrJc�J��eZdZdZej
�ZdZd�fd�Z�xZ	S)rAzThe CHAR_LENGTH() SQL function.Tc�&��t�|�|fi|��yrw�rsrq)rm�argr�rus   �rTrqzchar_length.__init__�s���	����#��#rV)r�z_ColumnExpressionArgument[str]r�r�
r�r�r�r�rr�r�r�rqr�r�s@rTrArA�s%���)��8����D��M�$�$rVrAc��eZdZdZdZdZy)r�zThe RANDOM() SQL function.TN�r�r�r�r�rjr�r\rVrTr�r��s��$��I��MrVr�c�T��eZdZdZej
�ZdZ	d			d�fd�
Z�xZ	S)rMa�The ANSI COUNT aggregate function.  With no arguments,
    emits COUNT \*.

    E.g.::

        from sqlalchemy import func
        from sqlalchemy import select
        from sqlalchemy import table, column

        my_table = table("some_table", column("id"))

        stmt = select(func.count()).select_from(my_table)

    Executing ``stmt`` would emit:

    .. sourcecode:: sql

        SELECT count(*) AS count_1
        FROM some_table


    Tc�@��|�td�}t�|�|fi|��y)N�*)r*rsrq)rm�
expressionr'rus   �rTrqzcount.__init__�s'�����'��,�J�
����.�v�.rVrw)r�z7Union[_ColumnExpressionArgument[Any], _StarOrOne, None]r'rr�r�s@rTrMrM�sB����.�8����D��M�
�		/�
�	/�
�	/�	/rVrMc�6�eZdZdZej
�ZdZy)rTz The CURRENT_DATE() SQL function.TN)r�r�r�r�r�Dater�r�r\rVrTrTrT����*��8�=�=�?�D��MrVrTc�6�eZdZdZej
�ZdZy)rWz The CURRENT_TIME() SQL function.TN)r�r�r�r�r�Timer�r�r\rVrTrWrW�r�rVrWc�6�eZdZdZej
�ZdZy)rYz%The CURRENT_TIMESTAMP() SQL function.TNr�r\rVrTrYrY�s��/��8����D��MrVrYc�6�eZdZdZej
�ZdZy)r[z The CURRENT_USER() SQL function.TNr�r\rVrTr[r[����*��8�?�?��D��MrVr[c�6�eZdZdZej
�ZdZy)rfzThe localtime() SQL function.TNr�r\rVrTrfrf�s��'��8����D��MrVrfc�6�eZdZdZej
�ZdZy)rhz"The localtimestamp() SQL function.TNr�r\rVrTrhrh�s��,��8����D��MrVrhc�6�eZdZdZej
�ZdZy)r�z The SESSION_USER() SQL function.TNr�r\rVrTr�r��r�rVr�c�6�eZdZdZej
�ZdZy)r�zThe SYSDATE() SQL function.TNr�r\rVrTr�r�s��%��8����D��MrVr�c�6�eZdZdZej
�ZdZy)r�zThe USER() SQL function.TNr�r\rVrTr�r�s��"��8�?�?��D��MrVr�c�(��eZdZdZdZd�fd�Z�xZS)r=a�Support for the ARRAY_AGG function.

    The ``func.array_agg(expr)`` construct returns an expression of
    type :class:`_types.ARRAY`.

    e.g.::

        stmt = select(func.array_agg(table.c.values)[2:5])

    .. seealso::

        :func:`_postgresql.array_agg` - PostgreSQL-specific version that
        returns :class:`_postgresql.ARRAY`, which has PG-specific operators
        added.

    Tc�V��|D�cgc](}tjtj||����*}}|j	dt
j�}d|vr8t|�}t|t
j�r||d<n
||d��|d<||d<t�|�(|i|��ycc}w)N)rc�_default_array_typerr)�
dimensionsr�)rrgrrhr�rr�r r�rsrq)rmrpr'ror��default_array_type�type_from_argsrus       �rTrqzarray_agg.__init__&s����
�	1
���
����+�+�Q�d�
��		�1
�$�Z�Z�(=�x�~�~�N���&� �,�W�5�N��.�(�.�.�9�"0��w��"4�"�q�#��w��")��~��
���'�,�V�,��#1
s�-B&r�)r�r�r�r�r�rqr�r�s@rTr=r=s����"�M�-�-rVr=c�(�eZdZdZdZdZ				dd�Zy)�
OrderedSetAggz�Define a function where the return type is based on the sort
    expression type as defined by the expression passed to the
    :meth:`.FunctionElement.within_group` method.FTc�2�tt|jj�}t	j
|j�}|jr:t|j�dkDr"tj|dj�S|djS)Nrr)
rr$rYr��sqlutil�unwrap_order_byr��array_for_multi_clauser/rnrr�r�)rmr��func_clausesr�s    rTr�zOrderedSetAgg.within_group_typeCs{���J��(8�(8�(@�(@�A��18�1H�1H��!�!�2
���&�&�3�|�/C�/C�+D�q�+H��>�>�(�1�+�"2�"2�3�3��A�;�#�#�#rVN)r�zWithinGroup[Any]r�zTypeEngine[Any])r�r�r�r�rr�r�r\rVrTr�r�;s)��5�#���M�
$�,�
$�	�
$rVr�c��eZdZdZdZy)rvaImplement the ``mode`` ordered-set aggregate function.

    This function must be used with the :meth:`.FunctionElement.within_group`
    modifier to supply a sort expression to operate upon.

    The return type of this function is the same as the sort expression.

    TNr�r\rVrTrvrvPs����MrVrvc��eZdZdZdZdZy)r�a|Implement the ``percentile_cont`` ordered-set aggregate function.

    This function must be used with the :meth:`.FunctionElement.within_group`
    modifier to supply a sort expression to operate upon.

    The return type of this function is the same as the sort expression,
    or if the arguments are an array, an :class:`_types.ARRAY` of the sort
    expression's type.

    TN�r�r�r�r�rr�r\rVrTr�r�]���	�"���MrVr�c��eZdZdZdZdZy)r�a|Implement the ``percentile_disc`` ordered-set aggregate function.

    This function must be used with the :meth:`.FunctionElement.within_group`
    modifier to supply a sort expression to operate upon.

    The return type of this function is the same as the sort expression,
    or if the arguments are an array, an :class:`_types.ARRAY` of the sort
    expression's type.

    TNrr\rVrTr�r�mrrVr�c�6�eZdZdZej
�ZdZy)r�aImplement the ``rank`` hypothetical-set aggregate function.

    This function must be used with the :meth:`.FunctionElement.within_group`
    modifier to supply a sort expression to operate upon.

    The return type of this function is :class:`.Integer`.

    TN�r�r�r�r�rr�r�r�r\rVrTr�r�}�����8����D��MrVr�c�6�eZdZdZej
�ZdZy)r]aImplement the ``dense_rank`` hypothetical-set aggregate function.

    This function must be used with the :meth:`.FunctionElement.within_group`
    modifier to supply a sort expression to operate upon.

    The return type of this function is :class:`.Integer`.

    TNrr\rVrTr]r]�rrVr]c�B�eZdZUdZej
�Zded<dZy)r~aImplement the ``percent_rank`` hypothetical-set aggregate function.

    This function must be used with the :meth:`.FunctionElement.within_group`
    modifier to supply a sort expression to operate upon.

    The return type of this function is :class:`.Numeric`.

    �!sqltypes.Numeric[decimal.Decimal]r�TN�	r�r�r�r�r�Numericr�r�r�r\rVrTr~r~��$���/?�h�.>�.>�.@�D�
+�@��MrVr~c�B�eZdZUdZej
�Zded<dZy)rQaImplement the ``cume_dist`` hypothetical-set aggregate function.

    This function must be used with the :meth:`.FunctionElement.within_group`
    modifier to supply a sort expression to operate upon.

    The return type of this function is :class:`.Numeric`.

    rr�TNrr\rVrTrQrQ�rrVrQc��eZdZdZdZdZy)rOaSImplement the ``CUBE`` grouping operation.

    This function is used as part of the GROUP BY of a statement,
    e.g. :meth:`_expression.Select.group_by`::

        stmt = select(
            func.sum(table.c.value), table.c.col_1, table.c.col_2
        ).group_by(func.cube(table.c.col_1, table.c.col_2))

    .. versionadded:: 1.2

    TNr�r\rVrTrOrO������I��MrVrOc��eZdZdZdZdZy)r�aWImplement the ``ROLLUP`` grouping operation.

    This function is used as part of the GROUP BY of a statement,
    e.g. :meth:`_expression.Select.group_by`::

        stmt = select(
            func.sum(table.c.value), table.c.col_1, table.c.col_2
        ).group_by(func.rollup(table.c.col_1, table.c.col_2))

    .. versionadded:: 1.2

    TNr�r\rVrTr�r��rrVr�c��eZdZdZdZdZy)rca�Implement the ``GROUPING SETS`` grouping operation.

    This function is used as part of the GROUP BY of a statement,
    e.g. :meth:`_expression.Select.group_by`::

        stmt = select(
            func.sum(table.c.value), table.c.col_1, table.c.col_2
        ).group_by(func.grouping_sets(table.c.col_1, table.c.col_2))

    In order to group by multiple sets, use the :func:`.tuple_` construct::

        from sqlalchemy import tuple_

        stmt = select(
            func.sum(table.c.value), table.c.col_1, table.c.col_2, table.c.col_3
        ).group_by(
            func.grouping_sets(
                tuple_(table.c.col_1, table.c.col_2),
                tuple_(table.c.value, table.c.col_3),
            )
        )

    .. versionadded:: 1.2

    TNr�r\rVrTrcrc�s���4�I��MrVrcc�N��eZdZdZej
�ZdZdZd�fd�Z	�xZ
S)r8a�Implement a generic string aggregation function.

    This function will concatenate non-null values into a string and
    separate the values by a delimiter.

    This function is compiled on a per-backend basis, into functions
    such as ``group_concat()``, ``string_agg()``, or ``LISTAGG()``.

    e.g. Example usage with delimiter '.'::

        stmt = select(func.aggregate_strings(table.c.str_col, "."))

    The return type of this function is :class:`.String`.

    .. versionadded: 2.0.21

    Tc�&��t�|�||�yrwr�)rm�clause�	separatorrus   �rTrqzaggregate_strings.__init__s���
�����+rV)rr�rrL)r�r�r�r�rr�r�rjr�rqr�r�s@rTr8r8�s,����$�8�?�?��D��I��M�,�,rVr8)r,)rPrLrQzType[Function[Any]]rRrLr�r)�r��
__future__r�datetime�decimal�typingrrrrrr	r
rrr
rrr�rrrrrrrrr�_typingr�baserrrrr�elementsr r!r"r#r$r%r&r(r)r*r+r-r/�
selectabler0r1r2r3r4�visitorsr5r7r8r9r:r;r<r=r>r?r@rA�engine.baserB�
engine.cursorrC�engine.interfacesrDrE�util.typingrFrGrI�defaultdict�dictrJr�rUrXr�r~rr6�modifierr1r�r�rxr�r�rDrjrqr�rzrLrJrA�floatr�rM�daterT�timerWrYr[rfrhr�r�r�r=r�rvr�r�r�r]�Decimalr~rQrOr�rcr8r\rVrT�<module>r1sY���#������������� �����������(�#�"����%�&�#�� �#��$��$�!��!�"��(�$� �'���$�2�;�<�#�,�&�'�,�+�'�(�,�;�?�"��T�����T�����D���T��
�@��>H����,��7:��	��0E
3�j�-��"3�Z��E
3�P1�'��,�1�h0�;�r�?�0�4{*�{*�@���!�)�)����E�*��w
��r�"�w
�ti
�h�r�l�i
�X�&�$���)�W�%�"���%�"�J8�?�2�&�8�0-���,�0-�f�!�"�%��
�
�R�
 ���
�R�
 ���
�R�
 ��	�/�(�+�+�
,�	��_�S�
!��4	$�/�#�&�	$��_�U�
#��$/�O�C� �$/�N�<��
�
�.���<��
�
�.����X�%6�%6�7���<��$����X�.�.�/���\�(�"3�"3�4���<��$���l�8�,�,�-���<����&-���#�&-�R$�O�B�'�$�*
�=���
�
�m�B�'�
� 
�m�B�'�
� �?�3������%���?�7�?�?�3�������0���?�2���$�_�R�
 ��$�O�B�'��>,���,�,rV

ZeroDay Forums Mini