class FunctionElement(Executable, ColumnElement[
Known subclasses: sqlalchemy.sql.functions.Function
Base for SQL function-oriented constructs. .. 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.
Method | __init__ |
Construct a :class:`.FunctionElement`. |
Method | alias |
Produce a :class:`_expression.Alias` construct against this :class:`.FunctionElement`. |
Method | as |
Interpret this expression as a boolean comparison between two values. |
Method | clauses |
Return the underlying :class:`.ClauseList` which contains the arguments for this :class:`.FunctionElement`. |
Method | column |
Return this :class:`_functions.FunctionElement` as a column expression that selects from itself as a FROM clause. |
Method | filter |
Produce a FILTER clause against this function. |
Method | over |
Produce an OVER clause against this function. |
Method | scalar |
Return a column expression that's against this :class:`_functions.FunctionElement` as a scalar table-valued expression. |
Method | select |
Produce a :func:`_expression.select` construct against this :class:`.FunctionElement`. |
Method | self |
Apply a 'grouping' to this :class:`_expression.ClauseElement`. |
Method | table |
Return a :class:`_sql.TableValuedAlias` representation of this :class:`_functions.FunctionElement` with table-valued expressions added. |
Method | within |
Produce a WITHIN GROUP (ORDER BY expr) clause against this function. |
Method | within |
For types that define their return type as based on the criteria within a WITHIN GROUP (ORDER BY) expression, called by the :class:`.WithinGroup` construct. |
Class Variable | packagenames |
Undocumented |
Class Variable | primary |
Return the iterable collection of :class:`_schema.Column` objects which comprise the primary key of this :class:`_selectable.FromClause`. |
Instance Variable | clause |
Undocumented |
Property | c |
synonym for :attr:`.FunctionElement.columns`. |
Property | columns |
The set of columns exported by this :class:`.FunctionElement`. |
Property | entity |
overrides FromClause.entity_namespace as functions are generally column expressions and not FromClauses. |
Property | exported |
A :class:`_expression.ColumnCollection` that represents the "exported" columns of this :class:`_expression.Selectable`. |
Method | _bind |
Undocumented |
Method | _execute |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _non |
the 'name' that naturally applies this element when rendered in SQL. |
Class Variable | _table |
Undocumented |
Class Variable | _traverse |
Undocumented |
Class Variable | _with |
Undocumented |
Instance Variable | _has |
Undocumented |
Property | _all |
A sequence of column expression objects that represents the "selected" columns of this :class:`_expression.ReturnsRows`. |
Property | _from |
Undocumented |
Property | _proxy |
Undocumented |
Inherited from Executable
:
Method | execution |
Set non-SQL options for the statement which take effect during execution. |
Method | get |
Get the non-SQL options which will take effect during execution. |
Method | options |
Apply options to this statement. |
Class Variable | __visit |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | supports |
Undocumented |
Method | _add |
Add a context option to this statement. |
Method | _compile |
Undocumented |
Method | _execute |
Undocumented |
Method | _set |
Assign the compile options to a new value. |
Method | _update |
update the _compile_options with new keys. |
Class Variable | _executable |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _with |
Undocumented |
Class Variable | _with |
Undocumented |
Instance Variable | _compile |
Undocumented |
Instance Variable | _execution |
Undocumented |
Property | _effective |
Undocumented |
Inherited from StatementRole
(via Executable
):
Class Variable | __slots__ |
Undocumented |
Class Variable | _role |
Undocumented |
Property | _propagate |
Undocumented |
Inherited from ColumnElement
(via Executable
, StatementRole
):
Method | __getattr__ |
Undocumented |
Method | cast |
Produce a type cast, i.e. ``CAST(<expression> AS <type>)``. |
Method | comparator |
Undocumented |
Method | label |
Produce a column label, i.e. ``<columnname> AS <name>``. |
Method | operate |
Operate on an argument. |
Method | reverse |
Reverse operate on an argument. |
Method | shares |
Return True if the given :class:`_expression.ColumnElement` has a common ancestor to this :class:`_expression.ColumnElement`. |
Class Variable | foreign |
Undocumented |
Class Variable | key |
The 'key' that in some circumstances refers to this object in a Python namespace. |
Property | anon |
Undocumented |
Property | anon |
Undocumented |
Property | base |
Undocumented |
Property | expression |
Return a column expression. |
Property | proxy |
set of all columns we are proxying |
Property | type |
Undocumented |
Method | _anon |
Undocumented |
Method | _compare |
Return True if the given column element compares to this one when targeting within a result row. |
Method | _dedupe |
label to apply to a column that is anon labeled, but repeated in the SELECT, so that we have to make an "extra anon" label that disambiguates it from the previous appearance. |
Method | _dedupe |
Undocumented |
Method | _expression |
a suggested label to use in the case that the column has no name, which should be used if possible as the explicit 'AS <label>' where this expression would normally have an anon label. |
Method | _make |
Create a new :class:`_expression.ColumnElement` representing this :class:`_expression.ColumnElement` as it appears in the select list of a descending selectable. |
Method | _negate |
Undocumented |
Method | _tq |
A label-based version of 'key' that in some circumstances refers to this object in a Python namespace. |
Method | _uncached |
An 'uncached' version of proxy set. |
Class Variable | _allow |
A flag that can be flipped to prevent a column from being resolvable by string label name. |
Class Variable | _alt |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _render |
A flag used by select._columns_plus_names that helps to determine we are actually going to render in terms of "SELECT <col> AS <label>". This flag can be returned as False for some Column objects that want to be rendered as simple "SELECT <col>"; typically columns that don't have any parent table and are named the same as what the label would be in any case. |
Property | _anon |
Provides a constant 'anonymous key label' for this ColumnElement. |
Property | _anon |
Provides a constant 'anonymous label' for this ColumnElement. |
Property | _anon |
Undocumented |
Property | _anon |
Undocumented |
Property | _expanded |
Undocumented |
Property | _key |
legacy; renamed to _tq_key_label |
Property | _label |
legacy; renamed to _tq_label |
Property | _proxies |
Undocumented |
Property | _select |
Undocumented |
Property | _tq |
The named label that can be used to target this column in a result set in a "table qualified" context. |
Inherited from FromClause
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
):
Method | is |
Return ``True`` if this :class:`_expression.FromClause` is 'derived' from the given ``FromClause``. |
Method | join |
Return a :class:`_expression.Join` from this :class:`_expression.FromClause` to another :class:`FromClause`. |
Method | outerjoin |
Return a :class:`_expression.Join` from this :class:`_expression.FromClause` to another :class:`FromClause`, with the "isouter" flag set to True. |
Method | tablesample |
Return a TABLESAMPLE alias of this :class:`_expression.FromClause`. |
Class Variable | is |
Undocumented |
Class Variable | named |
Undocumented |
Class Variable | schema |
Define the 'schema' attribute for this :class:`_expression.FromClause`. |
Property | description |
A brief description of this :class:`_expression.FromClause`. |
Method | _anonymous |
Undocumented |
Method | _generate |
Populate columns into an :class:`.AliasedReturnsRows` object. |
Method | _init |
Undocumented |
Method | _is |
Return ``True`` if this :class:`_expression.FromClause` and the other represent the same lexical identity. |
Method | _populate |
Called on subclasses to establish the .c collection. |
Method | _refresh |
Given a column added to the .c collection of an underlying selectable, produce the local version of that column, assuming this selectable ultimately should proxy this column. |
Method | _reset |
Reset the attributes linked to the ``FromClause.c`` attribute. |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _use |
Undocumented |
Instance Variable | _columns |
Undocumented |
Property | _cols |
Undocumented |
Property | _hide |
Undocumented |
Inherited from FromClauseRole
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
):
Class Variable | _is |
Undocumented |
Inherited from AllowsLambdaRole
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
):
Class Variable | allows |
Undocumented |
Inherited from UsesInspection
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
):
Class Variable | uses |
Undocumented |
Class Variable | _post |
Undocumented |
Inherited from SQLCoreOperations
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
):
Method | __add__ |
Implement the ``+`` operator. |
Method | __and__ |
Implement the ``&`` operator. |
Method | __contains__ |
Undocumented |
Method | __eq__ |
Implement the ``==`` operator. |
Method | __floordiv__ |
Implement the ``//`` operator. |
Method | __ge__ |
Implement the ``>=`` operator. |
Method | __getitem__ |
Implement the [] operator. |
Method | __gt__ |
Implement the ``>`` operator. |
Method | __invert__ |
Implement the ``~`` operator. |
Method | __le__ |
Implement the ``<=`` operator. |
Method | __lt__ |
Implement the ``<`` operator. |
Method | __mod__ |
Implement the ``%`` operator. |
Method | __mul__ |
Implement the ``*`` operator. |
Method | __ne__ |
Implement the ``!=`` operator. |
Method | __neg__ |
Implement the ``-`` operator. |
Method | __or__ |
Implement the ``|`` operator. |
Method | __radd__ |
Implement the ``+`` operator in reverse. |
Method | __rfloordiv__ |
Implement the ``//`` operator in reverse. |
Method | __rmod__ |
Implement the ``%`` operator in reverse. |
Method | __rmul__ |
Implement the ``*`` operator in reverse. |
Method | __rsub__ |
Implement the ``-`` operator in reverse. |
Method | __rtruediv__ |
Implement the ``/`` operator in reverse. |
Method | __sub__ |
Implement the ``-`` operator. |
Method | __truediv__ |
Implement the ``/`` operator. |
Method | all_ |
Produce an :func:`_expression.all_` clause against the parent object. |
Method | any_ |
Produce an :func:`_expression.any_` clause against the parent object. |
Method | asc |
Produce a :func:`_expression.asc` clause against the parent object. |
Method | between |
Produce a :func:`_expression.between` clause against the parent object, given the lower and upper range. |
Method | bool |
Return a custom boolean operator. |
Method | collate |
Produce a :func:`_expression.collate` clause against the parent object, given the collation string. |
Method | concat |
Implement the 'concat' operator. |
Method | contains |
Implement the 'contains' operator. |
Method | desc |
Produce a :func:`_expression.desc` clause against the parent object. |
Method | distinct |
Produce a :func:`_expression.distinct` clause against the parent object. |
Method | endswith |
Implement the 'endswith' operator. |
Method | ilike |
Implement the ``ilike`` operator, e.g. case insensitive LIKE. |
Method | in_ |
Implement the ``in`` operator. |
Method | is_ |
Implement the ``IS`` operator. |
Method | is |
Implement the ``IS DISTINCT FROM`` operator. |
Method | is |
Implement the ``IS NOT`` operator. |
Method | is |
Implement the ``IS NOT DISTINCT FROM`` operator. |
Method | isnot |
Undocumented |
Method | like |
Implement the ``like`` operator. |
Method | match |
Implements a database-specific 'match' operator. |
Method | not |
implement the ``NOT ILIKE`` operator. |
Method | not |
implement the ``NOT IN`` operator. |
Method | not |
implement the ``NOT LIKE`` operator. |
Method | notilike |
Undocumented |
Method | notin_ |
Undocumented |
Method | notlike |
Undocumented |
Method | nulls |
Produce a :func:`_expression.nulls_first` clause against the parent object. |
Method | nulls |
Produce a :func:`_expression.nulls_last` clause against the parent object. |
Method | nullsfirst |
Undocumented |
Method | nullslast |
Undocumented |
Method | op |
Produce a generic operator function. |
Method | regexp |
Implements a database-specific 'regexp match' operator. |
Method | regexp |
Implements a database-specific 'regexp replace' operator. |
Method | startswith |
Implement the ``startswith`` operator. |
Inherited from ColumnOperators
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
):
Method | __lshift__ |
implement the << operator. |
Method | __rshift__ |
implement the >> operator. |
Method | bitwise |
Produce a bitwise AND operation, typically via the ``&`` operator. |
Method | bitwise |
Produce a bitwise LSHIFT operation, typically via the ``<<`` operator. |
Method | bitwise |
Produce a bitwise NOT operation, typically via the ``~`` operator. |
Method | bitwise |
Produce a bitwise OR operation, typically via the ``|`` operator. |
Method | bitwise |
Produce a bitwise RSHIFT operation, typically via the ``>>`` operator. |
Method | bitwise |
Produce a bitwise XOR operation, typically via the ``^`` operator, or ``#`` for PostgreSQL. |
Method | icontains |
Implement the ``icontains`` operator, e.g. case insensitive version of :meth:`.ColumnOperators.contains`. |
Method | iendswith |
Implement the ``iendswith`` operator, e.g. case insensitive version of :meth:`.ColumnOperators.endswith`. |
Method | isnot |
Undocumented |
Method | istartswith |
Implement the ``istartswith`` operator, e.g. case insensitive version of :meth:`.ColumnOperators.startswith`. |
Class Variable | timetuple |
Hack, allows datetime objects to be compared on the LHS. |
Method | _rconcat |
Implement an 'rconcat' operator. |
Inherited from Selectable
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
):
Method | corresponding |
Given a :class:`_expression.ColumnElement`, return the exported :class:`_expression.ColumnElement` object from the :attr:`_expression.Selectable.exported_columns` collection of this :class:`_expression... |
Method | lateral |
Return a LATERAL alias of this :class:`_expression.Selectable`. |
Method | replace |
Replace all occurrences of :class:`_expression.FromClause` 'old' with the given :class:`_expression.Alias` object, returning a copy of this :class:`_expression.FromClause`. |
Inherited from ReturnsRows
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, Selectable
):
Property | selectable |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Inherited from DQLDMLClauseElement
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, Selectable
, ReturnsRows
, ReturnsRowsRole
, SQLRole
):
Method | compile |
Compile this SQL expression. |
Method | _compiler |
Return a compiler appropriate for this ClauseElement, given a Dialect. |
Inherited from ClauseElement
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, Selectable
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
):
Method | __bool__ |
Undocumented |
Method | __getstate__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | compare |
Compare this :class:`_expression.ClauseElement` to the given :class:`_expression.ClauseElement`. |
Method | get |
Return immediate child :class:`.visitors.HasTraverseInternals` elements of this :class:`.visitors.HasTraverseInternals`. |
Method | params |
Return a copy with :func:`_expression.bindparam` elements replaced. |
Method | unique |
Return a copy with :func:`_expression.bindparam` elements replaced. |
Class Variable | is |
Undocumented |
Class Variable | negation |
Undocumented |
Method | _clone |
Create a shallow copy of this ClauseElement. |
Method | _cloned |
Return the set consisting all cloned ancestors of this ClauseElement. |
Method | _negate |
a hook to allow the right side of a binary expression to respond to a negation of the binary expression. |
Method | _replace |
Undocumented |
Method | _set |
Undocumented |
Method | _ungroup |
Return this :class:`_expression.ClauseElement` without any groupings. |
Method | _with |
in the context of binary expression, convert the type of this object to the one given. |
Class Variable | _cache |
Undocumented |
Class Variable | _gen |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Property | _constructor |
return the 'constructor' for this ClauseElement. |
Property | _order |
Undocumented |
Inherited from SupportsWrappingAnnotations
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, Selectable
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
):
Method | _annotate |
return a copy of this ClauseElement with annotations updated by the given dictionary. |
Method | _deannotate |
return a copy of this :class:`_expression.ClauseElement` with annotations removed. |
Method | _with |
return a copy of this ClauseElement with annotations replaced by the given dictionary. |
Inherited from SupportsAnnotations
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, Selectable
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
):
Method | _gen |
Undocumented |
Property | _annotations |
Undocumented |
Inherited from MemoizedHasCacheKey
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, Selectable
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
):
Method | _generate |
return a cache key. |
Inherited from HasCacheKey
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, Selectable
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
):
Class Variable | inherit |
Indicate if this :class:`.HasCacheKey` instance should make use of the cache key generation scheme used by its immediate superclass. |
Class Method | _generate |
generate cache key dispatcher for a new class. |
Class Method | _generate |
Undocumented |
Method | _gen |
return an optional cache key. |
Class Variable | _generated |
Undocumented |
Class Variable | _hierarchy |
private attribute which may be set to False to prevent the inherit_cache warning from being emitted for a hierarchy of subclasses. |
Class Variable | _is |
Undocumented |
Inherited from Generative
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, Selectable
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
, HasCacheKey
):
Method | _generate |
Undocumented |
Inherited from HasCopyInternals
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, Selectable
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
, HasCacheKey
, Generative
):
Method | _copy |
Reassign internal elements to be clones of themselves. |
Inherited from CompilerElement
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, Selectable
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
, HasCacheKey
, Generative
, HasCopyInternals
, ExternallyTraversible
, HasTraverseInternals
):
Method | __str__ |
Undocumented |
Class Variable | stringify |
Undocumented |
Inherited from Visitable
(via Executable
, StatementRole
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, FromClause
, AnonymizedFromClauseRole
, StrictFromClauseRole
, FromClauseRole
, ColumnsClauseRole
, JoinTargetRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, Selectable
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
, HasCacheKey
, Generative
, HasCopyInternals
, ExternallyTraversible
, HasTraverseInternals
, CompilerElement
):
Method | __class |
Undocumented |
Method | __init |
Undocumented |
Class Method | _generate |
Undocumented |
Method | _compiler |
Undocumented |
Class Variable | _original |
Undocumented |
sqlalchemy.sql.functions.Function
Construct 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`
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`
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
Return the underlying :class:`.ClauseList` which contains the arguments for this :class:`.FunctionElement`.
Return 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`
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) .. versionadded:: 1.0.0 .. seealso:: :ref:`tutorial_functions_within_group` - in the :ref:`unified_tutorial` :class:`.FunctionFilter` :func:`.funcfilter`
Produce 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`
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`
Produce a :func:`_expression.select` construct against this :class:`.FunctionElement`. This is shorthand for:: s = select(function_element)
Apply a 'grouping' to this :class:`_expression.ClauseElement`. This method is overridden by subclasses to return a "grouping" construct, i.e. parenthesis. In particular it's used by "binary" expressions to provide a grouping around themselves when placed into a larger expression, as well as by :func:`_expression.select` constructs when placed into the FROM clause of another :func:`_expression.select`. (Note that subqueries should be normally created using the :meth:`_expression.Select.alias` method, as many platforms require nested SELECT statements to be named). As expressions are composed together, the application of :meth:`self_group` is automatic - end-user code should never need to use this method directly. Note that SQLAlchemy's clause constructs take operator precedence into account - so parenthesis might not be needed, for example, in an expression like ``x OR (y AND z)`` - AND takes precedence over OR. The base :meth:`self_group` method of :class:`_expression.ClauseElement` just returns self.
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, ...)``
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. .. versionadded:: 1.1 .. seealso:: :ref:`tutorial_functions_within_group` - in the :ref:`unified_tutorial`
sqlalchemy.sql.functions.OrderedSetAgg
For 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.
Return the iterable collection of :class:`_schema.Column` objects which comprise the primary key of this :class:`_selectable.FromClause`. For a :class:`_schema.Table` object, this collection is represented by the :class:`_schema.PrimaryKeyConstraint` which itself is an iterable collection of :class:`_schema.Column` objects.
The 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.
overrides FromClause.entity_namespace as functions are generally column expressions and not FromClauses.
A :class:`_expression.ColumnCollection` that represents the "exported" columns of this :class:`_expression.Selectable`. The "exported" columns for a :class:`_expression.FromClause` object are synonymous with the :attr:`_expression.FromClause.columns` collection. .. versionadded:: 1.4 .. seealso:: :attr:`_expression.Selectable.exported_columns` :attr:`_expression.SelectBase.exported_columns`
Connection
, distilled_params: _CoreMultiExecuteParams
, execution_options: CoreExecuteOptionsParameter
) -> CursorResult[ Any]
:
(source)
¶
Undocumented
the 'name' that naturally applies this element when rendered in SQL. Concretely, this is the "name" of a column or a label in a SELECT statement; ``<columnname>`` and ``<labelname>`` below:: SELECT <columnmame> FROM table SELECT column AS <labelname> FROM table Above, the two names noted will be what's present in the DBAPI ``cursor.description`` as the names. If this attribute returns ``None``, it means that the SQL element as written does not have a 100% fully predictable "name" that would appear in the ``cursor.description``. Examples include SQL functions, CAST functions, etc. While such things do return names in ``cursor.description``, they are only predictable on a database-specific basis; e.g. an expression like ``MAX(table.col)`` may appear as the string ``max`` on one database (like PostgreSQL) or may appear as the whole expression ``max(table.col)`` on SQLite. The default implementation looks for a ``.name`` attribute on the object, as has been the precedent established in SQLAlchemy for many years. An exception is made on the ``FunctionElement`` subclass so that the return value is always ``None``. .. versionadded:: 1.4.21
A sequence of column expression objects that represents the "selected" columns of this :class:`_expression.ReturnsRows`. This is typically equivalent to .exported_columns except it is delivered in the form of a straight sequence and not keyed :class:`_expression.ColumnCollection`.