Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mtmv]show create materialized view #2156

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ Reasons may be:

2. There may be a typographical error in the refresh keywords or a syntax error in the SQL definition of the materialized view. Check the SQL definition and creation statement for the materialized view for correctness.

### Q14: After the materialized view is refreshed successfully, there is still no data

The materialized view determines whether the data needs to be updated based on its ability to retrieve version information from the base table or base table partitions.

When encountering data lakes that currently do not support retrieving version information, such as JDBC Catalog, the refresh process will assume that the materialized view does not need to be updated. Therefore, when creating or refreshing a materialized view, you should specify complete instead of auto.

For the progress of materialized view support for data lakes, please refer to[Data Lake Support Status.](./overview.md)

## Queries and Transparent Rewriting

### Q1: How to confirm if a Materialized View hits, and how to find the reasons for Non-Hits?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ View the materialized view creation statement.

## Syntax



```sql
SHOW CREATE MATERIALIZED VIEW <materialized_view_name>
```
Expand All @@ -42,28 +40,25 @@ SHOW CREATE MATERIALIZED VIEW <materialized_view_name>

> The name of the materialized view.

## Return Values

|Column Name | Description |
| -- |------|
| Materialized View | Name of the materialized view |
| Create Materialized View | Statement used to create the materialized view |

## Access Control Requirements

The user executing this SQL command must have at least the following permissions:

| Privilege | Object | Notes |
| --------- | ------ | ------------------------------------------------------------ |
| SHOW_PRIV | Table | Requires SHOW_PRIV permission on the current materialized view |
| Privilege | Object | Notes |
| --------- | ------ | ----------------------------------------------------------- |
| SELECT_PRIV/LOAD_PRIV/ALTER_PRIV/CREATE_PRIV/DROP_PRIV | Table | |

## Example

1. View the creation statement of an asynchronous materialized view



```sql
SHOW CREATE MATERIALIZED VIEW partition_mv;
```

2. View the creation statement of a synchronized materialized view



```sql
SHOW CREATE MATERIALIZED VIEW sync_agg_mv on lineitem;
```
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ View the materialized view creation statement.

## Syntax



```sql
SHOW CREATE MATERIALIZED VIEW <materialized_view_name> ON <table_name>
```
Expand All @@ -46,28 +44,27 @@ SHOW CREATE MATERIALIZED VIEW <materialized_view_name> ON <table_name>

> The table to which the materialized view belongs.

## Return Values

|Column Name | Description |
| -- |------|
| TableName | Name of the table |
| ViewName | Name of the materialized view |
| CreateStmt | Statement used to create the materialized view |

## Access Control Requirements

The user executing this SQL command must have at least the following permissions:

| Privilege | Object | Notes |
| --------- | ------ | ------------------------------------------------------------ |
| SHOW_PRIV | Table | Requires SHOW_PRIV permission on the current materialized view |
| SELECT_PRIV/LOAD_PRIV/ALTER_PRIV/CREATE_PRIV/DROP_PRIV | Table | You need to have permissions for the table to which the current materialized view belongs |

## Examples

1. View the creation statement of an asynchronous materialized view



```sql
SHOW CREATE MATERIALIZED VIEW partition_mv;
```

2. View the creation statement of a synchronized materialized view


1. View the creation statement of a synchronized materialized view

