6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/functional/tabloid/test_bus_3103_windowed_funcs.py

54 lines
1.2 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-02-04 19:05:19 +01:00
"""
ID: tabloid.bus-3103-windowed-funcs
TITLE: Query for test MAX()OVER().
DESCRIPTION:
FBTEST: functional.tabloid.bus_3103_windowed_funcs
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
db = db_factory(from_backup='tabloid-bus-3103.fbk')
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
with
dx as (
select
t.cid
,p.pid
,hash(src) + hash(tgt) sth
,datediff(minute from dts0 to dts1 + iif(t.dts1 < t.dts0, 1, 0)) dd
from tmove t
left join pmove p on t.id = p.tid
)
,mx as (
select
dx.*,
nullif( abs( max(dd)over() - max(dd)over(partition by cid, sth) ), 1) ns
from dx
)
select
(select name from clist c where c.id = mx.cid) cnm,
count(pid) cnt
from mx
where ns = 0
group by mx.cid
having count(pid) > 0;
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
act = isql_act('db', test_script, substitutions=[('=.*', '')])
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
CNM ba
CNT 13
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-02-04 19:05:19 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout