Syntax
source_table change record to a column of table_name.
Example
Create MV
Changelog operation
Query MV
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Use the AS CHANGELOG clause to convert a changelog operation in a stream into a column.
WITH table_name AS CHANGELOG FROM source_table;
source_table change record to a column of table_name.
CREATE MATERIALIZED VIEW ss_mv AS
WITH sub AS CHANGELOG FROM user_behaviors
SELECT
user_id,
target_id,
event_timestamp AT TIME ZONE 'America/Indiana/Indianapolis' AS event_timestamp,
changelog_op AS __op,
_changelog_row_id::bigint AS __row_id
FROM
sub;
INSERT INTO user_behaviors (v1, v2) VALUES (1, 1);
INSERT INTO user_behaviors (v1, v2) VALUES (2, 2);
DELETE FROM user_behaviors WHERE v1 = 2;
UPDATE user_behaviors SET v2 = 100 WHERE v1 = 1;
SELECT * FROM ss_mv;
-------RESULT
v1 v2 changelog_op
1 1 1
2 2 1
2 2 2
1 1 4
1 100 3
Was this page helpful?