```sql
SHOW CREATE MATERIALIZED VIEW sync_agg_mv on lineitem;
```
```

Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ BUILD IMMEDIATE REFRESH AUTO ON MANUAL

2. 可能是构建物化的语句使用的 **关键词写错**或者物化定义 **SQL 语法有问题**,可以检查下物化定义 SQL 和创建物化语句是否正确。

### Q14:物化视图刷新成功后,还是没有数据

物化视图判断数据是否需要更新依赖于能够获取到基表或基表分区的版本信息。

遇到目前不支持获取版本信息的数据湖, 例如jdbc catalog, 那么刷新的时候会认为物化视图是不需要更新的,因此创建或者刷新物化视图的时候应该指定 complete 而不是 auto

物化视图支持数据湖的进度参考[数据湖支持情况](./overview.md)

## 查询和透明改写

### Q1:如何确认是否命中,如果不命中如何查看原因?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
{
"title": "SHOW CREATE ASYNC MATERIALIZED VIEW",
"language": "zh-CN"
"title": "SHOW CREATE ASYNC MATERIALIZED VIEW",
"language": "zh-CN"
}
---

Expand All @@ -26,7 +26,7 @@ under the License.

## 描述

查看物化视图创建语句
查看异步物化视图创建语句

## 语法

Expand All @@ -40,24 +40,25 @@ SHOW CREATE MATERIALIZED VIEW <materialized_view_name>

> 物化视图名称

## 返回值

| 列名 | 说明 |
| -- |------|
| Materialized View | 物化视图名 |
| Create Materialized View | 物化视图创建语句 |

## 权限控制

执行此 SQL 命令的用户必须至少具有以下权限:

| 权限(Privilege) | 对象(Object) | 说明(Notes) |
| :---------------- | :------------- | :------------------------------------ |
| SHOW_PRIV | 表(Table) | 需要拥有当前物化视图的 SHOW_PRIV 权限 |
| 权限 | 对象 | 说明 |
| :---------------- | :------------- |:-------------------------------------------------------------|
| SELECT_PRIV/LOAD_PRIV/ALTER_PRIV/CREATE_PRIV/DROP_PRIV | 表 | |

## 示例
## 示例(Examples)

1. 查看异步物化视图创建语句

```sql
SHOW CREATE MATERIALIZED VIEW partition_mv;
```

2. 查看同步物化视图创建语句

```sql
SHOW CREATE MATERIALIZED VIEW sync_agg_mv on lineitem;
```
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ under the License.

## 描述

查看物化视图创建语句
查看同步物化视图创建语句

## 语法

Expand All @@ -44,23 +44,25 @@ SHOW CREATE MATERIALIZED VIEW <materialized_view_name> ON <table_name>

> 物化视图所属的表

## 返回值

| 列名 | 说明 |
| -- |------|
| TableName | 表名 |
| ViewName | 物化视图名 |
| CreateStmt | 物化视图创建语句 |

## 权限控制

执行此 SQL 命令的用户必须至少具有以下权限:

| 权限 | 对象 | 说明 |
| :---------------- | :------------- | :------------------------------------ |
| SHOW_PRIV | 表 | 需要拥有当前物化视图的 SHOW_PRIV 权限 |
| 权限 | 对象 | 说明 |
| :---------------- | :------------- |:--------------------------|
| SELECT_PRIV/LOAD_PRIV/ALTER_PRIV/CREATE_PRIV/DROP_PRIV | 表 | 需要拥有当前物化视图所属表的权限 |

## 示例(Examples)

1. 查看异步物化视图创建语句

```sql
SHOW CREATE MATERIALIZED VIEW partition_mv;
```

2. 查看同步物化视图创建语句
1. 查看同步物化视图创建语句

```sql
SHOW CREATE MATERIALIZED VIEW sync_agg_mv on lineitem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ BUILD IMMEDIATE REFRESH AUTO ON MANUAL

2. 可能是构建物化的语句使用的 **关键词写错**或者物化定义 **SQL 语法有问题**,可以检查下物化定义 SQL 和创建物化语句是否正确。

### Q14:物化视图刷新成功后,还是没有数据

物化视图判断数据是否需要更新依赖于能够获取到基表或基表分区的版本信息。

遇到目前不支持获取版本信息的数据湖, 例如jdbc catalog, 那么刷新的时候会认为物化视图是不需要更新的,因此创建或者刷新物化视图的时候应该指定 complete 而不是 auto

物化视图支持数据湖的进度参考[数据湖支持情况](./overview.md)

## 查询和透明改写

### Q1:如何确认是否命中,如果不命中如何查看原因?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
{
"title": "SHOW CREATE ASYNC MATERIALIZED VIEW",
"language": "zh-CN"
"title": "SHOW CREATE ASYNC MATERIALIZED VIEW",
"language": "zh-CN"
}
---

