U@Q[SdZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd l m Z dd l m Z dd l mZdd l mZdd l mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddlmZddlmZddlmZddlmZddlmZej e!Z"ej dZ#ej$ddZ%dud!Z&Gd"d#e eeZ'Gd$d%eZ(Gd&d'e)Z*e*Z+e*je+_e*d()Z,Gd*d+e'Z-Gd,d-eZ.Gd.d/ej/e.e-Z0e&d0ee&d1eGd2d3e0Z1Gd4d5e0Z2Gd6d7e0Z3Gd8d9e3Z4Gd:d;e3Z5Gd<d=e3Z6Gd>d?e3Z7Gd@dAe0Z8GdBdCe0Z9GdDdEe0Z:GdFdGe0Z;GdHdIe0Z<GdJdKe2Z=GdLdMe2Z>GdNdOe2Z?GdPdQe2Z@GdRdSe2ZAGdTdUe2ZBGdVdWe2ZCGdXdYe2ZDGdZd[e2ZEGd\d]e0ZFGd^d_e0ZGGd`daeGZHGdbdceGZIGdddeeGZJGdfdge0ZKGdhdie0ZLGdjdke0ZMGdldme0ZNGdndoe0ZOGdpdqe0ZPGdrdse0ZQdtS)vz6SQL function API, factories, and built-in functions. ) annotation) operators)schema)sqltypes)util)ColumnCollection) Executable)_clone_literal_as_binds)_type_from_args)BinaryExpression) BindParameter)Cast) ClauseList) ColumnElement)ExtractFunctionFilter)Grouping)literal_columnOver WithinGroup)Alias) FromClause)Select) VisitableTypec4tjtSN)r defaultdictdict/srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/sqlalchemy/sql/functions.pyr((sD4DT4J4Jr&case_sensitive_functionzHSymbol to mark the functions that are switched into case-sensitive mode.)namedoc_defaultc t|}t|}|}tj|}||vr||t ur|||vr-tjd||||<ntjd|t|| dt ||<n||vr|||vrNtjdt|| |n-tjd|n|||<||||<dS)zAssociate a callable with a particular func. name. This is normally called by _GenericMeta, 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.zGenericFunction '{}' is already registered with different letter case, so the previously registered function '{}' is switched into case-sensitive mode. GenericFunction objects will be fully case-insensitive in a future release.zGenericFunction(s) '{}' are already registered with different letter cases and might interact with '{}'. GenericFunction objects will be fully case-insensitive in a future release.zLThe GenericFunction '{}' is already registered and is going to be overriden.N) _registry_case_sensitive_registryr text_typelower_CASE_SENSITIVEwarnformatwarn_deprecatedlistkeyssorted) identifierfnpackageregcase_sensitive_regraw_identifiers r'register_functionr@0s G C1':N ++1133JSS_OCC / ; ; ; I--3VJ-?-?   !C OO  "#)&"+J7<<>>??B##   .C OO ) ) ) !3J!? ? ?  "#)&-j9>>@@AA"##      I,,2F>,B,B    J68z">222r&ceZdZdZdZdZdZdZedZ e j dZ dd Z d Zd Zd Zed ZdZefdZdZddZdZdZdZddZdfd ZxZS)FunctionElementazBase for SQL function-oriented constructs. .. seealso:: :ref:`coretutorial_functions` - in the Core 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. r%Fcfd|D}jpt|_t|tjdd_dS)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` c:g|]}t|jSr%r r*.0cselfs r' z,FunctionElement.__init__..s&AAAA!!TY//AAAr&Toperatorgroup_contentsN) _has_argsboolrrcomma_op self_group clause_expr)rIclauseskwargsargss` r'__init__zFunctionElement.__init__sf BAAAAAA54::%?CY'   *,, r&c0||||Sr")_execute_function)rI connection multiparamsparamss r'_execute_on_connectionz&FunctionElement._execute_on_connections++D+vFFFr&cFt|dS)a?The set of columns exported by this :class:`.FunctionElement`. Function objects currently have no result column names built in; this method returns a single-element column collection with an anonymously named column. An interim approach to providing named columns for a function as a FROM clause is to build a :func:`_expression.select` with the desired columns:: from sqlalchemy.sql import column stmt = select([column('x'), column('y')]).\ select_from(func.myfunction()) N)rlabelrIs r'columnszFunctionElement.columnss&  4 0 0111r&c|jjS)z}Return the underlying :class:`.ClauseList` which contains the arguments for this :class:`.FunctionElement`. )rRelementr_s r'rSzFunctionElement.clausess ''r&Nc*t|||||S)aProduce 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. ) partition_byorder_byrowsrange_r)rIrdrerfrgs r'overzFunctionElement.overs*$ %     r&ct|g|RS)axProduce 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 r)rIres r' within_groupzFunctionElement.within_groups4+(++++r&c$|s|St|g|RS)aProduce 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:: :class:`.FunctionFilter` :func:`.funcfilter` r)rI criterions r'filterzFunctionElement.filters'2 Kd/Y////r&c$t|||S)ai Interpret this expression as a boolean comparison between two values. 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 )FunctionAsBinary)rI left_index right_indexs r' as_comparisonzFunctionElement.as_comparisons@ j+>>>r&c|jjSr")rS _from_objectsr_s r'rtzFunctionElement._from_objectsEs |))r&c |jfSr")rR)rIrTs r' get_childrenzFunctionElement.get_childrenIs ""r&c ||jfi||_|tj|dSr")rR_reset_exportedrBrS_reset)rIclonekws r'_copy_internalszFunctionElement._copy_internalsLsN 5!188R88 &&t,,,,,r&cdS)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%)rIrjs r'within_group_typez!FunctionElement.within_group_typeQs tr&c,tj||S)ajProduce a :class:`_expression.Alias` construct against this :class:`.FunctionElement`. This construct wraps the function in a named alias which is suitable for the FROM clause, in the style accepted for example by PostgreSQL. e.g.:: from sqlalchemy.sql import column stmt = select([column('data_view')]).\ select_from(SomeTable).\ select_from(func.unnest(SomeTable.data).alias('data_view') ) Would produce: .. sourcecode:: sql SELECT data_view FROM sometable, unnest(sometable.data) AS data_view .. versionadded:: 0.9.8 The :meth:`.FunctionElement.alias` method is now supported. Previously, this method's behavior was undefined and did not behave consistently across versions. )r _construct)rIr*flats r'aliaszFunctionElement.alias]s<d+++r&cXt|g}|jr|jdi|j}|S)zProduce a :func:`_expression.select` construct against this :class:`.FunctionElement`. This is shorthand for:: s = select([function_element]) r%)r_execution_optionsexecution_options)rIss r'selectzFunctionElement.select}s< D6NN  " ?##>>d&=>>Ar&cr|S)aExecute this :class:`.FunctionElement` against an embedded 'bind' and return a scalar value. This first calls :meth:`~.FunctionElement.select` to produce a SELECT construct. Note that :class:`.FunctionElement` can be passed to the :meth:`.Connectable.scalar` method of :class:`_engine.Connection` or :class:`_engine.Engine`. )rexecutescalarr_s r'rzFunctionElement.scalars*{{}}$$&&--///r&cN|S)agExecute this :class:`.FunctionElement` against an embedded 'bind'. This first calls :meth:`~.FunctionElement.select` to produce a SELECT construct. Note that :class:`.FunctionElement` can be passed to the :meth:`.Connectable.execute` method of :class:`_engine.Connection` or :class:`_engine.Engine`. )rrr_s r'rzFunctionElement.executes{{}}$$&&&r&c6td|||jd|S)NT)_compared_to_operator_compared_to_typeuniquetype_)rtyperIrLobjrs r' _bind_paramzFunctionElement._bind_params-  "*"i     r&c|tjur.t|jtjrt |Stt| |S)N)against) rgetitem isinstancerrARRAYrsuperrBrQ)rIr __class__s r'rQzFunctionElement.self_groupsZ i' ' 'J Ix~- - 'D>> !$//::7:KK Kr&)NNNN)NFr")__name__ __module__ __qualname____doc__ packagenamesrNrVr\propertyr`rmemoized_propertyrSrhrjrmrrrtrvr r|r~rrrrrrQ __classcell__rs@r'rBrBrs LI,GGG22X2( (((    4 , , ,000:@?@?@?D**X*###%+----   ,,,,@    0 0 0 ' ' '     L L L L L L L L L Lr&rBceZdZfdZedZejdZedZejdZfdZxZ S)roc|jj|dz }|jj|dz }||_||_||_t t |||tjtj dS)Nr)r) rS sql_functionrprqrrorVrfunction_as_comparison_opr BOOLEANTYPE)rIr;rprqleftrightrs r'rVzFunctionAsBinary.__init__sz!*q.1 ";?3$& %%..    /& /     r&c@|jjj|jdz SNrrrSrpr_s r'rzFunctionAsBinary.lefts (011DEEr&c>||jjj|jdz <dSrrrIvalues r'rzFunctionAsBinary.lefts"AF!)$/A*=>>>r&c@|jjj|jdz SrrrSrqr_s r'rzFunctionAsBinary.rights (01AA1EFFr&c>||jjj|jdz <dSrrrs r'rzFunctionAsBinary.rights#BG!)$*:Q*>???r&c |d}||jfi||_tt|jdi|dS)Nrzr%)poprrror|)rIr{rzrs r'r|z FunctionAsBinary._copy_internalssYw!E$"3::r::5%%5;;;;;;;r&) rrrrVrrsetterrr|rrs@r'roros      FFXF [GG[GGGXG \HH\H<<<<<<<<>> print(func.count(1)) 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:: >>> print(select([func.count(table.c.id)])) 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:: >>> print(func.current_timestamp()) CURRENT_TIMESTAMP To call functions which are present in dot-separated packages, specify them in the same manner:: >>> print(func.stats.yield_curve(5, 10)) 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: >>> print(func.my_string(u'hi', type_=Unicode) + ' ' + ... func.my_string(u'there', type_=Unicode)) 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:`coretutorial_functions` - in the Core Tutorial :class:`.Function` c "g|_||_dSr")_FunctionGenerator__namesopts)rIrs r'rVz_FunctionGenerator.__init__1s  r&c |dr+ |j|S#t$rt|wxYw|dr |dd}t di|j}t|j|gz|_|S)N___r.r%) startswith__dict__KeyErrorAttributeErrorendswithrrr7r)rIr*fs r' __getattr__z_FunctionGenerator.__getattr__5s ??4   +}T** + + +$T*** +]]3   ":D  + + + +&&$/ s $>cH|j}||t|j}|dkr |j\}}n|dkrd|jd}}nd}|t ||}|turGt|}|||}|||i|St|jdg|Rd|jddi|S)Nr rr,r.rr) rcopyupdatelenrr/getr2r3r0Function) rIrHrTotokensr<fnamefuncr>s r'__call__z_FunctionGenerator.__call__Cs/ INN   T\"" Q;;!\NGUU q[['aUGGG  W%))%++--88D&&%=g%F")--ekkmm<<@@GGtQ}!}}$ L  @A   +/<"+= EF   r&N)rrrrrVrrr%r&r'rrsNJJX        r&rF)groupc$eZdZdZdZdZddZdS)raDescribe 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:`coretutorial_functions` :data:`.func` - namespace which produces registered or ad-hoc :class:`.Function` instances. :class:`.GenericFunction` - allows creation of registered function types. functionc|ddpg|_||_|dd|_t j|dd|_tj |g|Ri|dS)zConstruct a :class:`.Function`. The :data:`.func` construct is normally used to construct new :class:`.Function` instances. rNbindr) rrr*r_bindr to_instancerrBrV)rIr*rSr{s r'rVzFunction.__init__sFF>488>B VVFD)) ()>)>??  6666266666r&Nc@t|j|||j|dS)NT)rrrr)rr*rrs r'rzFunction._bind_params/ I "*"i     r&r")rrrr__visit_name__rVrr%r&r'rrdsIB N 7 7 7      r&rceZdZfdZxZS) _GenericMetactj|jvr|d|x|_}|d|x|_}|dd}d|vr |d|_t|dd|_ |j rt|||nd|_ tt| |||dS)Nr*r:r<r,__return_type__ _registerT)r Annotated__mro__rr*r:rrgetattrrr@rrrV)clsclsnamebasesclsdictr*r:r<rs r'rVz_GenericMeta.__init__s  s{ 2 2%kk&':: :CHt*1++lD*I*I ICNZkk)Z88G G++"#45$Cd;;CM} %!*c7;;;;!%  lC  ))'5'BBBBBr&)rrrrVrrs@r'rrsACCCCCCCCCr&rc eZdZdZdZdZdZdS)GenericFunctiona Define 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 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" 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" The above function will render as follows:: >>> print(func.geo.buffer()) 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" The above function will render as:: >>> print(func.geo.buffer()) "ST_Buffer"() .. 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. TFc|dd}|fd|D}jpt|_g_|dd_t |tjdd _ tj |ddptdd_dS)N _parsed_argsc:g|]}t|jSr%rErFs r'rJz,GenericFunction.__init__..s&IIIq,Q ::IIIr&rTrKrr)rrNrOrrrrrrPrQrRrrrr)rIrUrT parsed_argss` r'rVzGenericFunction.__init__sjj66  IIIIDIIIK<4 +<+<ZZ-- %?JY'   *,, ( JJw % % Dvt)D)D   r&N)rrrrcoerce_argumentsrrVr%r&r'rrs=TTlI      r&rcastextractcPeZdZdZejZdZdZe dZ dS) next_valueaRepresent 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. c t|tjs Jd|dd|_||_dS)Nz0next_value() accepts a Sequence object as input.r)rrSequencerrsequence)rIseqr{s r'rVznext_value.__init__2sT    > > = > > VVFD))  r&cgSr"r%r_s r'rtznext_value._from_objects9s r&N) rrrrrIntegerrr*rVrrtr%r&r'rr%s_ 8   D DXr&rceZdZdZdS) AnsiFunctionc0tj|g|Ri|dSr"rrV)rIrUrTs r'rVzAnsiFunction.__init__?s) 777777777r&N)rrrrVr%r&r'rr>s#88888r&rc"eZdZdZfdZxZS)ReturnTypeFromArgszADefine a function whose return type is the same as its arguments.cfd|D}|dt|||d<ttj|i|dS)Nc:g|]}t|jSr%rErFs r'rJz/ReturnTypeFromArgs.__init__..Gs&>>>A!!TY//>>>r&rr) setdefaultr rrrV)rIrUrTrs` r'rVzReturnTypeFromArgs.__init__Fsn>>>>>>>'?4#8#8999!%~0 $''0$A&AAAAAr&)rrrrrVrrs@r'rrCsGKKBBBBBBBBBr&rceZdZdZdS)coalesceTNrrrrNr%r&r'rrMIIIr&rceZdZdS)maxNrrrr%r&r'rrQDr&rceZdZdS)minNrr%r&r'r r Ur r&r ceZdZdS)sumNrr%r&r'r r Yr r&r ceZdZejZdS)nowNrrrrDateTimerr%r&r'rr]  DDDr&rceZdZejZdS)concatNrrrrStringrr%r&r'rra ?DDDr&rc"eZdZejZdZdS) char_lengthc ,tj||fi|dSr"r)rIargrTs r'rVzchar_length.__init__hs# s55f55555r&N)rrrrrrrVr%r&r'rres+  D66666r&rceZdZdZdS)randomTNrr%r&r'rrlrr&rc2eZdZdZejZdfd ZxZS)countaThe 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:: SELECT count(*) AS count_1 FROM some_table Nc l|td}tt|j|fi|dS)N*)rrrrV)rI expressionrTrs r'rVzcount.__init__sA  ',,J#eT#J99&99999r&r") rrrrrrrrVrrs@r'rrpsQ(  D::::::::::r&rceZdZejZdS) current_dateN)rrrrDaterr%r&r'r$r$ =DDDr&r$ceZdZejZdS) current_timeN)rrrrTimerr%r&r'r(r(r&r&r(ceZdZejZdS)current_timestampNrr%r&r'r+r+rr&r+ceZdZejZdS) current_userNrr%r&r'r-r-rr&r-ceZdZejZdS) localtimeNrr%r&r'r/r/rr&r/ceZdZejZdS)localtimestampNrr%r&r'r1r1rr&r1ceZdZejZdS) session_userNrr%r&r'r3r3rr&r3ceZdZejZdS)sysdateNrr%r&r'r5r5rr&r5ceZdZejZdS)userNrr%r&r'r7r7rr&r7c0eZdZdZejZfdZxZS) array_aggaSupport 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]]) .. versionadded:: 1.1 .. seealso:: :func:`_postgresql.array_agg` - PostgreSQL-specific version that returns :class:`_postgresql.ARRAY`, which has PG-specific operators added. c,d|D}|dtj}d|vr=t|}t |tjr||d<n|||d<||d<t t |j|i|dS)Nc,g|]}t|Sr%r )rGrHs r'rJz&array_agg.__init__..s!333!!$$333r&_default_array_typerr)rrrr rrr9rV)rIrUrTdefault_array_typetype_from_argsrs r'rVzarray_agg.__init__s33d333#ZZ(=x~NN & ,T22N.(.99 E"0w"4"4^"D"Dw!%~'i'888888r&) rrrrrrrrVrrs@r'r9r9sK& >D 9 9 9 9 9 9 9 9 9r&r9ceZdZdZdZdZdS) OrderedSetAggzDefine 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.Fc|jj}tj|j}|jr7t |jdkrtj |dj S|dj S)Nrr.) rRrbsqlutilunwrap_order_byrearray_for_multi_clauserrSrrr)rIrj func_clausesres r'r~zOrderedSetAgg.within_group_typesd'/ *<+@AA  & $3|/C+D+Dq+H+H>(1+"233 3A;# #r&N)rrrrrDr~r%r&r'r@r@s555#$$$$$r&r@ceZdZdZdS)modea*Implement 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. .. versionadded:: 1.1 N)rrrrr%r&r'rGrGs    r&rGceZdZdZdZdS)percentile_contaImplement 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. .. versionadded:: 1.1 TNrrrrrDr%r&r'rIrI"  "r&rIceZdZdZdZdS)percentile_discaImplement 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. .. versionadded:: 1.1 TNrJr%r&r'rMrMrKr&rMc0eZdZdZejZdS)ranka!Implement 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`. .. versionadded:: 1.1 Nrrrrrrrr%r&r'rOrO*   8   DDDr&rOc0eZdZdZejZdS) dense_ranka'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`. .. versionadded:: 1.1 NrPr%r&r'rSrS$rQr&rSc0eZdZdZejZdS) percent_ranka)Implement 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`. .. versionadded:: 1.1 NrrrrrNumericrr%r&r'rUrU3rQr&rUc0eZdZdZejZdS) cume_dista&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`. .. versionadded:: 1.1 NrVr%r&r'rYrYBrQr&rYceZdZdZdZdS)cubeaYImplement 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 TNrrrrrNr%r&r'r[r[Q  IIIr&r[ceZdZdZdZdS)rollupaYImplement the ``ROLLUP`` grouping operation. This function is used as part of the GROUP BY of a statement, e.g. :meth:`_expression.Select.group_by`:: stmt = select( [func.sum(table.c.value), table.c.col_1, table.c.col_2] ).group_by(func.rollup(table.c.col_1, table.c.col_2)) .. versionadded:: 1.2 TNr\r%r&r'r_r_ar]r&r_ceZdZdZdZdS) grouping_setsa0Implement the ``GROUPING SETS`` grouping operation. This function is used as part of the GROUP BY of a statement, e.g. :meth:`_expression.Select.group_by`:: stmt = select( [func.sum(table.c.value), table.c.col_1, table.c.col_2] ).group_by(func.grouping_sets(table.c.col_1, table.c.col_2)) In order to group by multiple sets, use the :func:`.tuple_` construct:: from sqlalchemy import tuple_ stmt = select( [ func.sum(table.c.value), table.c.col_1, table.c.col_2, table.c.col_3] ).group_by( func.grouping_sets( tuple_(table.c.col_1, table.c.col_2), tuple_(table.c.value, table.c.col_3), ) ) .. versionadded:: 1.2 TNr\r%r&r'raraqs:IIIr&raN)r,)RrrrrrrrBbaserr elementsr r r rrrrrrrrrrr selectablerrrvisitorsrr#r$r/r0symbolr3r@rBroobjectrrmodifierrrwith_metaclassrrrrrrr r rrrrrr$r(r+r-r/r1r3r5r7r9r@rGrIrMrOrSrUrYr[r_rar%r&r'rksY """"""''''''%%%%%%&&&&&&###### ######$$$$$$$$$$$$!!!!!!""""""###### D T " " +4+,J,JKK$+ " ?8?8?8?8DILILILILILj-ILILILX #<#<#<#<#<'#<#<#