--
-- Test case: TEMPORAL NORMALIZER
--
drop table r01;
drop table s01;
create table r01(
	a char, 
	b char, 
	ts int, 
	te int
);
create table s01(
	c int, 
	d char, 
	ts int, 
	te int
);
insert into r01 values
('a','B',1,7), 
('b','B',3,9), 
('c','G',8,10);
insert into s01 values
(1,'B',2,5), 
(2,'B',3,4), 
(3,'B',7,9);
-- Temporal normalizer test: equality qualifiers only, simple query...
select * from 
(
	r01 normalize s01 on r01.b=s01.d with (ts,te,ts,te)
) x;
 a | b | ts | te 
---+---+----+----
 a | B |  1 |  2
 a | B |  2 |  3
 a | B |  3 |  4
 a | B |  4 |  5
 a | B |  5 |  7
 b | B |  3 |  4
 b | B |  4 |  5
 b | B |  5 |  7
 b | B |  7 |  9
 c | G |  8 | 10
(10 rows)

-- Temporal aligner test: targetlist of outer query *not* A_STAR... 
select a, count(a) from 
(
	r01 normalize s01 on r01.b=s01.d with (ts,te,ts,te)
) x 
group by a;
 a | count 
---+-------
 c |     1
 b |     4
 a |     5
(3 rows)
select * from (r03 normalize s03 using(a) with (ts,te,ts,te)) x;
 a | ts | te 
---+----+----
 a |  1 |  8
 j |  2 |  6
 a |  8 | 12
(3 rows)

