当前位置: 首页>>代码示例>>Python>>正文


Python func.percentile_cont方法代码示例

本文整理汇总了Python中sqlalchemy.func.percentile_cont方法的典型用法代码示例。如果您正苦于以下问题:Python func.percentile_cont方法的具体用法?Python func.percentile_cont怎么用?Python func.percentile_cont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy.func的用法示例。


在下文中一共展示了func.percentile_cont方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_funcfilter_within_group_multi

# 需要导入模块: from sqlalchemy import func [as 别名]
# 或者: from sqlalchemy.func import percentile_cont [as 别名]
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},
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_functions.py

示例2: test_funcfilter_within_group_w_over

# 需要导入模块: from sqlalchemy import func [as 别名]
# 或者: from sqlalchemy.func import percentile_cont [as 别名]
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},
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_functions.py

示例3: __init__

# 需要导入模块: from sqlalchemy import func [as 别名]
# 或者: from sqlalchemy.func import percentile_cont [as 别名]
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) 
开发者ID:yfauser,项目名称:planespotter,代码行数:43,代码来源:elements.py

示例4: __init__

# 需要导入模块: from sqlalchemy import func [as 别名]
# 或者: from sqlalchemy.func import percentile_cont [as 别名]
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
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:43,代码来源:elements.py

示例5: test_funcfilter_within_group

# 需要导入模块: from sqlalchemy import func [as 别名]
# 或者: from sqlalchemy.func import percentile_cont [as 别名]
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},
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:17,代码来源:test_functions.py

示例6: test_funcfilter_within_group_desc

# 需要导入模块: from sqlalchemy import func [as 别名]
# 或者: from sqlalchemy.func import percentile_cont [as 别名]
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},
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:17,代码来源:test_functions.py

示例7: test_percentile_cont_array

# 需要导入模块: from sqlalchemy import func [as 别名]
# 或者: from sqlalchemy.func import percentile_cont [as 别名]
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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:8,代码来源:test_functions.py

示例8: test_percentile_cont_array_desc

# 需要导入模块: from sqlalchemy import func [as 别名]
# 或者: from sqlalchemy.func import percentile_cont [as 别名]
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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:8,代码来源:test_functions.py

示例9: test_within_group

# 需要导入模块: from sqlalchemy import func [as 别名]
# 或者: from sqlalchemy.func import percentile_cont [as 别名]
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",
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:17,代码来源:test_compiler.py

示例10: test_over_within_group

# 需要导入模块: from sqlalchemy import func [as 别名]
# 或者: from sqlalchemy.func import percentile_cont [as 别名]
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",
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:46,代码来源:test_compiler.py


注:本文中的sqlalchemy.func.percentile_cont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。