Continuous Aggregation Error: CTEs, subqueries and set-returning functions are not supported by continuous aggregates

CREATE MATERIALIZED VIEW current_aggregate_view
WITH
	(timescaledb.continuous) AS
SELECT
	time_bucket (INTERVAL '1 hour', time_slot) AS time_slot,
	(
		SELECT
			COALESCE(JSONB_OBJECT_AGG(A, COUNT), '{}'::jsonb)
		FROM
			(
				SELECT
					A,
					COUNT(DISTINCT C) AS COUNT
				FROM
					another_aggregate_view
				GROUP BY
					A,
					B
			) AS A_kv
	) AS A
FROM
	another_aggregate_view
GROUP BY
	1,
	D,
	E
WITH
	no data;

Hi all,

I met error here:

ERROR:  CTEs, subqueries and set-returning functions are not supported by continuous aggregates.invalid continuous aggregate query 

ERROR:  invalid continuous aggregate query
SQL state: 0A000
Detail: CTEs, subqueries and set-returning functions are not supported by continuous aggregates.

Any suggestions?

Can you share a bit more of what type of data you’re trying to build?

You may not need to over complicate with this recursive queries.

Can the K and V be columns of your data?

I think you can also check this blog post: Adapting JSON Structures for Real-Time Aggregates in Postgres