Python sqlalchemy.func.percentile_cont() Examples
The following are 13
code examples of sqlalchemy.func.percentile_cont().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy.func
, or try the search function
.
Example #1
Source File: test_functions.py From sqlalchemy with MIT License | 6 votes |
def test_funcfilter_within_group_multi(self): stmt = select( [ table1.c.myid, func.percentile_cont(0.5).within_group( table1.c.name, table1.c.description ), ] ) self.assert_compile( stmt, "SELECT mytable.myid, percentile_cont(:percentile_cont_1) " "WITHIN GROUP (ORDER BY mytable.name, mytable.description) " "AS anon_1 " "FROM mytable", {"percentile_cont_1": 0.5}, )
Example #2
Source File: test_functions.py From sqlalchemy with MIT License | 6 votes |
def test_funcfilter_within_group_w_over(self): stmt = select( [ table1.c.myid, func.percentile_cont(0.5) .within_group(table1.c.name.desc()) .over(partition_by=table1.c.description), ] ) self.assert_compile( stmt, "SELECT mytable.myid, percentile_cont(:percentile_cont_1) " "WITHIN GROUP (ORDER BY mytable.name DESC) " "OVER (PARTITION BY mytable.description) AS anon_1 " "FROM mytable", {"percentile_cont_1": 0.5}, )
Example #3
Source File: test_functions.py From sqlalchemy with MIT License | 6 votes |
def test_percentile_cont_array(self): expr = func.percentile_cont(0.5, 0.7).within_group( column("data", Integer) ) is_(expr.type._type_affinity, ARRAY) is_(expr.type.item_type._type_affinity, Integer)
Example #4
Source File: elements.py From planespotter with MIT License | 5 votes |
def __init__(self, element, *order_by): r"""Produce a :class:`.WithinGroup` object against a function. Used against so-called "ordered set aggregate" and "hypothetical set aggregate" functions, including :class:`.percentile_cont`, :class:`.rank`, :class:`.dense_rank`, etc. :func:`~.expression.within_group` is usually called using the :meth:`.FunctionElement.within_group` method, e.g.:: from sqlalchemy import within_group stmt = select([ department.c.id, func.percentile_cont(0.5).within_group( department.c.salary.desc() ) ]) The above statement would produce SQL similar to ``SELECT department.id, percentile_cont(0.5) WITHIN GROUP (ORDER BY department.salary DESC)``. :param element: a :class:`.FunctionElement` construct, typically generated by :data:`~.expression.func`. :param \*order_by: one or more column elements that will be used as the ORDER BY clause of the WITHIN GROUP construct. .. versionadded:: 1.1 .. seealso:: :data:`.expression.func` :func:`.expression.over` """ self.element = element if order_by is not None: self.order_by = ClauseList( *util.to_list(order_by), _literal_as_text=_literal_as_label_reference)
Example #5
Source File: elements.py From pyRevit with GNU General Public License v3.0 | 5 votes |
def __init__(self, element, *order_by): r"""Produce a :class:`.WithinGroup` object against a function. Used against so-called "ordered set aggregate" and "hypothetical set aggregate" functions, including :class:`.percentile_cont`, :class:`.rank`, :class:`.dense_rank`, etc. :func:`~.expression.within_group` is usually called using the :meth:`.FunctionElement.within_group` method, e.g.:: from sqlalchemy import within_group stmt = select([ department.c.id, func.percentile_cont(0.5).within_group( department.c.salary.desc() ) ]) The above statement would produce SQL similar to ``SELECT department.id, percentile_cont(0.5) WITHIN GROUP (ORDER BY department.salary DESC)``. :param element: a :class:`.FunctionElement` construct, typically generated by :data:`~.expression.func`. :param \*order_by: one or more column elements that will be used as the ORDER BY clause of the WITHIN GROUP construct. .. versionadded:: 1.1 .. seealso:: :data:`.expression.func` :func:`.expression.over` """ self.element = element if order_by is not None: self.order_by = ClauseList( *util.to_list(order_by), _literal_as_text=_literal_as_label_reference)
Example #6
Source File: elements.py From sqlalchemy with MIT License | 5 votes |
def __init__(self, element, *order_by): r"""Produce a :class:`.WithinGroup` object against a function. Used against so-called "ordered set aggregate" and "hypothetical set aggregate" functions, including :class:`.percentile_cont`, :class:`.rank`, :class:`.dense_rank`, etc. :func:`_expression.within_group` is usually called using the :meth:`.FunctionElement.within_group` method, e.g.:: from sqlalchemy import within_group stmt = select([ department.c.id, func.percentile_cont(0.5).within_group( department.c.salary.desc() ) ]) The above statement would produce SQL similar to ``SELECT department.id, percentile_cont(0.5) WITHIN GROUP (ORDER BY department.salary DESC)``. :param element: a :class:`.FunctionElement` construct, typically generated by :data:`~.expression.func`. :param \*order_by: one or more column elements that will be used as the ORDER BY clause of the WITHIN GROUP construct. .. versionadded:: 1.1 .. seealso:: :data:`.expression.func` :func:`_expression.over` """ self.element = element if order_by is not None: self.order_by = ClauseList( *util.to_list(order_by), _literal_as_text_role=roles.ByOfRole )
Example #7
Source File: test_functions.py From sqlalchemy with MIT License | 5 votes |
def test_funcfilter_within_group(self): stmt = select( [ table1.c.myid, func.percentile_cont(0.5).within_group(table1.c.name), ] ) self.assert_compile( stmt, "SELECT mytable.myid, percentile_cont(:percentile_cont_1) " "WITHIN GROUP (ORDER BY mytable.name) " "AS anon_1 " "FROM mytable", {"percentile_cont_1": 0.5}, )
Example #8
Source File: test_functions.py From sqlalchemy with MIT License | 5 votes |
def test_funcfilter_within_group_desc(self): stmt = select( [ table1.c.myid, func.percentile_cont(0.5).within_group(table1.c.name.desc()), ] ) self.assert_compile( stmt, "SELECT mytable.myid, percentile_cont(:percentile_cont_1) " "WITHIN GROUP (ORDER BY mytable.name DESC) " "AS anon_1 " "FROM mytable", {"percentile_cont_1": 0.5}, )
Example #9
Source File: test_functions.py From sqlalchemy with MIT License | 5 votes |
def test_percentile_cont_array_desc(self): expr = func.percentile_cont(0.5, 0.7).within_group( column("data", Integer).desc() ) is_(expr.type._type_affinity, ARRAY) is_(expr.type.item_type._type_affinity, Integer)
Example #10
Source File: test_compiler.py From sqlalchemy with MIT License | 5 votes |
def test_within_group(self): # stringify of these was supported anyway by defaultdialect. from sqlalchemy import within_group stmt = select( [ table1.c.myid, within_group(func.percentile_cont(0.5), table1.c.name.desc()), ] ) eq_ignore_whitespace( str(stmt), "SELECT mytable.myid, percentile_cont(:percentile_cont_1) " "WITHIN GROUP (ORDER BY mytable.name DESC) AS anon_1 FROM mytable", )
Example #11
Source File: elements.py From jarvis with GNU General Public License v2.0 | 5 votes |
def __init__(self, element, *order_by): r"""Produce a :class:`.WithinGroup` object against a function. Used against so-called "ordered set aggregate" and "hypothetical set aggregate" functions, including :class:`.percentile_cont`, :class:`.rank`, :class:`.dense_rank`, etc. :func:`~.expression.within_group` is usually called using the :meth:`.FunctionElement.within_group` method, e.g.:: from sqlalchemy import within_group stmt = select([ department.c.id, func.percentile_cont(0.5).within_group( department.c.salary.desc() ) ]) The above statement would produce SQL similar to ``SELECT department.id, percentile_cont(0.5) WITHIN GROUP (ORDER BY department.salary DESC)``. :param element: a :class:`.FunctionElement` construct, typically generated by :data:`~.expression.func`. :param \*order_by: one or more column elements that will be used as the ORDER BY clause of the WITHIN GROUP construct. .. versionadded:: 1.1 .. seealso:: :data:`.expression.func` :func:`.expression.over` """ self.element = element if order_by is not None: self.order_by = ClauseList( *util.to_list(order_by), _literal_as_text=_literal_as_label_reference)
Example #12
Source File: elements.py From android_universal with MIT License | 5 votes |
def __init__(self, element, *order_by): r"""Produce a :class:`.WithinGroup` object against a function. Used against so-called "ordered set aggregate" and "hypothetical set aggregate" functions, including :class:`.percentile_cont`, :class:`.rank`, :class:`.dense_rank`, etc. :func:`~.expression.within_group` is usually called using the :meth:`.FunctionElement.within_group` method, e.g.:: from sqlalchemy import within_group stmt = select([ department.c.id, func.percentile_cont(0.5).within_group( department.c.salary.desc() ) ]) The above statement would produce SQL similar to ``SELECT department.id, percentile_cont(0.5) WITHIN GROUP (ORDER BY department.salary DESC)``. :param element: a :class:`.FunctionElement` construct, typically generated by :data:`~.expression.func`. :param \*order_by: one or more column elements that will be used as the ORDER BY clause of the WITHIN GROUP construct. .. versionadded:: 1.1 .. seealso:: :data:`.expression.func` :func:`.expression.over` """ self.element = element if order_by is not None: self.order_by = ClauseList( *util.to_list(order_by), _literal_as_text=_literal_as_label_reference)
Example #13
Source File: test_compiler.py From sqlalchemy with MIT License | 4 votes |
def test_over_within_group(self): from sqlalchemy import within_group stmt = select( [ table1.c.myid, within_group( func.percentile_cont(0.5), table1.c.name.desc() ).over( range_=(1, 2), partition_by=table1.c.name, order_by=table1.c.myid, ), ] ) eq_ignore_whitespace( str(stmt), "SELECT mytable.myid, percentile_cont(:percentile_cont_1) " "WITHIN GROUP (ORDER BY mytable.name DESC) " "OVER (PARTITION BY mytable.name ORDER BY mytable.myid " "RANGE BETWEEN :param_1 FOLLOWING AND :param_2 FOLLOWING) " "AS anon_1 FROM mytable", ) stmt = select( [ table1.c.myid, within_group( func.percentile_cont(0.5), table1.c.name.desc() ).over( rows=(1, 2), partition_by=table1.c.name, order_by=table1.c.myid, ), ] ) eq_ignore_whitespace( str(stmt), "SELECT mytable.myid, percentile_cont(:percentile_cont_1) " "WITHIN GROUP (ORDER BY mytable.name DESC) " "OVER (PARTITION BY mytable.name ORDER BY mytable.myid " "ROWS BETWEEN :param_1 FOLLOWING AND :param_2 FOLLOWING) " "AS anon_1 FROM mytable", )