MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_over_within_group

Method test_over_within_group

test/sql/test_compiler.py:3520–3555  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3518 )
3519
3520 def test_over_within_group(self):
3521 from sqlalchemy import within_group
3522
3523 stmt = select(
3524 table1.c.myid,
3525 within_group(func.percentile_cont(0.5), table1.c.name.desc()).over(
3526 range_=(1, 2),
3527 partition_by=table1.c.name,
3528 order_by=table1.c.myid,
3529 ),
3530 )
3531 eq_ignore_whitespace(
3532 str(stmt),
3533 "SELECT mytable.myid, percentile_cont(:percentile_cont_1) "
3534 "WITHIN GROUP (ORDER BY mytable.name DESC) "
3535 "OVER (PARTITION BY mytable.name ORDER BY mytable.myid "
3536 "RANGE BETWEEN :param_1 FOLLOWING AND :param_2 FOLLOWING) "
3537 "AS anon_1 FROM mytable",
3538 )
3539
3540 stmt = select(
3541 table1.c.myid,
3542 within_group(func.percentile_cont(0.5), table1.c.name.desc()).over(
3543 rows=(1, 2),
3544 partition_by=table1.c.name,
3545 order_by=table1.c.myid,
3546 ),
3547 )
3548 eq_ignore_whitespace(
3549 str(stmt),
3550 "SELECT mytable.myid, percentile_cont(:percentile_cont_1) "
3551 "WITHIN GROUP (ORDER BY mytable.name DESC) "
3552 "OVER (PARTITION BY mytable.name ORDER BY mytable.myid "
3553 "ROWS BETWEEN :param_1 FOLLOWING AND :param_2 FOLLOWING) "
3554 "AS anon_1 FROM mytable",
3555 )
3556
3557 def test_date_between(self):
3558 import datetime

Callers

nothing calls this directly

Calls 6

selectFunction · 0.90
within_groupFunction · 0.90
eq_ignore_whitespaceFunction · 0.90
percentile_contMethod · 0.80
overMethod · 0.45
descMethod · 0.45

Tested by

no test coverage detected