provsql
provsql copied to clipboard
Feature/fix arithmetic on aggregation failure
This PR fixes an issue where arithmetic expressions involving provsql aggregation results (e.g., SELECT AVG(col) * 10 FROM table) would fail or return empty results.
The provenance_aggregate function returns a custom agg_token type 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 handle agg_token in those expressions.
Changes
-
src/agg_token.c: Implemented C helper functions (
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. - sql/provsql.common.sql: Exposed these fun