IITDBGroup / gprom

GProM is a middleware that adds support for provenance to database backends.
http://www.cs.iit.edu/%7edbgroup/research/gprom.php
Apache License 2.0
8 stars 5 forks source link

Sequenced temporal aggregation without group-by returns 0 instead of NULL #37

Closed lordpretzel closed 6 years ago

lordpretzel commented 6 years ago

For aggregation functions sum/avg/..., the sequenced aggregation without group-by should return NULL for empty snapshots. However, it returns 0 as long as there is a non-empty snapshot that is before the temporal snapshot in temporal order. For instance,

SELECT * 
FROM (SEQUENCED TEMPORAL (
              SELECT sum(salary) AS x 
              FROM ttest WITH TIME (FROM_DATE, TO_DATE))) a 
ORDER BY T_B;
 X     | T_B        | T_E        |
----------------------------------
 NULL  | 4712-01-01 | 1988-09-05 |
 41538 | 1988-09-05 | 1989-09-05 |
 45131 | 1989-09-05 | 1990-09-05 |
 45629 | 1990-09-05 | 1991-09-05 |
 48360 | 1991-09-05 | 1992-09-04 |
 50664 | 1992-09-04 | 1993-09-04 |
 53060 | 1993-09-04 | 1994-09-04 |
 56640 | 1994-09-04 | 1995-09-04 |
 0     | 1995-09-04 | 1998-04-11 |
 53112 | 1998-04-11 | 1999-04-11 |
 53164 | 1999-04-11 | 1999-10-31 |
 0     | 1999-10-31 | 9999-01-01 |
lordpretzel commented 6 years ago

To avoid that we have to maintain a count aggregate no matter what aggregation function is chosen and then set the output to NULL if the count is 0.