Files
aitsc/.venv/Lib/site-packages/sqlalchemy/sql/__pycache__/functions.cpython-312.pyc

1145 lines
74 KiB
Plaintext
Raw Normal View History

2025-02-23 09:07:52 +08:00
<EFBFBD>
t&<26>h<EFBFBD><00><01> <00>UdZddlmZddlZddlZddlmZddlmZddlmZddlm Z ddlm
2025-02-23 09:07:52 +08:00
Z
dd lm Z dd
lm Z dd lm 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<06>E<EFBFBD>ZOedFe<06>E<EFBFBD>ZPej<>eR<65>ZSdGeTdH< d<> d<>dI<64>ZUGdJ<64>dKe"e+eOe4e#<23>ZVGdL<64>dMe'e<00>ZWGdN<64>dOe0eO<00>ZXGdP<64>dQ<64>ZYeY<65>ZZeYjeZ_eYdR<64>S<EFBFBD>Z[GdT<64>dUeVeO<00>Z\GdV<64>dWe\eO<00>Z]eUdXe)<29>eUdYe,<2C>GdZ<64>d[e]e^<00>Z_Gd\<5C>d]e]eO<00>Z`Gd^<5E>d_e]eO<00>ZaGd`<60>daeaeO<00>ZbGdb<64>dceaeO<00>ZcGdd<64>deeaeO<00>ZdGdf<64>dgeaeO<00>ZeGdh<64>die]ej<00>ZfGdj<64>dke]eg<00>ZhGdl<64>dme]e^<00>ZiGdn<64>doe]ej<00>ZkGdp<64>dqe]e^<00>ZlGdr<64>dse`ej<><00>ZnGdt<64>due`ej<><00>ZpGdv<64>dwe`ej<00>ZqGdx<64>dye`eg<00>ZrGdz<64>d{e`ej<00>ZsGd|<7C>d}e`ej<00>ZtGd~<7E>de`eg<00>ZuGd<><64>d<>e`ej<00>ZvGd<><64>d<>e`eg<00>ZwGd<><64>d<>e]eO<00>ZxGd<><64>d<>e]eO<00>ZyGd<><64>d<>eyeO<00>ZzGd<><64>d<>eyeO<00>Z{Gd<><64>d<>eyeO<00>Z|Gd<><64>d<>e]e^<00>Z}Gd<><64>d<>e]e^<00>Z~Gd<><64>d<>e]ej<><00>Z<>Gd<><64>d<>e]ej<><00>Z<>Gd<><64>d<>e]eO<00>Z<>Gd<><64>d<>e]eO<00>Z<>Gd<><64>d<>e]eO<00>Z<>Gd<><64>d<>e]eg<00>Z<>y)<29>z6SQL function API, factories, and built-in functions.
<EFBFBD>)<01> annotationsN)<01>Any)<01>cast)<01>Dict)<01>List)<01>Mapping)<01>Optional)<01>overload)<01>Sequence)<01>Tuple)<01>Type)<01> TYPE_CHECKING)<01>TypeVar)<01>Union<6F>)<01>
annotation)<01> coercions)<01> operators)<01>roles)<01>schema)<01>sqltypes)<01>type_api)<01>util)<01>is_table_value_type)<01>_entity_namespace)<01>ColumnCollection)<01>
Executable)<01>
Generative)<01> HasMemoized)<01>_type_from_args)<01>BinaryExpression)<01> BindParameter)<01>Cast)<01>
ClauseList)<01> ColumnElement)<01>Extract<63><01>FunctionFilter)<01>Grouping)<01>literal_column)<01> NamedColumn<6D><01>Over<65><01> WithinGroup)<01>
FromClause)<01>Select)<01>TableValuedAlias)<01>TableValueType)<01>
TypeEngine)<01>InternalTraversal<61>)<01> _ByArgument)<01>_ColumnExpressionArgument)<01>"_ColumnExpressionOrLiteralArgument)<01>#_ColumnExpressionOrStrLabelArgument)<01>
_StarOrOne)<01>_TypeEngineArgument)<01>_EntityNamespace)<01> ClauseElement)<01>KeyedColumnElement)<01>TableValuedColumn)<01> OperatorType)<01>
Connection)<01> CursorResult)<01>_CoreMultiExecuteParams)<01>CoreExecuteOptionsParameter)<01>Self<6C>_T)<01>bound<6E>_Sz5util.defaultdict[str, Dict[str, Type[Function[Any]]]]<5D> _registryc<01><><00>t|}t|<00>j<00>}||vr$tjdj |<00><00>|||<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<00>str<74>lowerr<00>warn<72>format)<04>
identifier<EFBFBD>fn<66>package<67>regs <20>AD:\xxxx\aitsc\.venv\Lib\site-packages\sqlalchemy\sql\functions.py<70>register_functionrU]sP<00><00> <14>G<EFBFBD>
2025-02-23 09:07:52 +08:00
<1C>C<EFBFBD><14>Z<EFBFBD><1F>&<26>&<26>(<28>J<EFBFBD><12>S<EFBFBD><18> <0C> <09> <09> )<29>)/<2F><16>
<EFBFBD>);<3B>
<EFBFBD><19>C<EFBFBD>
<EFBFBD>O<EFBFBD>c<01><><00><00>eZdZUdZdej
fdej fdejfgZdZ de
d<dZ dZ d Z d
e
d<d e
d <d e
d <de
d<d(d<0F>Zd Zed)<29>fd<10> <0C>Z d*d<11>Z d+ d,d<12>Z d-d<13>Z d. d/d<14>Zej.d0d<15><04>Zej2d0d<16><04>Zed1d<17><04>Ze d0d<18><04>Zej<d2d<19><04>Zd d d d d<1A> d3d<1B>Z d4d<1C>Z!e"d5d<1D><04>Z#e" d6d<1E><04>Z# d7d<1F>Z# d8d <20>Z$ed)d!<21><04>Z% d9d"<22>Z& d. d:d#<23>Z'd;d$<24>Z( d. d<d%<25>Z)d+d=<3D>fd&<26> Z*ed>d'<27><04>Z+<2B>xZ,S)?<3F>FunctionElementa<74>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.
<20> clause_expr<70>_with_ordinality<74>_table_value_type<70>zTuple[str, ...]<5D> packagenamesFNzOptional[TableValueType]r<00> primary_key<65> _is_clone_ofz Grouping[Any]c <01><00>|D<00>cgc]4}tjtj|t |dd<02>|<00><03><00><02>6}}|j
xs t |<03>|_tt|tjdd<05><02><01>|_ 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`
<20>nameN<65>ra<00>apply_propagate_attrsT<73><02>operator<6F>group_contents) r<00>expectr<00>ExpressionElementRole<6C>getattr<74> _has_args<67>boolr)r$r<00>comma_oprY)<04>self<6C>clauses<65>c<>argss rT<00>__init__zFunctionElement.__init__<5F>s<><00><00>.<1D>:
<EFBFBD><1D><01> <16> <1C> <1C><15>+<2B>+<2B><11><1C>T<EFBFBD>6<EFBFBD>4<EFBFBD>0<>&*<2A>  <0E> <1D> <0A>:
<EFBFBD><1E><1E><1E>5<>4<EFBFBD><04>:<3A><04><0E>#<23> <16>$<24> <09> 2<> 2<>4<EFBFBD> O<>
<EFBFBD><04><18><>:
s<00>9Bc<01>6<00><01>t<00>|<00>xs t|dd<00>S)Nra)<03>super<65>
_proxy_keyri)rm<00> __class__s <20>rTrtzFunctionElement._proxy_key<65>s<00><><00><14>w<EFBFBD>!<21>@<40>W<EFBFBD>T<EFBFBD>6<EFBFBD>4<EFBFBD>%@<40>@rVc<01>(<00>|j|||<03>S<00>N)<01>_execute_function)rm<00>
connection<EFBFBD>distilled_params<6D>execution_optionss rT<00>_execute_on_connectionz&FunctionElement._execute_on_connection<6F>s <00><00> <1A>+<2B>+<2B> <10>"<22>$5<>
<EFBFBD>
rVc<01><00>t|||<02>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`
)<01>ScalarFunctionColumn)rmra<00>type_s rT<00>scalar_table_valuedz#FunctionElement.scalar_table_valued<65>s<00><00>B$<24>D<EFBFBD>$<24><05>6<>6rVc<01><><00>|j<00>}|jdd<02>}|jdd<02>}|jdd<02>}|r ||fz }d|_t|<01>x|_|_|j ||<05><06>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, ...)``
<20>with_ordinalityN<79>joins_implicitlyraT<>rar<>)<07> _generate<74>poprZr3<00>typer[<00>alias)rm<00>expr<70>kw<6B>new_funcr<63>r<>ras rT<00> table_valuedzFunctionElement.table_valued<65>s<><00><00>V<18>><3E>><3E>#<23><08><1C>&<26>&<26>!2<>D<EFBFBD>9<><0F><1D>6<EFBFBD>6<EFBFBD>"4<>d<EFBFBD>;<3B><18><11>v<EFBFBD>v<EFBFBD>f<EFBFBD>d<EFBFBD>#<23><04> <1A> <10>_<EFBFBD>&<26> &<26>D<EFBFBD>(,<2C>H<EFBFBD> %<25>5C<35>T<EFBFBD>5J<35>J<><08> <0A><08>2<><17>~<7E>~<7E>4<EFBFBD>:J<>~<7E>K<>KrVc<01><<00>|j||<02><01>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<><00>column<6D>rmrar<>s rT<00> column_valuedzFunctionElement.column_valuedHs<00><00>R<14>z<EFBFBD>z<EFBFBD>t<EFBFBD>6F<36>z<EFBFBD>G<>N<>N<>NrVc<01><00>|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<00>rms rT<00>columnszFunctionElement.columnsss <00><00>0<14>v<EFBFBD>v<EFBFBD> rVc<01>l<00>t|jD<00>cgc]}|j|f<02><02>c}<01><01>Scc}w)z-synonym for :attr:`.FunctionElement.columns`.<2E>r<>)r<00>_all_selected_columns<6E>key)rm<00>cols rTrozFunctionElement.c<>s6<00><00> <20>/3<>/I<>/I<>J<>/I<><03>c<EFBFBD>g<EFBFBD>g<EFBFBD>s<EFBFBD>^<5E>/I<>J<>
<EFBFBD>
<EFBFBD><EFBFBD>Js<00>1c<01><><00>t|j<00>r"td|jj<00>}|S|j d<00>g}|S)N<>!Sequence[KeyedColumnElement[Any]])rr<>r<00> _elements<74>label)rm<00>colss rTr<>z%FunctionElement._all_selected_columns<6E>sF<00><00> <1E>t<EFBFBD>y<EFBFBD>y<EFBFBD> )<29><17>3<>T<EFBFBD>Y<EFBFBD>Y<EFBFBD>5H<35>5H<35><0E>D<EFBFBD> <14> <0B><19>J<EFBFBD>J<EFBFBD>t<EFBFBD>$<24>%<25>D<EFBFBD><13> rVc<01><00>|jSrwr<>r<>s rT<00>exported_columnsz FunctionElement.exported_columns<6E>s<00><00><14>|<7C>|<7C>rVc<01>J<00>tt|jj<00>S)z}Return the underlying :class:`.ClauseList` which contains
the arguments for this :class:`.FunctionElement`.
)rr$rY<00>elementr<74>s rTrnzFunctionElement.clauses<65>s<00><00> <14>J<EFBFBD><04> 0<> 0<> 8<> 8<>9<>9rV<00><04> partition_by<62>order_by<62>rows<77>range_c<01>"<00>t|||||<04><01>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<00>overzFunctionElement.over<65>s!<00><00>@<14> <10>%<25><1D><15><19> 
<EFBFBD>
rVc<01><00>t|g|<01><01><06>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<00> within_groupzFunctionElement.within_group<75>s<00><00>$<1B>4<EFBFBD>+<2B>(<28>+<2B>+rVc<01><00>yrwr\r<>s rT<00>filterzFunctionElement.filter<65>s<00><00>!rVc<01><00>yrwr\)rm<00>_FunctionElement__criterion0<6E> criterions rTr<>zFunctionElement.filter<65>s<00><00>
!rVc<01>"<00>|s|St|g|<01><01><06>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<65>s<00><00>:<19><17>K<EFBFBD><1D>d<EFBFBD>/<2F>Y<EFBFBD>/<2F>/rVc<01><00>t|||<02>S)as Interpret 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
)<01>FunctionAsBinary)rm<00>
left_index<EFBFBD> right_indexs rT<00> as_comparisonzFunctionElement.as_comparisons<00><00>V <20><04>j<EFBFBD>+<2B>><3E>>rVc<01>.<00>|jjSrw)rn<00> _from_objectsr<73>s rTr<>zFunctionElement._from_objectscs<00><00><13>|<7C>|<7C>)<29>)<29>)rVc<01><00>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<00>within_group_typez!FunctionElement.within_group_typegs<00><00>rVc<01>H<00>tj|||j|<02><01>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<00>table_value_typer<65>)r2<00>
_constructr<EFBFBD>r<>s rTr<>zFunctionElement.aliasus(<00><00>R <20>*<2A>*<2A> <10><15>!<21>Y<EFBFBD>Y<EFBFBD>-<2D> 
<EFBFBD>
rVc<01>l<00>t|<00>}|jr|jdi|j<00><01>}|S)z<>Produce a :func:`_expression.select` construct
against this :class:`.FunctionElement`.
This is shorthand for::
s = select(function_element)
r\)r1<00>_execution_optionsr{)rm<00>ss rT<00>selectzFunctionElement.select<63>s6<00><00> <20><04><1C><01> <0F> "<22> "<22>#<23><01>#<23>#<23>><3E>d<EFBFBD>&=<3D>&=<3D>><3E>A<EFBFBD><10>rVc <01><<00>td|f||jd||d<02>|<05><01>S)NT)<05>_compared_to_operator<6F>_compared_to_type<70>uniquer<00> expanding)r"r<><00>rmre<00>objrr<>r<>s rT<00> _bind_paramzFunctionElement._bind_param<61>s;<00><00><1D> <10> <0F> 
<EFBFBD>#+<2B>"<22>i<EFBFBD>i<EFBFBD><17><17><1F> 
<EFBFBD><11> 
<EFBFBD>
rVc<01><><00><01>|tjur/t|jtj
<00>r t |<00>St<00>|<00>!|<01><01>S)N)<01>against) r<00>getitem<65>
isinstancer<EFBFBD>r<00>ARRAYr)rs<00>
self_group)rmr<>rus <20>rTr<>zFunctionElement.self_group<75>sF<00><><00>
<13>i<EFBFBD>'<27>'<27> '<27>J<EFBFBD> <10>I<EFBFBD>I<EFBFBD>x<EFBFBD>~<7E>~<7E>-
<EFBFBD><1C>D<EFBFBD>><3E> !<21><18>7<EFBFBD>%<25>g<EFBFBD>%<25>6<> 6rVc<01>,<00>t|j<00>S)zzoverrides FromClause.entity_namespace as functions are generally
column expressions and not FromClauses.
)rrYr<>s rT<00>entity_namespacez FunctionElement.entity_namespace<63>s<00><00>!<21><14>!1<>!1<>2<>2rV)rn<00>'_ColumnExpressionOrLiteralArgument[Any]<5D><02>returnr)ryrBrzrDr{rEr<>zCursorResult[Any]rw)rarLr<00>!Optional[_TypeEngineArgument[_T]]r<>zScalarFunctionColumn[_T])r<>z(_ColumnExpressionOrStrLabelArgument[Any]r<>rr<>r2<00>NF)ra<00> Optional[str]r<>rkr<>zTableValuedColumn[_T])r<>z.ColumnCollection[str, KeyedColumnElement[Any]])r<>r<>)r<>r$)
r<EFBFBD><00>Optional[_ByArgument]r<>r<>r<><00>-Optional[Tuple[Optional[int], Optional[int]]]r<>r<>r<>zOver[_T])r<><00>_ColumnExpressionArgument[Any]r<>zWithinGroup[_T])r<>rF)r<><00>_ColumnExpressionArgument[bool]r<>r<>r<>zFunctionFilter[_T])r<>r<>r<>zUnion[Self, FunctionFilter[_T]])r<><00>intr<74>r<>r<>r<>)r<>zWithinGroup[_S]r<>zOptional[TypeEngine[_S]])rar<>r<>rkr<>r2)r<>zSelect[Tuple[_T]]<5D> rerAr<>rrzOptional[TypeEngine[_T]]r<>rkr<>rr<>zBindParameter[_T])r<>zOptional[OperatorType]r<>r>)r<>r=)-<2D>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r5<00>dp_clauseelement<6E>
dp_boolean<EFBFBD>dp_has_cache_key<65>_traverse_internalsr]<00>__annotations__rjrZr[rq<00>_non_anon_label<65>propertyrtr|r<>r<>r<>r<00>ro_non_memoized_propertyr<79><00>ro_memoized_propertyror<>r<>r<00>memoized_attributernr<>r<>r
r<>r<>r<>r<>r<>r<>r<>r<>r<><00> __classcell__<5F>rus@rTrXrXus;<00><><00><08>,
<17>)<29>:<3A>:<3A>;<3B> <1B>.<2E>9<>9<>:<3A> <1C>/<2F>@<40>@<40>A<><06><17> %'<27>L<EFBFBD>/<2F>&<26><15>I<EFBFBD><1C><14>26<32><15>/<2F>6<><15><14><15><15><1E><1E>
<EFBFBD><<1B>O<EFBFBD> <0A>A<01><0E>A<01>
<EFBFBD><1E>
<EFBFBD>2<>
<EFBFBD>7<> 
<EFBFBD>
<1B> 
<EFBFBD>EI<01>!7<><17>!7<> A<>!7<> !<21>!7<>FWL<01>=<3D>WL<01>EH<45>WL<01> <19>WL<01>tDI<01>)O<01>!<21>)O<01><@<40>)O<01> <1E>)O<01>V
<EFBFBD>"<22>"<22><16>#<23><16>2
<EFBFBD><1E><1E>
<EFBFBD><1F>
<EFBFBD><0E> <14><0E> <14><0E><1C> 7<><1C><0E><1C>
<11>#<23>#<23>:<3A>$<24>:<3A>/3<>*.<2E>>B<>@D<> &
<EFBFBD>,<2C>&
<EFBFBD>(<28> &
<EFBFBD>
<<3C> &
<EFBFBD> ><3E> &
<EFBFBD>
<12>&
<EFBFBD>P,<2C>7<>,<2C> <18>,<2C>(<0E>!<21><0E>!<21> <0A>!<21>5<>!<21>4<>!<21>
<1C> !<21><0E>!<21> 0<>9<>0<> (<28>0<>BK?<3F><1D>K?<3F>,/<2F>K?<3F> <19>K?<3F>Z<0E>*<2A><0E>*<2A> <14>+<2B> <14> !<21> <14>DI<01>N
<EFBFBD>!<21>N
<EFBFBD><@<40>N
<EFBFBD> <19>N
<EFBFBD>` <11>$+/<2F><1F> 
<EFBFBD><1E>
<EFBFBD><11>
<EFBFBD>(<28> 
<EFBFBD>
<18> 
<EFBFBD> <12> 
<EFBFBD>
<1B>
<EFBFBD>&
7<><0E>3<><0E>3rVrXc<01>2<00>eZdZUdejfdej
fdej
fdej fgZded<ded<ded<dd<07>Z dd<08>Z
e dd <09><04>Z e jdd
<EFBFBD><04>Z e dd <0B><04>Zejdd <0C><04>Zese ZeZy y )r<><00> sql_functionr<6E>r<><00> modifiers<72>FunctionElement[Any]r<>c<01>0<00>tj|||<02>Srw)r%<00>_gen_cache_key)rm<00>anon_map<61>
bindparamss rTr<>zFunctionAsBinary._gen_cache_key s<00><00><1C>+<2B>+<2B>D<EFBFBD>(<28>J<EFBFBD>G<>GrVc<01><><00>||_||_||_tj|_t j|_d|_ d|_
i|_ y)NT) r<>r<>r<>r<00>function_as_comparison_oprer<00> BOOLEANTYPEr<45><00>negate<74>_is_implicitly_booleanr<6E>)rmrQr<>r<>s rTrqzFunctionAsBinary.__init__ sK<00><00><1F><04><19>$<24><04><0F>&<26><04><18>!<21>;<3B>;<3B><04> <0A><1C>(<28>(<28><04> <09><1A><04> <0B>&*<2A><04>#<23><1B><04>rVc<01>b<00>|jjj|jdz
S<00>Nr<00>r<>rnr<>r<>s rT<00> left_exprzFunctionAsBinary.left_exprs(<00><00><13> <20> <20>(<28>(<28>0<>0<><14><1F><1F>1<EFBFBD>1D<31>E<>ErVc<01>d<00>||jjj|jdz
<yr<>r<><00>rm<00>values rTr<>zFunctionAsBinary.left_exprs'<00><00>AF<41><04><19><19>!<21>!<21>)<29>)<29>$<24>/<2F>/<2F>A<EFBFBD>*=<3D>>rVc<01>b<00>|jjj|jdz
Sr<><00>r<>rnr<>r<>s rT<00>
right_exprzFunctionAsBinary.right_expr!s*<00><00><13> <20> <20>(<28>(<28>0<>0<><14>1A<31>1A<31>A<EFBFBD>1E<31>F<>FrVc<01>d<00>||jjj|jdz
<yr<>rr<>s rTrzFunctionAsBinary.right_expr%s)<00><00>BG<42><04><19><19>!<21>!<21>)<29>)<29>$<24>*:<3A>*:<3A>Q<EFBFBD>*><3E>?rVN)r<>rr<>rr<>r)rQr<>r<>r<>r<>r<>)r<><00>ColumnElement[Any])rrr<><00>None)r<>r<>r<>r5r<><00> dp_plain_obj<62> dp_plain_dictr<74>r<>r<>rqr<>r<><00>setterrr<00>left<66>rightr\rVrTr<>r<><00>s<><00><00> <17>*<2A>;<3B>;<3B><<3C> <15>(<28>5<>5<>6<> <16>)<29>6<>6<>7<> <14>'<27>5<>5<>6<> <06><17>'<27>&<26><13>O<EFBFBD><14><14>H<01> <1C>&<26> <1C>47<34> <1C>FI<46> <1C><0E>F<01><0E>F<01><0F><15><15>G<01><16>G<01><0E>G<01><0E>G<01><10><16><16>H<01><17>H<01> <19><19><04><1A><05> rVr<>c<01><><00>eZdZdZdej
fdej fdejfgZdZ dZ
d d d<07>Z y)
r~<00>scalar_function_columnrar<>rQFNc<01>T<00>||_||_tj|<03>|_yrw)rQrar<00> to_instancer<65>)rmrQrars rTrqzScalarFunctionColumn.__init__=s&<00><00> <15><04><07><18><04> <09><1D>(<28>(<28><15>/<2F><04> rVrw)rQzFunctionElement[_T]rarLrr<>) r<>r<>r<><00>__visit_name__r5<00> dp_anon_name<6D>dp_typer<65>r<><00>
is_literal<EFBFBD>tablerqr\rVrTr~r~1sp<00><00>-<2D>N<EFBFBD>
<10>"<22>/<2F>/<2F>0<> <0F>"<22>*<2A>*<2A>+<2B> <0A> <20>1<>1<>2<><06><17> <17>J<EFBFBD> <10>E<EFBFBD> 48<34> 0<> <1F> 0<><12> 0<>1<> 0rVr~c<01><><00>eZdZdZd7d<02>Zd8d<03>Ze d9d<04><04>Zed:d<05><04>Zd:d<06>Ze<08>re d;d<07><04>Z
e d<d<08><04>Z e d=d <09><04>Z e d>d
<EFBFBD><04>Z e d?d <0B><04>Ze d@d <0C><04>Ze dAd <0A><04>Ze dBd<0E><04>Z dBd<0F>Ze dCd<10><04>Ze dDd<11><04>Ze dEd<12><04>Ze dFd<13><04>Ze dGd<14><04>Ze dHd<15><04>Ze dId<16><04>Ze dJd<17><04>Ze dKd<18><04>Ze dLd<19><04>Ze dMd<1A><04>Ze dNd<1B><04>Ze dOd<1C><04>Ze dPd<1D><04>Ze dQd<1E><04>Ze dRd<1F><04>Z dRd <20>Ze dSd!<21><04>Ze dTd"<22><04>Ze dUd#<23><04>Z dUd$<24>Ze dVd%<25><04>Ze dWd&<26><04>Z e dXd'<27><04>Z!e dYd(<28><04>Z"e dZd)<29><04>Z#e d[d*<2A><04>Z$e d\d+<2B><04>Z%e d]d,<2C><04>Z&e d^d-<2D><04>Z'e d_d.<2E><04>Z(e d`d/<2F><04>Z)e dad0<64><04>Z*e dbd1<64><04>Z*e dcd2<64><04>Z* dcd3<64>Z*e ddd4<64><04>Z+e ded5<64><04>Z,y6y6)f<>_FunctionGeneratora<72> 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 <01> <00>g|_||_yrw)<02>_FunctionGenerator__names<65>opts)rmrs rTrqz_FunctionGenerator.__init__<5F>s<00><00>"$<24><04> <0C><18><04> rVc<01>
<00>|jd<01>r |j|S|j d<02>r|dd}t di|j <00><01>}t|j<00>|gz|_|S#t$r t|<01><00>wxYw)N<>__<5F>_r<00><><EFBFBD><EFBFBD><EFBFBD>r\) <09>
startswith<EFBFBD>__dict__<5F>KeyError<6F>AttributeError<6F>endswithrr<00>listr)rmra<00>fs rT<00> __getattr__z_FunctionGenerator.__getattr__<5F>s<><00><00> <0F>?<3F>?<3F>4<EFBFBD> <20> +<2B><1B>}<7D>}<7D>T<EFBFBD>*<2A>*<2A><12>]<5D>]<5D>3<EFBFBD> <1F><17><01>"<22>:<3A>D<EFBFBD> <1E> +<2B><14><19><19> +<2B><01><18><14><1C><1C>&<26>$<24><16>/<2F><01> <09><10><08><><1C> +<2B>$<24>T<EFBFBD>*<2A>*<2A> +<2B>s <00>A-<00>-Bc<01><00>yrwr\)rmrro<00>kwargss rT<00>__call__z_FunctionGenerator.__call__<5F>s<00><00>rVc<01><00>yrwr\)rmror's rTr(z_FunctionGenerator.__call__<5F><00><00><00>ADrVc <01><><00>|jj<00>}|j|<02>t|j<00>}|dk(r|j\}}n|dk(rd|jd}}nd}|<05>0t
|j j<00><00>}|<07>||i|<03><01>St|jdg|<01><01>dt|jdd<00>i|<03><01>S)Nr6r<00>_defaultrrr])
r<00>copy<70>update<74>lenrrJ<00>getrM<00>Function<6F>tuple)rmror'<00>o<>tokensrR<00>fname<6D>funcs rTr(z_FunctionGenerator.__call__<5F>s<><00><00> <10>I<EFBFBD>I<EFBFBD>N<EFBFBD>N<EFBFBD> <1C><01> <09><08><08><16><18><14>T<EFBFBD>\<5C>\<5C>"<22><06> <11>Q<EFBFBD>;<3B>!<21>\<5C>\<5C>N<EFBFBD>G<EFBFBD>U<EFBFBD> <13>q<EFBFBD>[<5B>'<27><14><1C><1C>a<EFBFBD><1F>U<EFBFBD>G<EFBFBD><1A>G<EFBFBD> <12> <1E><1C>W<EFBFBD>%<25>)<29>)<29>%<25>+<2B>+<2B>-<2D>8<>D<EFBFBD><13><1F><1B>Q<EFBFBD>}<7D>!<21>}<7D>$<24><17> <10>L<EFBFBD>L<EFBFBD><12> <1C>
<EFBFBD>GH<EFBFBD>
<EFBFBD>+0<><14><1C><1C>a<EFBFBD><02>1C<31>+D<>
<EFBFBD>LM<EFBFBD>
<EFBFBD>
rVc<01><00>yrwr\r<>s rT<00>aggregate_stringsz$_FunctionGenerator.aggregate_strings<67><00><00><00>@CrVc<01><00>yrwr\r<>s rT<00> ansifunctionz_FunctionGenerator.ansifunction<6F>s<00><00>;>rVc<01><00>yrwr\r<>s rT<00> array_aggz_FunctionGenerator.array_agg<67>s<00><00>58rVc<01><00>yrwr\r<>s rTrz_FunctionGenerator.cast<73><00><00><00>+.rVc<01><00>yrwr\r<>s rT<00> char_lengthz_FunctionGenerator.char_length<74>s<00><00>47rVc<01><00>yrwr\<00>rmr<>rpr's rT<00>coalescez_FunctionGenerator.coalesce<63><00><00><00> rVc<01><00>yrwr\rCs rTrDz_FunctionGenerator.coalesce<63>rErVc<01><00>yrwr\rCs rTrDz_FunctionGenerator.coalesce<63>rErVc<01><00>yrwr\rCs rTrDz_FunctionGenerator.coalesces<00><00>
rVc<01><00>yrwr\r<>s rT<00>concatz_FunctionGenerator.concat<00><00><00>*-rVc<01><00>yrwr\r<>s rT<00>countz_FunctionGenerator.counts<00><00>(+rVc<01><00>yrwr\r<>s rT<00>cubez_FunctionGenerator.cuber?rVc<01><00>yrwr\r<>s rT<00> cume_distz_FunctionGenerator.cume_dist<00><00><00>03rVc<01><00>yrwr\r<>s rT<00> current_datez_FunctionGenerator.current_date<00><00><00>69rVc<01><00>yrwr\r<>s rT<00> current_timez_FunctionGenerator.current_timerUrVc<01><00>yrwr\r<>s rT<00>current_timestampz$_FunctionGenerator.current_timestamp r9rVc<01><00>yrwr\r<>s rT<00> current_userz_FunctionGenerator.current_user#rUrVc<01><00>yrwr\r<>s rT<00>
dense_rankz_FunctionGenerator.dense_rank&<00><00><00>25rVc<01><00>yrwr\r<>s rT<00>extractz_FunctionGenerator.extract)<00><00><00>,/rVc<01><00>yrwr\r<>s rT<00> grouping_setsz _FunctionGenerator.grouping_sets,<00><00><00>=@rVc<01><00>yrwr\r<>s rT<00> localtimez_FunctionGenerator.localtime/rRrVc<01><00>yrwr\r<>s rT<00>localtimestampz!_FunctionGenerator.localtimestamp2s<00><00>:=rVc<01><00>yrwr\rCs rT<00>maxz_FunctionGenerator.max:<00><00><00> rVc<01><00>yrwr\rCs rTrjz_FunctionGenerator.maxBrkrVc<01><00>yrwr\rCs rTrjz_FunctionGenerator.maxJrkrVc<01><00>yrwr\rCs rTrjz_FunctionGenerator.maxR<00><00><00>
rVc<01><00>yrwr\rCs rT<00>minz_FunctionGenerator.min^rkrVc<01><00>yrwr\rCs rTrqz_FunctionGenerator.minfrkrVc<01><00>yrwr\rCs rTrqz_FunctionGenerator.minnrkrVc<01><00>yrwr\rCs rTrqz_FunctionGenerator.minvrorVc<01><00>yrwr\r<>s rT<00>modez_FunctionGenerator.mode}r?rVc<01><00>yrwr\r<>s rT<00>
next_valuez_FunctionGenerator.next_value<75>r^rVc<01><00>yrwr\r<>s rT<00>nowz_FunctionGenerator.now<6F>s<00><00>$'rVc<01><00>yrwr\r<>s rT<00> orderedsetaggz _FunctionGenerator.orderedsetagg<67>rdrVc<01><00>yrwr\r<>s rT<00> percent_rankz_FunctionGenerator.percent_rank<6E>rUrVc<01><00>yrwr\r<>s rT<00>percentile_contz"_FunctionGenerator.percentile_cont<6E>r*rVc<01><00>yrwr\r<>s rT<00>percentile_discz"_FunctionGenerator.percentile_disc<73>r*rVc<01><00>yrwr\r<>s rT<00>randomz_FunctionGenerator.random<6F>rKrVc<01><00>yrwr\r<>s rT<00>rankz_FunctionGenerator.rank<6E><00><00><00>&)rVc<01><00>yrwr\r<>s rT<00>rollupz_FunctionGenerator.rollup<75>s<00><00>/2rVc<01><00>yrwr\r<>s rT<00> session_userz_FunctionGenerator.session_user<65>rUrVc<01><00>yrwr\rCs rT<00>sumz_FunctionGenerator.sum<75>rkrVc<01><00>yrwr\rCs rTr<>z_FunctionGenerator.sum<75>rkrVc<01><00>yrwr\rCs rTr<>z_FunctionGenerator.sum<75>rkrVc<01><00>yrwr\rCs rTr<>z_FunctionGenerator.sum<75>rorVc<01><00>yrwr\r<>s rT<00>sysdatez_FunctionGenerator.sysdate<74>rarVc<01><00>yrwr\r<>s rT<00>userz_FunctionGenerator.user<65>r<>rVN)rr)rarLr<>r)rorr<00>_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<><00>ColumnElement[_T]rpr<>r'rr<><00> coalesce[_T])r<><00>_ColumnExpressionArgument[_T]rpr<>r'rr<>r<>)r<><00>&_ColumnExpressionOrLiteralArgument[_T]rpr<>r'rr<>r<>)r<>z Type[concat])r<>z Type[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<><00>max[_T])r<>r<>rpr<>r'rr<>r<>)r<>r<>rpr<>r'rr<>r<>)r<>r<>rpr<>r'rr<><00>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<><00>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<><00><00>W<08>r<19> <11><0E><1B><15><1B>5<><1B>AD<41><1B> <15><1B><0E><1B><0E>D<><0E>D<>
<EFBFBD>,<15>
<12>C<>
<12>C<> <11>><3E>
<12>><3E> <11>8<>
<12>8<> <11>.<2E>
<12>.<2E> <11>7<>
<12>7<>
<12> <1F>"<22> <1F>;<3B> <1F><1A>  <1F>
<1A>  <1F>
<12> <1F>
<12> <1F>.<2E> <1F>;<3B> <1F><1A>  <1F>
<1A>  <1F>
<12> <1F>
<12> <1F>7<> <1F>;<3B> <1F><1A>  <1F>
<1A>  <1F>
<12> <1F> <1F>7<> <1F>;<3B> <1F><1A>  <1F>
<1A>  <1F>
<12>-<2D>
<12>-<2D> <11>+<2B>
<12>+<2B> <11>.<2E>
<12>.<2E> <11>3<>
<12>3<> <11>9<>
<12>9<> <11>9<>
<12>9<> <11>C<>
<12>C<> <11>9<>
<12>9<> <11>5<>
<12>5<> <11>/<2F>
<12>/<2F> <11>@<40>
<12>@<40> <11>3<>
<12>3<> <11>=<3D>
<12>=<3D>
<12> <1A>"<22> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12> <1A>
<12> <1A>.<2E> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12> <1A>
<12> <1A>7<> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12> <1A> <1A>7<> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12> <1A>"<22> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12> <1A>
<12> <1A>.<2E> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12> <1A>
<12> <1A>7<> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12> <1A> <1A>7<> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12>.<2E>
<12>.<2E> <11>5<>
<12>5<> <11>'<27>
<12>'<27> <11>@<40>
<12>@<40> <11>9<>
<12>9<> <11>D<>
<12>D<> <11>D<>
<12>D<> <11>-<2D>
<12>-<2D> <11>)<29>
<12>)<29> <11>2<>
<12>2<> <11>9<>
<12>9<>
<12> <1A>"<22> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12> <1A>
<12> <1A>.<2E> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12> <1A>
<12> <1A>7<> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12> <1A> <1A>7<> <1A>;<3B> <1A><1A>  <1A>
<15>  <1A>
<12>/<2F>
<12>/<2F> <11>)<29>
<12>)<29>crVrF)<01>groupc<01>4<00>eZdZUdZdZej dejfdejfdejfgzZde d<de d<de d< e d d d
<EFBFBD> dd <0B><06>Z e d d d
<EFBFBD> dd <0C><06>Z d d d
<EFBFBD> dd<0E>Z d dd<0F>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.
<20>functionr]rar<>rLrPzTypeEngine[_T].)rr]c<01><00>yrwr\<00>rmrarr]rns rTrqzFunction.__init__<00><00><00> rVc<01><00>yrwr\r<>s rTrqzFunction.__init__r<>rVNc<01><><00>|xsd|_||_tj|<02>|_t j |g|<04><01><06>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?<00><00>)<29>.<2E>B<EFBFBD><04><19><18><04> <09><1D>(<28>(<28><15>/<2F><04> <09><17> <20> <20><14>0<><07>0rVc <01>P<00>t|j|f||j|d|d<02>|<05><01>S)NT)r<>r<>rr<>r<>)r"rar<>r<>s rTr<>zFunction._bind_param7s?<00><00><1D> <10>I<EFBFBD>I<EFBFBD> <0F> 
<EFBFBD>#+<2B>"<22>i<EFBFBD>i<EFBFBD><17><17><1F> 
<EFBFBD><11> 
<EFBFBD>
rV)rarLrnr<>rrr]<00>Optional[Tuple[str, ...]])rarLrnr<>rr<>r]r<>)rarLrnr<>rr<>r]r<>r<>r<>)r<>r<>r<>r<>rrXr<>r5r<00> dp_stringrr<>r
rqr<>r\rVrTr1r1<00>sh<00><00><08>@ <20>N<EFBFBD>)<29>=<3D>=<3D> <17>*<2A>7<>7<>8<> <0F>"<22>,<2C>,<2C>-<2D> <0F>"<22>*<2A>*<2A>+<2B>A<06><06><17> <0E>I<EFBFBD><13>O<EFBFBD>
<18><18><08> <0E>
<1A>25<32>  <0B><11> <0B>9<> <0B><14>  <0B>
0<>  <0B><0E> <0B><0E>
*-<2D>25<32>  <0B><11> <0B>:<3A> <0B>'<27>  <0B>
0<>  <0B><0E> <0B>48<34>26<32> 1<><11>1<>:<3A>1<>1<> 1<>
0<> 1<>4+/<2F><1F> 
<EFBFBD><1E>
<EFBFBD><11>
<EFBFBD>(<28> 
<EFBFBD>
<18> 
<EFBFBD> <12> 
<EFBFBD>
<1B>
rVr1c<01>j<00><00>eZdZUdZdZdZded<dZd<08>fd<05> Ze d d<06><04>Z
d
d<07>Z <0B>xZ S) <0B>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<00> _registerc<01><><00><01>tj|jvr&|j|j|j
<00>t <00>|<00><00>yrw)r<00> Annotated<65>__mro__<5F>_register_generic_functionr<6E>rrs<00>__init_subclass__)<02>clsrus <20>rTr<>z!GenericFunction.__init_subclass__<5F>s8<00><><00> <15> <1F> <1F>s<EFBFBD>{<7B>{<7B> 2<> <0F> *<2A> *<2A>3<EFBFBD><<3C><<3C><13><1C><1C> F<> <0A><07>!<21>#rVc<01><00>|jd|<01>x|_}|jd|<03>x|_}|jdd<04>}d|vr
|d|_t |dd<07>|_|j
rt |||<05>yd|_y)NrarPrRr,<00>__return_type__r<5F>T)r0rarPr<>rir<>rU)r<><00>clsname<6D>clsdictrarPrRs rTr<>z*GenericFunction._register_generic_function<6F>s<><00><00>"<22>+<2B>+<2B>f<EFBFBD>g<EFBFBD>6<>6<><03><08>4<EFBFBD>&-<2D>k<EFBFBD>k<EFBFBD>,<2C><04>&E<>E<><03><0E><1A><19>+<2B>+<2B>i<EFBFBD><1A>4<><07> <1C><07> '<27><1E>0<>1<>C<EFBFBD>H<EFBFBD> <20><03>[<5B>$<24>7<><03> <0A> <0F>=<3D>=<3D> <1D>j<EFBFBD>#<23>w<EFBFBD> 7<>!<21>C<EFBFBD>MrVc <01><><00>|jdd<00>}|<03>>|D<00>cgc]3}tjtj||j
|<00><02><00><02>5}}|j xs t|<03>|_d|_tt|tjdd<05><02><01>|_ tj|jdd<00>xs t!|dd<00><00>|_ycc}w)N<> _parsed_argsrbr\Trdrr<>)r<>rrgrrhrarjrkr]r)r$rrlrYrrrir<>)rmrpr'<00> parsed_argsros rTrqzGenericFunction.__init__<5F>s<><00><00><1D>j<EFBFBD>j<EFBFBD><1E><14>6<> <0B> <16> <1E><1E><0E><1E>A<EFBFBD> <1A> <20> <20><19>/<2F>/<2F><15><1D><19><19>*.<2E> <12> <1E> <18><0E><1E><1E><1E><<3C>4<EFBFBD> <0B>+<<3C><04><0E><1E><04><19>#<23> <16>CN<43><19>+<2B>+<2B>D<EFBFBD> <0E>
<EFBFBD><04><18> <1D>(<28>(<28> <12>J<EFBFBD>J<EFBFBD>w<EFBFBD><04> %<25> D<><17><14>v<EFBFBD>t<EFBFBD>)D<>
<EFBFBD><04> <09><>%s<00>8C)r<>r)r<>rLr<>zMapping[str, Any]r<>r<00>rpr<>r'r) r<>r<>r<>r<><00>coerce_arguments<74> inherit_cacher<65>rar<><00> classmethodr<64>rqr<>r<>s@rTr<>r<>Ksg<00><><00>l<08>\<1C><14><18>M<EFBFBD><13>O<EFBFBD> <1C>D<EFBFBD>$<24>
<11>!<21><19>!<21>$5<>!<21> <0A>!<21><11>!<21>(
<EFBFBD><<3C>
<EFBFBD>HK<EFBFBD>
rVr<>rr`c<01>v<00>eZdZdZej
<00>ZdZdejfgZ
dd<03>Z dd<04>Z e d d<05><04>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.
<20>sequencec <01><><00>t|tj<00>sJd<01><00>||_t j
|j xs t|dd<00><00>|_y)Nz0next_value() accepts a Sequence object as input.r<>) r<>rr r<>rr<00> data_typerir<>)rm<00>seqr<71>s rTrqznext_value.__init__ sU<00><00><19> <0F><16><1F><1F>
<EFBFBD> ><3E> =<3D> ><3E>
<EFBFBD><1C><04> <0A><1C>(<28>(<28> <0F>M<EFBFBD>M<EFBFBD> 8<>W<EFBFBD>T<EFBFBD>6<EFBFBD>4<EFBFBD>8<>
<EFBFBD><04> rVc <01><><00>t|t<00>xr-|jj|jjk(Srw)r<>rxr<>ra)rm<00>otherr<72>s rT<00>compareznext_value.compares2<00><00> <16>u<EFBFBD>j<EFBFBD> )<29> :<3A><14> <0A> <0A>"<22>"<22>e<EFBFBD>n<EFBFBD>n<EFBFBD>&9<>&9<>9<>
rVc<01><00>gSrwr\r<>s rTr<>znext_value._from_objectss<00><00><11> rVN)r<>zschema.Sequencer<65>r)r<>rr<>rr<>rkr<>)r<>r<>r<>r<>r<00>Integerr<72>rar5<00>dp_named_ddl_elementr<74>rqr<>r<>r<>r\rVrTrxrx<00>sU<00><00><08> <1C>8<EFBFBD> <1B> <1B> <1D>D<EFBFBD> <17>D<EFBFBD>
<14>&<26>;<3B>;<3B><<3C><06><17>
<EFBFBD>
<EFBFBD> <0E><12><0E>rVrxc<01><00>eZdZdZdZdd<03>Zy)<06> AnsiFunctionzEDefine a function in "ansi" format, which doesn't render parenthesis.Tc<01>6<00>tj|g|<01><01>i|<02><01>yrw)r<>rq)rmrpr's rTrqzAnsiFunction.__init__%s<00><00><17> <20> <20><14>7<><04>7<><06>7rVN<>rpr<>r'r)r<>r<>r<>r<>r<>rqr\rVrTr<>r<> s<00><00>O<><18>M<EFBFBD>8rVr<>c<01><><00><00>eZdZdZdZe dd<03><04>Ze dd<04><04>Ze d d<05><04>Z d
<EFBFBD>fd<06> Z<06>xZS) <0B>ReturnTypeFromArgszADefine a function whose return type is the same as its arguments.Tc<01><00>yrwr\rCs rTrqzReturnTypeFromArgs.__init__3<00><00><00>  rVc<01><00>yrwr\rCs rTrqzReturnTypeFromArgs.__init__;r<>rVc<01><00>yrwr\rCs rTrqzReturnTypeFromArgs.__init__Cr<>rVc <01><><00><01>|D<00>cgc]3}tjtj||j|<00><01><00><02>5}}|j dt |<04><00>||d<t<00>|<00> |i|<02><01>ycc}w)Nrbrr<>) rrgrrhra<00>
setdefaultr rsrq)rmrpr'ro<00>fn_argsrus <20>rTrqzReturnTypeFromArgs.__init__Ks<><00><><00><1A>1
<EFBFBD><1A><01> <16> <1C> <1C><15>+<2B>+<2B><11><19>Y<EFBFBD>Y<EFBFBD>&*<2A>  <0E> <1A> <10>1
<EFBFBD> <0F><19><19>'<27>?<3F>7<EFBFBD>#;<3B><<3C>!(<28><06>~<7E><1E> <0A><07><18>'<27>,<2C>V<EFBFBD>,<2C><>1
s<00>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<><00><><00>K<><18>M<EFBFBD><0E> <0B> <1E> <0B>7<> <0B><16>  <0B><0E> <0B><0E> <0B> *<2A> <0B>7<> <0B><16>  <0B><0E> <0B><0E> <0B> 3<> <0B>7<> <0B><16>  <0B><0E> <0B>-<2D><<3C>-<2D>HK<48>-<2D>-rVr<>c<01><00>eZdZdZdZy)rDTN)r<>r<>r<>rjr<>r\rVrTrDrD\s <00><00><14>I<EFBFBD><18>MrVrDc<01><00>eZdZdZdZy)rjz!The SQL MAX() aggregate function.TN<54>r<>r<>r<>r<>r<>r\rVrTrjrja<00>
<00><00>+<2B><18>MrVrjc<01><00>eZdZdZdZy)rqz!The SQL MIN() aggregate function.TNr<4E>r\rVrTrqrqgr<>rVrqc<01><00>eZdZdZdZy)r<>z!The SQL SUM() aggregate function.TNr<4E>r\rVrTr<>r<>mr<>rVr<>c<01>6<00>eZdZdZej
<00>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<54>r<>r<>r<>r<>r<00>DateTimer<65>r<>r\rVrTrzrzss<00><00><08> <1D>8<EFBFBD> <1C> <1C> <1E>D<EFBFBD><18>MrVrzc<01>6<00>eZdZdZej
<00>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<54>r<>r<>r<>r<>r<00>Stringr<67>r<>r\rVrTrJrJs<00><00><08>* <1B>8<EFBFBD>?<3F>?<3F> <1C>D<EFBFBD><18>MrVrJc<01>J<00><00>eZdZdZej
<00>ZdZd<04>fd<03> Z<08>xZ S)rAzThe CHAR_LENGTH() SQL function.Tc <01>&<00><01>t<00>|<00>|fi|<02><01>yrw<00>rsrq)rm<00>argr<67>rus <20>rTrqzchar_length.__init__<5F>s<00><><00> <0E><07><18><13>#<23><02>#rV)r<>z_ColumnExpressionArgument[str]r<>r<00>
r<EFBFBD>r<>r<>r<>rr<>r<>r<>rqr<>r<>s@rTrArA<00>s%<00><><00>)<29> <1B>8<EFBFBD> <1B> <1B> <1D>D<EFBFBD><18>M<EFBFBD>$<24>$rVrAc<01><00>eZdZdZdZdZy)r<>zThe RANDOM() SQL function.TN<54>r<>r<>r<>r<>rjr<>r\rVrTr<>r<><00>s<00><00>$<24><14>I<EFBFBD><18>MrVr<>c<01>T<00><00>eZdZdZej
<00>ZdZ d d<05>fd<03> Z<08>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 <01>@<00><01>|<01> td<01>}t<00>|<00>|fi|<02><01>y)N<>*)r*rsrq)rm<00>
expressionr'rus <20>rTrqzcount.__init__<5F>s'<00><><00> <16> <1D>'<27><03>,<2C>J<EFBFBD> <0A><07><18><1A>.<2E>v<EFBFBD>.rVrw)r<>z7Union[_ColumnExpressionArgument[Any], _StarOrOne, None]r'rr<>r<>s@rTrMrM<00>sB<00><><00><08>. <1C>8<EFBFBD> <1B> <1B> <1D>D<EFBFBD><18>M<EFBFBD> <11> /<2F>
<EFBFBD> /<2F>
<16> /<2F> /rVrMc<01>6<00>eZdZdZej
<00>ZdZy)rTz The CURRENT_DATE() SQL function.TN)r<>r<>r<>r<>r<00>Dater<65>r<>r\rVrTrTrT<00><00><00><00>*<2A> <18>8<EFBFBD>=<3D>=<3D>?<3F>D<EFBFBD><18>MrVrTc<01>6<00>eZdZdZej
<00>ZdZy)rWz The CURRENT_TIME() SQL function.TN)r<>r<>r<>r<>r<00>Timer<65>r<>r\rVrTrWrW<00>r<>rVrWc<01>6<00>eZdZdZej
<00>ZdZy)rYz%The CURRENT_TIMESTAMP() SQL function.TNr<4E>r\rVrTrYrY<00>s<00><00>/<2F> <1C>8<EFBFBD> <1C> <1C> <1E>D<EFBFBD><18>MrVrYc<01>6<00>eZdZdZej
<00>ZdZy)r[z The CURRENT_USER() SQL function.TNr<4E>r\rVrTr[r[<00><00><00><00>*<2A> <1A>8<EFBFBD>?<3F>?<3F> <1C>D<EFBFBD><18>MrVr[c<01>6<00>eZdZdZej
<00>ZdZy)rfzThe localtime() SQL function.TNr<4E>r\rVrTrfrf<00>s<00><00>'<27> <1C>8<EFBFBD> <1C> <1C> <1E>D<EFBFBD><18>MrVrfc<01>6<00>eZdZdZej
<00>ZdZy)rhz"The localtimestamp() SQL function.TNr<4E>r\rVrTrhrh<00>s<00><00>,<2C> <1C>8<EFBFBD> <1C> <1C> <1E>D<EFBFBD><18>MrVrhc<01>6<00>eZdZdZej
<00>ZdZy)r<>z The SESSION_USER() SQL function.TNr<4E>r\rVrTr<>r<><00>r<>rVr<>c<01>6<00>eZdZdZej
<00>ZdZy)r<>zThe SYSDATE() SQL function.TNr<4E>r\rVrTr<>r<>s<00><00>%<25> <1C>8<EFBFBD> <1C> <1C> <1E>D<EFBFBD><18>MrVr<>c<01>6<00>eZdZdZej
<00>ZdZy)r<>zThe USER() SQL function.TNr<4E>r\rVrTr<>r<> s<00><00>"<22> <1A>8<EFBFBD>?<3F>?<3F> <1C>D<EFBFBD><18>MrVr<>c<01>(<00><00>eZdZdZdZd<04>fd<03> Z<05>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<01>V<00><01>|D<00>cgc](}tjtj||<00><01><00><02>*}}|j dt
j <00>}d|vr8t|<04>}t|t
j <00>r||d<n ||d<04><05>|d<||d<t<00>|<00>(|i|<02><01>ycc}w)N)rc<00>_default_array_typerr)<01>
dimensionsr<EFBFBD>) rrgrrhr<>rr<>r r<>rsrq)rmrpr'ror<><00>default_array_type<70>type_from_argsrus <20>rTrqzarray_agg.__init__&s<><00><><00>
<1A> 1
<EFBFBD><1A><01> <16> <1C> <1C><15>+<2B>+<2B>Q<EFBFBD>d<EFBFBD> <0E><1A> <10>1
<EFBFBD>$<24>Z<EFBFBD>Z<EFBFBD>(=<3D>x<EFBFBD>~<7E>~<7E>N<><1A> <12>&<26> <20>,<2C>W<EFBFBD>5<>N<EFBFBD><19>.<2E>(<28>.<2E>.<2E>9<>"0<><06>w<EFBFBD><0F>"4<>"<22>q<EFBFBD>#<12><06>w<EFBFBD><0F>")<29><06>~<7E><1E> <0A><07><18>'<27>,<2C>V<EFBFBD>,<2C><>#1
s<00>-B&r<>)r<>r<>r<>r<>r<>rqr<>r<>s@rTr=r=s<00><><00><08>"<19>M<EFBFBD>-<2D>-rVr=c<01>(<00>eZdZdZdZdZ dd<04>Zy)<07> OrderedSetAggz<67>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<01>2<00>tt|jj<00>}t j
|j <00>}|jr:t|j<00>dkDr"tj|dj<00>S|djS)Nrr) rr$rYr<><00>sqlutil<69>unwrap_order_byr<79><00>array_for_multi_clauser/rnrr<>r<>)rmr<><00> func_clausesr<73>s rTr<>zOrderedSetAgg.within_group_typeCs{<00><00><1C>J<EFBFBD><04>(8<>(8<>(@<40>(@<40>A<> <0C>18<31>1H<31>1H<31> <18> !<21> !<21>2
<EFBFBD><08> <10> &<26> &<26>3<EFBFBD>|<7C>/C<>/C<>+D<>q<EFBFBD>+H<><1B>><3E>><3E>(<28>1<EFBFBD>+<2B>"2<>"2<>3<> 3<><1B>A<EFBFBD>;<3B>#<23>#<23> #rVN)r<>zWithinGroup[Any]r<>zTypeEngine[Any])r<>r<>r<>r<>rr<>r<>r\rVrTr<>r<>;s)<00><00>5<>#<23><1A><18>M<EFBFBD>
$<24>,<2C>
$<24> <18>
$rVr<>c<01><00>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<4E>r\rVrTrvrvPs<00><00><08><19>MrVrvc<01><00>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<54>r<>r<>r<>r<>rr<>r\rVrTr<>r<>]<00><00><00> <08>"<22><1A><18>MrVr<>c<01><00>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<01>6<00>eZdZdZej
<00>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<54>r<>r<>r<>r<>rr<>r<>r<>r\rVrTr<>r<>}<00><00><00><08> <1C>8<EFBFBD> <1B> <1B> <1D>D<EFBFBD><18>MrVr<>c<01>6<00>eZdZdZej
<00>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`.
TNr r\rVrTr]r]<00>r rVr]c<01>B<00>eZdZUdZej
<00>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`.
<20>!sqltypes.Numeric[decimal.Decimal]r<>TN<54> r<>r<>r<>r<>r<00>Numericr<63>r<>r<>r\rVrTr~r~<00><00>$<00><00><08>/?<3F>h<EFBFBD>.><3E>.><3E>.@<40>D<EFBFBD>
+<2B>@<40><18>MrVr~c<01>B<00>eZdZUdZej
<00>Zded<dZy)rQa Implement 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<00>rrVrQc<01><00>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<4E>r\rVrTrOrO<00><00><00><00> <08><15>I<EFBFBD><18>MrVrOc<01><00>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<4E>r\rVrTr<>r<><00>rrVr<>c<01><00>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<4E>r\rVrTrcrc<00>s<00><00><08>4<15>I<EFBFBD><18>MrVrcc<01>N<00><00>eZdZdZej
<00>ZdZdZd<04>fd<03> Z <09>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<01>&<00><01>t<00>|<00>||<02>yrwr<>)rm<00>clause<73> separatorrus <20>rTrqzaggregate_strings.__init__s<00><><00> <0A><07><18><16><19>+rV)rr<>rrL) r<>r<>r<>r<>rr<>r<>rjr<>rqr<>r<>s@rTr8r8<00>s,<00><><00><08>$ <1B>8<EFBFBD>?<3F>?<3F> <1C>D<EFBFBD><14>I<EFBFBD><18>M<EFBFBD>,<2C>,rVr8)r,)rPrLrQzType[Function[Any]]rRrLr<>r)<29>r<EFBFBD><00>
__future__r<00>datetime<6D>decimal<61>typingrrrrrr r
r r r rrr<00>rrrrrrrrr<00>_typingr<00>baserrrrr<00>elementsr r!r"r#r$r%r&r(r)r*r+r-r/<00>
selectabler0r1r2r3r4<00>visitorsr5r7r8r9r:r;r<r=r>r?r@rA<00> engine.baserB<00> engine.cursorrC<00>engine.interfacesrDrE<00> util.typingrFrGrI<00> defaultdict<63>dictrJr<>rUrXr<>r~rr6<00>modifierr1r<>r<>rxr<>r<>rDrjrqr<>rzrLrJrA<00>floatr<74>rM<00>daterT<00>timerWrYr[rfrhr<>r<>r<>r=r<>rvr<>r<>r<>r]<00>Decimalr~rQrOr<>rcr8r\rVrT<00><module>r1sY<00><01><04>#<23><0F><0E><16><17><17><17><1A><1B><1B><1B><18><17> <20><1A><18><18><17><17><13><14><16><16><1D>(<28>#<23>"<22><1C><1C><1D>%<25>&<26>#<23><1A> <20>#<23><1D>$<24><1E>$<24>!<21><1A>!<21>"<22><1E>(<28>$<24> <20>'<27><13><11>$<24>2<>;<3B><<3C>#<23>,<2C>&<26>'<27>,<2C>+<2B>'<27>(<28>,<2C>;<3B>?<3F>"<22> <0C>T<EFBFBD><13><1D><02> <0C>T<EFBFBD><13><1D><02><15>D<EFBFBD><14><14>T<EFBFBD><1A>
<EFBFBD> @<40><02> >H<01><19><13><19>,<2C><19>7:<3A><19> <09><19>0E
3<>j<EFBFBD>-<2D><02>"3<>Z<EFBFBD><1A>E
3<>P1<1B>'<27><03>,<2C>1<1B>h0<>;<3B>r<EFBFBD>?<3F>0<>4{*<2A>{*<2A>@ <1A><1B><04>!<21>)<29>)<29><04> <0C> <1D>E<EFBFBD> *<2A><08>w
<EFBFBD><EFBFBD>r<EFBFBD>"<22>w
<EFBFBD>ti
<EFBFBD>h<EFBFBD>r<EFBFBD>l<EFBFBD>i
<EFBFBD>X<12>&<26>$<24><1F><11>)<29>W<EFBFBD>%<25>"<12><1F><13>%<25>"<12>J8<>?<3F>2<EFBFBD>&<26>8<>0-<2D><1F><12>,<2C>0-<2D>f<19>!<21>"<22>%<25><19>
<19>
<1C>R<EFBFBD>
<20><19> <19>
<1C>R<EFBFBD>
<20><19> <19>
<1C>R<EFBFBD>
<20><19> <19>/<2F>(<28>+<2B>+<2B>
,<2C> <19><19>_<EFBFBD>S<EFBFBD> !<21><19>4 $<24>/<2F>#<23>&<26> $<24><19>_<EFBFBD>U<EFBFBD> #<23><19>$/<2F>O<EFBFBD>C<EFBFBD> <20>$/<2F>N<19><<3C><08> <0A> <0A>.<2E><19><19><<3C><08> <0A> <0A>.<2E><19><19> <0C>X<EFBFBD>%6<>%6<>7<><19><19><<3C><03>$<24><19><19> <0C>X<EFBFBD>.<2E>.<2E>/<2F><19><19>\<5C>(<28>"3<>"3<>4<><19><19><<3C><03>$<24><19><19>l<EFBFBD>8<EFBFBD>,<2C>,<2C>-<2D><19><19><<3C><03> <1C><19>&-<2D><0F><02>#<23>&-<2D>R$<24>O<EFBFBD>B<EFBFBD>'<27>$<24>*
<19>=<3D><12> <1C>
<19> <19>m<EFBFBD>B<EFBFBD>'<27> <19> <19>m<EFBFBD>B<EFBFBD>'<27> <19> <19>?<3F>3<EFBFBD> <1F> <19> <19><1F><13>%<25> <19> <19>?<3F>7<EFBFBD>?<3F>?<3F>3<> <19> <19><0F><07><0F><0F>0<> <19><19>?<3F>2<EFBFBD> <1E><19>$<19>_<EFBFBD>R<EFBFBD> <20><19>$<19>O<EFBFBD>B<EFBFBD>'<27><19>>,<2C><0F><03>,<2C>,rV