@@ -31,3 +31,30 @@ select vit_refresh();
3131select * from vit;
3232select count (* )from vitwhere t= ' min' ::text ;
3333select count (* )from vitwhere i>= ' 1 minute' ::interval;
34+
35+ create table stock (symbolchar (5 ), daydate , lowreal , highreal , openreal , closereal );
36+ insert into stockvalues
37+ (' AAA' ,' 01-11-2018' ,10 .0 ,11 .0 ,10 .1 ,10 .8 ),
38+ (' AAA' ,' 02-11-2018' ,11 .0 ,12 .0 ,11 .2 ,11 .5 ),
39+ (' AAA' ,' 03-11-2018' ,10 .4 ,10 .6 ,10 .5 ,10 .4 ),
40+ (' AAA' ,' 04-11-2018' ,11 .1 ,11 .5 ,11 .2 ,11 .4 ),
41+ (' AAA' ,' 05-11-2018' ,11 .0 ,11 .3 ,11 .4 ,11 .1 );
42+ select create_projection(' vstock' ,' stock' ,array[' day' ,' low' ,' high' ,' open' ,' close' ],array[' symbol' ],' day' );
43+
44+ select vstock_refresh();
45+ select avg ((open+ close)/ 2 ),max (high- low)from stockgroup by day;
46+ set vops .auto_substitute_projections = on ;
47+ explain (costs off)select avg ((open+ close)/ 2 ),max (high- low)from stockgroup by day;
48+ select avg ((open+ close)/ 2 ),max (high- low)from stockgroup by day;
49+
50+ insert into stockvalues
51+ (' AAA' ,' 06-11-2018' ,10 .1 ,10 .8 ,10 .3 ,10 .2 ),
52+ (' AAA' ,' 07-11-2018' ,11 .1 ,11 .8 ,10 .2 ,11 .4 ),
53+ (' AAA' ,' 08-11-2018' ,11 .2 ,11 .6 ,11 .4 ,11 .3 ),
54+ (' AAA' ,' 09-11-2018' ,10 .6 ,11 .1 ,11 .3 ,10 .8 ),
55+ (' AAA' ,' 10-11-2018' ,10 .7 ,11 .3 ,10 .8 ,11 .1 );
56+ select vstock_refresh();
57+
58+ select avg ((open+ close)/ 2 ),max (high- low)from stockgroup by day;
59+ set vops .auto_substitute_projections = off;
60+ select avg ((open+ close)/ 2 ),max (high- low)from stockgroup by day;