From 40c4abf3b693e6bd75b93b44c74da8331bdb4d54 Mon Sep 17 00:00:00 2001 From: Eric Fu Date: Thu, 11 Apr 2024 12:07:54 +0800 Subject: [PATCH 1/2] resolve #16070 --- e2e_test/ddl/show.slt | 12 ++++++------ .../system_catalog/pg_catalog/pg_matviews.rs | 19 +++++++------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/e2e_test/ddl/show.slt b/e2e_test/ddl/show.slt index 56e4868843a6a..f2bd63b4e3768 100644 --- a/e2e_test/ddl/show.slt +++ b/e2e_test/ddl/show.slt @@ -199,10 +199,10 @@ describe pg_matviews; schemaname character varying false NULL matviewname character varying false NULL matviewowner integer false NULL +tablespace character varying false NULL +hasindexes boolean false NULL +ispopulated boolean false NULL definition character varying false NULL -matviewid integer false NULL -matviewtimezone character varying false NULL -matviewgraph character varying false NULL table description pg_matviews NULL NULL query TTTT @@ -211,7 +211,7 @@ show columns from pg_catalog.pg_matviews; schemaname character varying false NULL matviewname character varying false NULL matviewowner integer false NULL +tablespace character varying false NULL +hasindexes boolean false NULL +ispopulated boolean false NULL definition character varying false NULL -matviewid integer false NULL -matviewtimezone character varying false NULL -matviewgraph character varying false NULL diff --git a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_matviews.rs b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_matviews.rs index f214ac756b667..2e8a9c5af7e77 100644 --- a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_matviews.rs +++ b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_matviews.rs @@ -24,10 +24,10 @@ use risingwave_frontend_macro::system_catalog; "SELECT schemaname, i.relationname AS matviewname, i.relationowner AS matviewowner, - definition, - i.relationid AS matviewid, - i.relationtimezone AS matviewtimezone, - i.fragments AS matviewgraph + NULL AS tablespace, + false AS hasindexes, + true AS ispopulated, + definition FROM rw_catalog.rw_relation_info i WHERE i.relationtype = 'MATERIALIZED VIEW'" )] @@ -36,13 +36,8 @@ struct PgMatview { schemaname: String, matviewname: String, matviewowner: i32, + tablespace: Option, + hasindexes: bool, + ispopulated: bool, definition: String, - // Below are some columns that PostgreSQL doesn't have. - // TODO: these field is only exist in RW and used by cloud side, need to remove it and let - // cloud switch to use `rw_catalog.rw_relation_info`. - matviewid: i32, - // The timezone used to interpret ambiguous dates/timestamps as tstz - matviewtimezone: String, - // materialized view graph is json encoded fragment infos. - matviewgraph: String, } From f3237c526c159f5b5adb2532f3314aa27615c35f Mon Sep 17 00:00:00 2001 From: Eric Fu Date: Thu, 11 Apr 2024 13:27:26 +0800 Subject: [PATCH 2/2] use rw_materialized_views and rw_schemas instead --- .../system_catalog/pg_catalog/pg_matviews.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_matviews.rs b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_matviews.rs index 2e8a9c5af7e77..c0b6afbf954d9 100644 --- a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_matviews.rs +++ b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_matviews.rs @@ -21,15 +21,16 @@ use risingwave_frontend_macro::system_catalog; #[system_catalog( view, "pg_catalog.pg_matviews", - "SELECT schemaname, - i.relationname AS matviewname, - i.relationowner AS matviewowner, - NULL AS tablespace, - false AS hasindexes, - true AS ispopulated, - definition - FROM rw_catalog.rw_relation_info i - WHERE i.relationtype = 'MATERIALIZED VIEW'" + "SELECT + s.name as schemaname, + mv.name as matviewname, + mv.owner as matviewowner, + NULL AS tablespace, + false AS hasindexes, + true AS ispopulated, + mv.definition as definition + FROM rw_materialized_views mv + JOIN rw_schemas s ON mv.schema_id = s.id" )] #[derive(Fields)] struct PgMatview {