Missing FROM-clause in RETURN QUERY EXECUTE FORMAT loop This query works fine, but I need to execute it for multiple tables:
select 'service:dms_fdo_query:joined' as metric_name, hypertable_size('prom_data.&quot;service:dms_fdo_query:joined&quot;') as raw_size 

I wrote this function:
CREATE OR REPLACE FUNCTION public.get_metric_sizes()
  RETURNS TABLE(metric_name text, raw_size bigint) AS
$func$
DECLARE
   metric_table name;
BEGIN
   FOR metric_table IN SELECT table_name FROM prom_info.metric
   loop
    RETURN QUERY EXECUTE FORMAT('SELECT %L as metric_name, hypertable_size(prom_data.%I) as raw_size', metric_table, metric_table);
   END LOOP;
END
$func$  LANGUAGE plpgsql;

but I am getting this error:
SQL Error [42P01]: ERROR: missing FROM-clause entry for table &quot;prom_data&quot;
  Where: PL/pgSQL function get_metric_sizes() line 7 at RETURN QUERY

I have really no idea how to fix this, any suggestion would be greatly appreciated!
It turns out that I simply needed to quote the table name passed to the function:
RETURN QUERY EXECUTE FORMAT('SELECT %L as metric_name, hypertable_size(''prom_data.%I'') as raw_size', metric_table, metric_table);