This is an automated email from the ASF dual-hosted git repository.
jark pushed a commit to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.11 by this push:
new 5399e03 [FLINK-17635][docs][table] Add documentation about view
support
5399e03 is described below
commit 5399e0315698778e579dcf6557f14e74e08dcc2e
Author: Leonard Xu <[email protected]>
AuthorDate: Mon Jun 8 19:52:21 2020 +0800
[FLINK-17635][docs][table] Add documentation about view support
This closes #12502
---
docs/dev/table/sql/create.md | 20 ++++++++++++++++++++
docs/dev/table/sql/create.zh.md | 20 ++++++++++++++++++++
docs/dev/table/sql/drop.md | 20 ++++++++++++++++++++
docs/dev/table/sql/drop.zh.md | 20 ++++++++++++++++++++
docs/dev/table/sql/index.md | 4 ++--
docs/dev/table/sql/index.zh.md | 4 ++--
docs/dev/table/sql/queries.md | 22 +++++++++++++++++++++-
docs/dev/table/sql/queries.zh.md | 22 +++++++++++++++++++++-
8 files changed, 126 insertions(+), 6 deletions(-)
diff --git a/docs/dev/table/sql/create.md b/docs/dev/table/sql/create.md
index d3e454d..dc799bb 100644
--- a/docs/dev/table/sql/create.md
+++ b/docs/dev/table/sql/create.md
@@ -31,6 +31,7 @@ Flink SQL supports the following CREATE statements for now:
- CREATE TABLE
- CREATE DATABASE
+- CREATE VIEW
- CREATE FUNCTION
## Run a CREATE statement
@@ -351,6 +352,25 @@ The key and value of expression `key1=val1` should both be
string literal.
{% top %}
+## CREATE VIEW
+{% highlight sql %}
+CREATE [TEMPORARY] VIEW [IF NOT EXISTS] [catalog_name.][db_name.]view_name
+ [{columnName [, columnName ]* }] [COMMENT view_comment]
+ AS query_expression
+{% endhighlight %}
+
+Create a view with the given query expression. If a view with the same name
already exists in the catalog, an exception is thrown.
+
+**TEMPORARY**
+
+Create temporary view that has catalog and database namespaces and overrides
views.
+
+**IF NOT EXISTS**
+
+If the view already exists, nothing happens.
+
+{% top %}
+
## CREATE FUNCTION
{% highlight sql%}
CREATE [TEMPORARY|TEMPORARY SYSTEM] FUNCTION
diff --git a/docs/dev/table/sql/create.zh.md b/docs/dev/table/sql/create.zh.md
index d4f9d79..8348d52 100644
--- a/docs/dev/table/sql/create.zh.md
+++ b/docs/dev/table/sql/create.zh.md
@@ -31,6 +31,7 @@ CREATE 语句用于向当前或指定的 [Catalog]({{ site.baseurl }}/zh/dev/tab
- CREATE TABLE
- CREATE DATABASE
+- CREATE VIEW
- CREATE FUNCTION
## 执行 CREATE 语句
@@ -344,6 +345,25 @@ CREATE DATABASE [IF NOT EXISTS] [catalog_name.]db_name
{% top %}
+## CREATE VIEW
+{% highlight sql %}
+CREATE [TEMPORARY] VIEW [IF NOT EXISTS] [catalog_name.][db_name.]view_name
+ [{columnName [, columnName ]* }] [COMMENT view_comment]
+ AS query_expression
+{% endhighlight %}
+
+根据给定的 query 语句创建一个视图。若数据库中已经存在同名视图会抛出异常.
+
+**TEMPORARY**
+
+创建一个有 catalog 和数据库命名空间的临时视图,并覆盖原有的视图。
+
+**IF NOT EXISTS**
+
+若该视图已经存在,则不会进行任何操作。
+
+{% top %}
+
## CREATE FUNCTION
{% highlight sql%}
CREATE [TEMPORARY|TEMPORARY SYSTEM] FUNCTION
diff --git a/docs/dev/table/sql/drop.md b/docs/dev/table/sql/drop.md
index 6f340e8..bcaea0b 100644
--- a/docs/dev/table/sql/drop.md
+++ b/docs/dev/table/sql/drop.md
@@ -31,6 +31,7 @@ Flink SQL supports the following DROP statements for now:
- DROP TABLE
- DROP DATABASE
+- DROP VIEW
- DROP FUNCTION
## Run a DROP statement
@@ -143,6 +144,25 @@ Dropping a non-empty database triggers an exception.
Enabled by default.
Dropping a non-empty database also drops all associated tables and functions.
+## DROP VIEW
+
+{% highlight sql %}
+DROP [TEMPORARY] VIEW [IF EXISTS] [catalog_name.][db_name.]view_name
+{% endhighlight %}
+
+Drop a view that has catalog and database namespaces. If the view to drop does
not exist, an exception is thrown.
+
+**TEMPORARY**
+
+Drop temporary view that has catalog and database namespaces.
+
+**IF EXISTS**
+
+If the view does not exist, nothing happens.
+
+**MAINTAIN DEPENDENCIES**
+Flink does not maintain dependencies of view by CASCADE/RESTRICT keywords, the
current way is producing postpone error message when user tries to use the view
under the scenarios like the underlying table of view has been dropped.
+
## DROP FUNCTION
{% highlight sql%}
diff --git a/docs/dev/table/sql/drop.zh.md b/docs/dev/table/sql/drop.zh.md
index 51ac456..8d1b76d 100644
--- a/docs/dev/table/sql/drop.zh.md
+++ b/docs/dev/table/sql/drop.zh.md
@@ -31,6 +31,7 @@ Flink SQL 目前支持以下 DROP 语句:
- DROP TABLE
- DROP DATABASE
+- DROP VIEW
- DROP FUNCTION
## 执行 DROP 语句
@@ -143,6 +144,25 @@ DROP DATABASE [IF EXISTS] [catalog_name.]db_name [
(RESTRICT | CASCADE) ]
删除一个非空数据库时,把相关联的表与函数一并删除。
+## DROP VIEW
+
+{% highlight sql %}
+DROP [TEMPORARY] VIEW [IF EXISTS] [catalog_name.][db_name.]view_name
+{% endhighlight %}
+
+删除一个有 catalog 和数据库命名空间的视图。若需要删除的视图不存在,则会产生异常。
+
+**TEMPORARY**
+
+删除一个有 catalog 和数据库命名空间的临时视图。
+
+**IF EXISTS**
+
+若视图不存在,则不会进行任何操作。
+
+**依赖管理**
+Flink 没有使用 CASCADE / RESTRICT
关键字来维护视图的依赖关系,当前的方案是在用户使用视图时再提示错误信息,比如在视图的底层表已经被删除等场景。
+
## DROP FUNCTION
{% highlight sql%}
diff --git a/docs/dev/table/sql/index.md b/docs/dev/table/sql/index.md
index 42a1f2a..73076e8 100644
--- a/docs/dev/table/sql/index.md
+++ b/docs/dev/table/sql/index.md
@@ -29,8 +29,8 @@ This page describes the SQL language supported in Flink,
including Data Definiti
This page lists all the supported statements supported in Flink SQL for now:
- [SELECT (Queries)](queries.html)
-- [CREATE TABLE, DATABASE, FUNCTION](create.html)
-- [DROP TABLE, DATABASE, FUNCTION](drop.html)
+- [CREATE TABLE, DATABASE, VIEW, FUNCTION](create.html)
+- [DROP TABLE, DATABASE, VIEW, FUNCTION](drop.html)
- [ALTER TABLE, DATABASE, FUNCTION](alter.html)
- [INSERT](insert.html)
- [SQL HINTS](hints.html)
diff --git a/docs/dev/table/sql/index.zh.md b/docs/dev/table/sql/index.zh.md
index 3f7b49f..b93f4ff 100644
--- a/docs/dev/table/sql/index.zh.md
+++ b/docs/dev/table/sql/index.zh.md
@@ -29,8 +29,8 @@ under the License.
本页面列出了目前 Flink SQL 所支持的所有语句:
- [SELECT (查询)](queries.html)
-- [CREATE TABLE, DATABASE, FUNCTION](create.html)
-- [DROP TABLE, DATABASE, FUNCTION](drop.html)
+- [CREATE TABLE, DATABASE, VIEW, FUNCTION](create.html)
+- [DROP TABLE, DATABASE, VIEW, FUNCTION](drop.html)
- [ALTER TABLE, DATABASE, FUNCTION](alter.html)
- [INSERT](insert.html)
- [SQL HINTS](hints.html)
diff --git a/docs/dev/table/sql/queries.md b/docs/dev/table/sql/queries.md
index 643ad8c..add05e8 100644
--- a/docs/dev/table/sql/queries.md
+++ b/docs/dev/table/sql/queries.md
@@ -294,7 +294,7 @@ String literals must be enclosed in single quotes (e.g.,
`SELECT 'Hello World'`)
## Operations
-### Show and Use
+### Show, Describe, and Use
<div markdown="1">
<table class="table table-bordered">
@@ -323,10 +323,30 @@ SHOW DATABASES;
{% highlight sql %}
SHOW TABLES;
{% endhighlight %}
+ <p>Show all views in the current database in the current catalog</p>
+{% highlight sql %}
+SHOW VIEWS;
+{% endhighlight %}
</td>
</tr>
<tr>
<td>
+ <strong>Describe</strong><br>
+ <span class="label label-primary">Batch</span> <span class="label
label-primary">Streaming</span>
+ </td>
+ <td>
+ <p>Describe the schema of the given table.</p>
+{% highlight sql %}
+DESCRIBE myTable;
+{% endhighlight %}
+ <p>Describe the schema of the given view.</p>
+{% highlight sql %}
+DESCRIBE myView;
+{% endhighlight %}
+ </td>
+ </tr>
+ <tr>
+ <td>
<strong>Use</strong><br>
<span class="label label-primary">Batch</span> <span class="label
label-primary">Streaming</span>
</td>
diff --git a/docs/dev/table/sql/queries.zh.md b/docs/dev/table/sql/queries.zh.md
index d6b6cff..e4e5d69 100644
--- a/docs/dev/table/sql/queries.zh.md
+++ b/docs/dev/table/sql/queries.zh.md
@@ -294,7 +294,7 @@ Flink SQL 对于标识符(表、属性、函数名)有类似于 Java 的词
## 操作符
-### Show 与 Use
+### Show, Describe 与 Use
<div markdown="1">
<table class="table table-bordered">
@@ -323,10 +323,30 @@ SHOW DATABASES;
{% highlight sql %}
SHOW TABLES;
{% endhighlight %}
+ <p>显示当前数据库、Catalog中的所有视图</p>
+{% highlight sql %}
+SHOW VIEWS;
+{% endhighlight %}
</td>
</tr>
<tr>
<td>
+ <strong>Describe</strong><br>
+ <span class="label label-primary">批处理</span> <span class="label
label-primary">流处理</span>
+ </td>
+ <td>
+ <p>描述给定表的 Schema</p>
+{% highlight sql %}
+DESCRIBE myTable;
+{% endhighlight %}
+ <p>描述给定视图的 Schema</p>
+{% highlight sql %}
+DESCRIBE myView;
+{% endhighlight %}
+ </td>
+ </tr>
+ <tr>
+ <td>
<strong>Use</strong><br>
<span class="label label-primary">批处理</span> <span class="label
label-primary">流处理</span>
</td>