MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_over_within_group

Method test_over_within_group

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

Source from the content-addressed store, hash-verified

3313 )
3314
3315 def test_over_within_group(self):
3316 from sqlalchemy import within_group
3317
3318 stmt = select(
3319 table1.c.myid,
3320 within_group(func.percentile_cont(0.5), table1.c.name.desc()).over(
3321 range_=(1, 2),
3322 partition_by=table1.c.name,
3323 order_by=table1.c.myid,
3324 ),
3325 )
3326 eq_ignore_whitespace(
3327 str(stmt),
3328 "SELECT mytable.myid, percentile_cont(:percentile_cont_1) "
3329 "WITHIN GROUP (ORDER BY mytable.name DESC) "
3330 "OVER (PARTITION BY mytable.name ORDER BY mytable.myid "
3331 "RANGE BETWEEN :param_1 FOLLOWING AND :param_2 FOLLOWING) "
3332 "AS anon_1 FROM mytable",
3333 )
3334
3335 stmt = select(
3336 table1.c.myid,
3337 within_group(func.percentile_cont(0.5), table1.c.name.desc()).over(
3338 rows=(1, 2),
3339 partition_by=table1.c.name,
3340 order_by=table1.c.myid,
3341 ),
3342 )
3343 eq_ignore_whitespace(
3344 str(stmt),
3345 "SELECT mytable.myid, percentile_cont(:percentile_cont_1) "
3346 "WITHIN GROUP (ORDER BY mytable.name DESC) "
3347 "OVER (PARTITION BY mytable.name ORDER BY mytable.myid "
3348 "ROWS BETWEEN :param_1 FOLLOWING AND :param_2 FOLLOWING) "
3349 "AS anon_1 FROM mytable",
3350 )
3351
3352 def test_date_between(self):
3353 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