Skip to content

Commit

Permalink
[Doc] Fix Feedback issue on SHOW MV (#42551)
Browse files Browse the repository at this point in the history
Signed-off-by: 絵空事スピリット <[email protected]>
  • Loading branch information
EsoragotoSpirit authored Mar 13, 2024
1 parent 679b412 commit b19c16a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,92 +36,27 @@ Parameters in brackets [] is optional.
| id | The ID of the materialized view. |
| database_name | The name of the database in which the materialized view resides. |
| name | The name of the materialized view. |
| refresh_type | The refresh type of the materialized view, including ROLLUP, MANUAL, ASYNC, and INCREMENTAL. |
| is_active | Whether the materialized view state is active. Valid Value: `true` and `false`. |
| partition_type | The partition type of the materialized view, including RANGE and UNPARTITIONED. |
| task_id | ID of the materialized view refresh task. |
| task_name | Name of the materialized view refresh task. |
| last_refresh_start_time | The start time of the last refresh of the materialized view. |
| last_refresh_finished_time | The end time of the last refresh of the materialized view. |
| last_refresh_duration | The time taken by the last refresh. Unit: seconds. |
| last_refresh_state | The status of the last refresh, including PENDING, RUNNING, FAILED, and SUCCESS. |
| last_refresh_force_refresh | Whether the last refresh is a FORCE refresh. |
| last_refresh_start_partition | The start partition of the last refresh in the materialized view. |
| last_refresh_end_partition | The end partition of the last refresh in the materialized view. |
| last_refresh_base_refresh_partitions | The base table partitions that were refreshed in the last refresh. |
| last_refresh_mv_refresh_partitions | The materialized view partitions that were refreshed in the last refresh. |
| last_refresh_error_code | The error code for the last failed refresh of the materialized view (if the materialized view state is not active). |
| last_refresh_error_message | The reason why the last refresh failed (if the materialized view state is not active). |
| rows | The number of data rows in the materialized view. |
| text | The statement used to create the materialized view. |

## Examples

Example 1: Show a specific materialized view

```Plain
MySQL > SHOW MATERIALIZED VIEW WHERE NAME = "lo_mv1"\G
*************************** 1. row ***************************
id: 475899
name: lo_mv1
database_name: wlc_test
text: CREATE MATERIALIZED VIEW `lo_mv1`
COMMENT "MATERIALIZED_VIEW"
DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 10
REFRESH ASYNC
PROPERTIES (
"replication_num" = "3",
"storage_medium" = "HDD"
)
AS SELECT `wlc_test`.`lineorder`.`lo_orderkey` AS `lo_orderkey`, `wlc_test`.`lineorder`.`lo_custkey` AS `lo_custkey`, sum(`wlc_test`.`lineorder`.`lo_quantity`) AS `total_quantity`, sum(`wlc_test`.`lineorder`.`lo_revenue`) AS `total_revenue`, count(`wlc_test`.`lineorder`.`lo_shipmode`) AS `shipmode_count` FROM `wlc_test`.`lineorder` GROUP BY `wlc_test`.`lineorder`.`lo_orderkey`, `wlc_test`.`lineorder`.`lo_custkey` ORDER BY `wlc_test`.`lineorder`.`lo_orderkey` ASC ;
rows: 0
1 row in set (0.42 sec)
```

Example 2: Show specific materialized views by matching the name

```Plain
MySQL > SHOW MATERIALIZED VIEW WHERE NAME LIKE "lo_mv%"\G
MySQL > SHOW MATERIALIZED VIEW\G
*************************** 1. row ***************************
id: 475985
name: lo_mv2
database_name: wlc_test
text: CREATE MATERIALIZED VIEW `lo_mv2`
COMMENT "MATERIALIZED_VIEW"
PARTITION BY (`lo_orderdate`)
DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 10
REFRESH ASYNC START("2023-07-01 10:00:00") EVERY(INTERVAL 1 DAY)
PROPERTIES (
"replication_num" = "3",
"storage_medium" = "HDD"
)
AS SELECT `wlc_test`.`lineorder`.`lo_orderkey` AS `lo_orderkey`, `wlc_test`.`lineorder`.`lo_orderdate` AS `lo_orderdate`, `wlc_test`.`lineorder`.`lo_custkey` AS `lo_custkey`, sum(`wlc_test`.`lineorder`.`lo_quantity`) AS `total_quantity`, sum(`wlc_test`.`lineorder`.`lo_revenue`) AS `total_revenue`, count(`wlc_test`.`lineorder`.`lo_shipmode`) AS `shipmode_count` FROM `wlc_test`.`lineorder` GROUP BY `wlc_test`.`lineorder`.`lo_orderkey`, `wlc_test`.`lineorder`.`lo_orderdate`, `wlc_test`.`lineorder`.`lo_custkey` ORDER BY `wlc_test`.`lineorder`.`lo_orderkey` ASC ;
rows: 0
*************************** 2. row ***************************
id: 475899
name: lo_mv1
database_name: wlc_test
text: CREATE MATERIALIZED VIEW `lo_mv1`
COMMENT "MATERIALIZED_VIEW"
DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 10
REFRESH ASYNC
id: 10099
name: order_mv
database_name: test
text: CREATE MATERIALIZED VIEW `order_mv` (`order_id`, `total`)
DISTRIBUTED BY HASH(`order_id`)
REFRESH ASYNC START("2022-09-01 10:00:00") EVERY(INTERVAL 1 DAY)
PROPERTIES (
"replication_num" = "3",
"storage_medium" = "HDD"
)
AS SELECT `wlc_test`.`lineorder`.`lo_orderkey` AS `lo_orderkey`, `wlc_test`.`lineorder`.`lo_custkey` AS `lo_custkey`, sum(`wlc_test`.`lineorder`.`lo_quantity`) AS `total_quantity`, sum(`wlc_test`.`lineorder`.`lo_revenue`) AS `total_revenue`, count(`wlc_test`.`lineorder`.`lo_shipmode`) AS `shipmode_count` FROM `wlc_test`.`lineorder` GROUP BY `wlc_test`.`lineorder`.`lo_orderkey`, `wlc_test`.`lineorder`.`lo_custkey` ORDER BY `wlc_test`.`lineorder`.`lo_orderkey` ASC ;
rows: 0
*************************** 3. row ***************************
id: 477338
name: lo_mv_sync_2
database_name: wlc_test
text: CREATE MATERIALIZED VIEW lo_mv_sync_2 REFRESH SYNC AS select lo_orderkey, lo_orderdate, lo_custkey, sum(lo_quantity) as total_quantity, sum(lo_revenue) as total_revenue, count(lo_shipmode) as shipmode_count from lineorder group by lo_orderkey, lo_orderdate, lo_custkey
rows: 0
*************************** 4. row ***************************
id: 475992
name: lo_mv_sync_1
database_name: wlc_test
text: CREATE MATERIALIZED VIEW lo_mv_sync_1ASselect lo_orderkey, lo_orderdate, lo_custkey, sum(lo_quantity) as total_quantity, sum(lo_revenue) as total_revenue, count(lo_shipmode) as shipmode_countfrom lineorder group by lo_orderkey, lo_orderdate, lo_custkey
rows: 0
4 rows in set (0.04 sec)
AS SELECT `order_list`.`order_id`, sum(`goods`.`price`) AS `total`
FROM `wlc`.`order_list` INNER JOIN `wlc`.`goods` ON `goods`.`item_id1` = `order_list`.`item_id2`
GROUP BY `order_list`.`order_id`;
rows: 3
1 row in set (0.02 sec)
```
Original file line number Diff line number Diff line change
Expand Up @@ -33,138 +33,32 @@ WHERE

## 返回

返回最近一次 REFRESH 任务的状态。

| **返回** | **说明** |
| -------------------------- | --------------------------------------------------------- |
| id | 物化视图 ID。 |
| database_name | 物化视图所属的数据库名称。 |
| name | 物化视图名称。 |
| refresh_type | 物化视图的更新方式,包括 ROLLUP、MANUAL、ASYNC、INCREMENTAL。 |
| is_active | 物化视图状态是否为 active。有效值:`true``false`|
| partition_type | 物化视图的分区类型,包括 RANGE 和 UNPARTITIONED。|
| task_id | 物化视图的刷新任务 ID。 |
| task_name | 物化视图的刷新任务名称。 |
| last_refresh_start_time | 物化视图上一次刷新开始时间。 |
| last_refresh_finished_time | 物化视图上一次刷新结束时间。 |
| last_refresh_duration | 物化视图上一次刷新耗时(单位秒)。 |
| last_refresh_state | 物化视图上一次刷新的状态,包括 PENDING、RUNNING、FAILED、SUCCESS。 |
| last_refresh_force_refresh | 物化视图上一次刷新是否为强制(FORCE)刷新。 |
| last_refresh_start_partition | 上一次刷新开始的物化视图分区。 |
| last_refresh_end_partition | 上一次刷新结束的物化视图分区。 |
| last_refresh_base_refresh_partitions | 上一次刷新基表更新的分区。 |
| last_refresh_mv_refresh_partitions | 上一次刷新物化视图刷新的分区。 |
| last_refresh_error_code | 物化视图上一次刷新失败的 ErrorCode(如果物化视图状态不为 active)。 |
| last_refresh_error_message | 物化视图上一次刷新失败的 ErrorMessage(如果物化视图状态不为 active)。 |
| rows | 物化视图中数据行数。 |
| text | 创建物化视图的查询语句。 |

## 示例

### 示例一:通过精确匹配查看特定物化视图

```Plain
-- Create Table: customer
CREATE TABLE customer ( C_CUSTKEY INTEGER NOT NULL,
C_NAME VARCHAR(25) NOT NULL,
C_ADDRESS VARCHAR(40) NOT NULL,
C_NATIONKEY INTEGER NOT NULL,
C_PHONE CHAR(15) NOT NULL,
C_ACCTBAL double NOT NULL,
C_MKTSEGMENT CHAR(10) NOT NULL,
C_COMMENT VARCHAR(117) NOT NULL,
PAD char(1) NOT NULL)
ENGINE=OLAP
DUPLICATE KEY(`c_custkey`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 10
PROPERTIES (
"replication_num" = "3",
"storage_format" = "DEFAULT"
);
-- Create MV: customer_mv
CREATE MATERIALIZED VIEW customer_mv
DISTRIBUTED BY HASH(c_custkey) buckets 10
REFRESH MANUAL
PROPERTIES (
"replication_num" = "3"
)
AS SELECT
c_custkey, c_phone, c_acctbal, count(1) as c_count, sum(c_acctbal) as c_sum
FROM
customer
GROUP BY c_custkey, c_phone, c_acctbal;
-- Refresh the MV
REFRESH MATERIALIZED VIEW customer_mv;
```

示例一:通过精确匹配查看特定物化视图

```Plain
mysql> show materialized views where name='customer_mv'\G;
mysql> SHOW MATERIALIZED VIEW\G
*************************** 1. row ***************************
id: 475899
name: lo_mv1
database_name: wlc_test
text: CREATE MATERIALIZED VIEW `lo_mv1`
COMMENT "MATERIALIZED_VIEW"
DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 10
REFRESH ASYNC
PROPERTIES (
"replication_num" = "3",
"storage_medium" = "HDD"
)
AS SELECT `wlc_test`.`lineorder`.`lo_orderkey` AS `lo_orderkey`, `wlc_test`.`lineorder`.`lo_custkey` AS `lo_custkey`, sum(`wlc_test`.`lineorder`.`lo_quantity`) AS `total_quantity`, sum(`wlc_test`.`lineorder`.`lo_revenue`) AS `total_revenue`, count(`wlc_test`.`lineorder`.`lo_shipmode`) AS `shipmode_count` FROM `wlc_test`.`lineorder` GROUP BY `wlc_test`.`lineorder`.`lo_orderkey`, `wlc_test`.`lineorder`.`lo_custkey` ORDER BY `wlc_test`.`lineorder`.`lo_orderkey` ASC ;
rows: 0
1 row in set (0.42 sec)
```

### 示例二:通过模糊匹配查看物化视图

```Plain
MySQL > SHOW MATERIALIZED VIEW WHERE NAME LIKE "lo_mv%"\G
*************************** 1. row ***************************
id: 475985
name: lo_mv2
database_name: wlc_test
text: CREATE MATERIALIZED VIEW `lo_mv2`
COMMENT "MATERIALIZED_VIEW"
PARTITION BY (`lo_orderdate`)
DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 10
REFRESH ASYNC START("2023-07-01 10:00:00") EVERY(INTERVAL 1 DAY)
PROPERTIES (
"replication_num" = "3",
"storage_medium" = "HDD"
)
AS SELECT `wlc_test`.`lineorder`.`lo_orderkey` AS `lo_orderkey`, `wlc_test`.`lineorder`.`lo_orderdate` AS `lo_orderdate`, `wlc_test`.`lineorder`.`lo_custkey` AS `lo_custkey`, sum(`wlc_test`.`lineorder`.`lo_quantity`) AS `total_quantity`, sum(`wlc_test`.`lineorder`.`lo_revenue`) AS `total_revenue`, count(`wlc_test`.`lineorder`.`lo_shipmode`) AS `shipmode_count` FROM `wlc_test`.`lineorder` GROUP BY `wlc_test`.`lineorder`.`lo_orderkey`, `wlc_test`.`lineorder`.`lo_orderdate`, `wlc_test`.`lineorder`.`lo_custkey` ORDER BY `wlc_test`.`lineorder`.`lo_orderkey` ASC ;
rows: 0
*************************** 2. row ***************************
id: 475899
name: lo_mv1
database_name: wlc_test
text: CREATE MATERIALIZED VIEW `lo_mv1`
COMMENT "MATERIALIZED_VIEW"
DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 10
REFRESH ASYNC
id: 10099
name: order_mv
database_name: test
text: CREATE MATERIALIZED VIEW `order_mv` (`order_id`, `total`)
DISTRIBUTED BY HASH(`order_id`)
REFRESH ASYNC START("2022-09-01 10:00:00") EVERY(INTERVAL 1 DAY)
PROPERTIES (
"replication_num" = "3",
"storage_medium" = "HDD"
)
AS SELECT `wlc_test`.`lineorder`.`lo_orderkey` AS `lo_orderkey`, `wlc_test`.`lineorder`.`lo_custkey` AS `lo_custkey`, sum(`wlc_test`.`lineorder`.`lo_quantity`) AS `total_quantity`, sum(`wlc_test`.`lineorder`.`lo_revenue`) AS `total_revenue`, count(`wlc_test`.`lineorder`.`lo_shipmode`) AS `shipmode_count` FROM `wlc_test`.`lineorder` GROUP BY `wlc_test`.`lineorder`.`lo_orderkey`, `wlc_test`.`lineorder`.`lo_custkey` ORDER BY `wlc_test`.`lineorder`.`lo_orderkey` ASC ;
rows: 0
*************************** 3. row ***************************
id: 477338
name: lo_mv_sync_2
database_name: wlc_test
text: CREATE MATERIALIZED VIEW lo_mv_sync_2 REFRESH SYNC AS select lo_orderkey, lo_orderdate, lo_custkey, sum(lo_quantity) as total_quantity, sum(lo_revenue) as total_revenue, count(lo_shipmode) as shipmode_count from lineorder group by lo_orderkey, lo_orderdate, lo_custkey
rows: 0
*************************** 4. row ***************************
id: 475992
name: lo_mv_sync_1
database_name: wlc_test
text: CREATE MATERIALIZED VIEW lo_mv_sync_1ASselect lo_orderkey, lo_orderdate, lo_custkey, sum(lo_quantity) as total_quantity, sum(lo_revenue) as total_revenue, count(lo_shipmode) as shipmode_countfrom lineorder group by lo_orderkey, lo_orderdate, lo_custkey
rows: 0
4 rows in set (0.04 sec)
AS SELECT `order_list`.`order_id`, sum(`goods`.`price`) AS `total`
FROM `wlc`.`order_list` INNER JOIN `wlc`.`goods` ON `goods`.`item_id1` = `order_list`.`item_id2`
GROUP BY `order_list`.`order_id`;
rows: 3
1 row in set (0.02 sec)
```

0 comments on commit b19c16a

Please sign in to comment.