Expand All @@ -24,10 +24,9 @@ specific language governing permissions and limitations
under the License.
-->


## 描述

查看物化视图创建语句
查看异步物化视图创建语句

## 语法

Expand All @@ -37,28 +36,29 @@ SHOW CREATE MATERIALIZED VIEW <materialized_view_name>

## 必选参数

**1. <materialized_view_new_name>**
**1. `<materialized_view_new_name>`**

> 物化视图名称

## 返回值

| 列名 | 说明 |
| -- |------|
| Materialized View | 物化视图名 |
| Create Materialized View | 物化视图创建语句 |

## 权限控制

执行此 SQL 命令的用户必须至少具有以下权限:

| 权限(Privilege) | 对象(Object) | 说明(Notes) |
| :---------------- | :------------- | :------------------------------------ |
| SHOW_PRIV | 表(Table) | 需要拥有当前物化视图的 SHOW_PRIV 权限 |
| 权限 | 对象 | 说明 |
| :---------------- | :------------- |:-------------------------------------------------------------|
| SELECT_PRIV/LOAD_PRIV/ALTER_PRIV/CREATE_PRIV/DROP_PRIV | 表 | |

## 示例
## 示例(Examples)

1. 查看异步物化视图创建语句

```sql
SHOW CREATE MATERIALIZED VIEW partition_mv;
```

2. 查看同步物化视图创建语句

```sql
SHOW CREATE MATERIALIZED VIEW sync_agg_mv on lineitem;
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
{
"title": "SHOW CREATE SYNC MATERIALIZED VIEW",
"language": "zh-CN"
"title": "SHOW CREATE SYNC MATERIALIZED VIEW",
"language": "zh-CN"
}
---

Expand All @@ -24,10 +24,9 @@ specific language governing permissions and limitations
under the License.
-->


## 描述

查看物化视图创建语句
查看同步物化视图创建语句

## 语法

Expand All @@ -45,23 +44,25 @@ SHOW CREATE MATERIALIZED VIEW <materialized_view_name> ON <table_name>

> 物化视图所属的表

## 返回值

| 列名 | 说明 |
| -- |------|
| TableName | 表名 |
| ViewName | 物化视图名 |
| CreateStmt | 物化视图创建语句 |

## 权限控制

执行此 SQL 命令的用户必须至少具有以下权限:

| 权限 | 对象 | 说明 |
| :---------------- | :------------- | :------------------------------------ |
| SHOW_PRIV | 表 | 需要拥有当前物化视图的 SHOW_PRIV 权限 |
| 权限 | 对象 | 说明 |
| :---------------- | :------------- |:--------------------------|
| SELECT_PRIV/LOAD_PRIV/ALTER_PRIV/CREATE_PRIV/DROP_PRIV | 表 | 需要拥有当前物化视图所属表的权限 |

## 示例(Examples)

1. 查看异步物化视图创建语句

```sql
SHOW CREATE MATERIALIZED VIEW partition_mv;
```

2. 查看同步物化视图创建语句
1. 查看同步物化视图创建语句

```sql
SHOW CREATE MATERIALIZED VIEW sync_agg_mv on lineitem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ BUILD IMMEDIATE REFRESH AUTO ON MANUAL

2. 可能是构建物化的语句使用的 **关键词写错**或者物化定义 **SQL 语法有问题**,可以检查下物化定义 SQL 和创建物化语句是否正确。

### Q14:物化视图刷新成功后,还是没有数据

物化视图判断数据是否需要更新依赖于能够获取到基表或基表分区的版本信息。

遇到目前不支持获取版本信息的数据湖, 例如jdbc catalog, 那么刷新的时候会认为物化视图是不需要更新的,因此创建或者刷新物化视图的时候应该指定 complete 而不是 auto

物化视图支持数据湖的进度参考[数据湖支持情况](./overview.md)

## 查询和透明改写

### Q1:如何确认是否命中,如果不命中如何查看原因?
Expand Down
Loading