Feature/fix arithmetic on aggregation failure#64
Feature/fix arithmetic on aggregation failure#64jeffery1236 wants to merge 2 commits intoPierreSenellart:masterfrom
Conversation
…feature/fix-arithmetic-on-aggregation-failure
|
Thanks! I will review these and integrate them in the next couple of weeks. Note that there are several issues related to maintaining provenance for this kind of queries:
Still, I think that your approach of converting to numbers is appropriate. But I think it would be good to add a warning that provenance information is lost while converting. And it would also be useful to add such a warning when an agg_token is generated for a non-monoid aggregate function, as there won't be much that can be done with the resulting agg_token. Also note that we are currently working on doing useful stuff with these aggregate tokens (for now, ProvSQL can compute them, but does nothing with them). Feel free to reach out if you think your use of ProvSQL would benefit of this. |
|
Will this help with a sum of two aggregate functions ? I wish I could receive in this example the same provenance as for filtering with kind = 1 OR kind = 2. (Yes, I know that I can rewrite this query as |
This PR fixes an issue where arithmetic expressions involving
provsqlaggregation results (e.g.,SELECT AVG(col) * 10 FROM table) would fail or return empty results.The
provenance_aggregatefunction returns a customagg_tokentype to hold both the value and the provenance token. However, this type lacked casts to standard numeric types. As a result, any subsequent operations (like multiplication or division) on the aggregation result would fail because the database did not know how to handleagg_tokenin those expressions.Changes
agg_token_numeric,agg_token_float8,agg_token_int4,agg_token_int8) that extract the value from theagg_tokenstring representation and convert it to the appropriate Postgres type.