provsql icon indicating copy to clipboard operation
provsql copied to clipboard

Feature/fix arithmetic on aggregation failure

Open jeffery1236 opened this issue 1 month ago • 2 comments

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 the agg_token string representation and convert it to the appropriate Postgres type.
  • sql/provsql.common.sql: Exposed these fun

jeffery1236 avatar Dec 04 '25 19:12 jeffery1236