Heartbeat_agg does not exist in schema 'public'

I’m trying to set up a heartbeat_agg as per the documentation, however I get the following error:

SQL Error [42883]: ERROR: function heartbeat_agg(timestamp with time zone, timestamp with time zone, interval, interval) does not exist
  Hint: No function matches the given name and argument types. You might need to add explicit type casts.

This is the script I’m running:

CREATE MATERIALIZED VIEW sensor_hourly_heartbeat AS
    time_bucket('1 hour', time) as hour,
    seen_by_sensor_id AS sensor_id,
    heartbeat_agg(time::timestamptz, time_bucket('1 hour', time), INTERVAL '1 hour', INTERVAL '1 minute') AS heartbeat
  FROM ap_seen_record
  GROUP BY seen_by_sensor_id;

From what I can tell, schema public doesn’t have access to this function, only toolkit_experimental:

SELECT n.nspname AS schema,
       p.proname AS function_name,
       pg_get_function_identity_arguments(p.oid) AS function_arguments,
FROM pg_proc p
JOIN pg_namespace n ON p.pronamespace = n.oid
LEFT JOIN pg_description d ON p.oid = d.objoid
WHERE  p.proname = 'heartbeat_agg';

schema              |function_name|function_arguments                                                                                                        |description|
toolkit_experimental|heartbeat_agg|heartbeat timestamp with time zone, agg_start timestamp with time zone, agg_duration interval, heartbeat_liveness interval|           |

How can I add this to ‘public’?

Hi @SsamWise, we have it as an experimental feature and we need more people testing it to guarantee the function is stable.

@smitty do we have any plans to promote it to public?

1 Like

We stabilized heartbeat_agg in Toolkit 1.15, so it will be in the public schema if your Toolkit is new enough.

You can run ALTER EXTENSION timescaledb_toolkit UPDATE; to update your Toolkit extension. (if you aren’t using our managed service, you might need to install the new extension on your database server first)

1 Like

Thanks for the clarification guys.

You may want to consider updating the docs with this info.