You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ja...@apache.org on 2020/06/20 02:47:14 UTC

[flink] branch release-1.11 updated (2cfaff8 -> b433a28)

This is an automated email from the ASF dual-hosted git repository.

jark pushed a change to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git.


    from 2cfaff8  [FLINK-18119][table-blink] Expire state automatically and accurately for time range bounded over aggregation
     new 68428f8  [FLINK-18254][docs][table] Add documentation for primary key syntax
     new b433a28  [hotfix][docs-zh] Translate navigation title into Chinese

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/concepts/flink-architecture.zh.md           |  2 +-
 docs/concepts/stateful-stream-processing.zh.md   |  4 ++--
 docs/concepts/timely-stream-processing.zh.md     |  4 ++--
 docs/dev/table/sql/create.md                     | 27 +++++++++++++++++++++++-
 docs/dev/table/sql/create.zh.md                  | 25 +++++++++++++++++++++-
 docs/learn-flink/etl.zh.md                       |  4 ++--
 docs/learn-flink/fault_tolerance.zh.md           |  4 ++--
 docs/learn-flink/streaming_analytics.zh.md       |  4 ++--
 docs/try-flink/datastream_api.zh.md              |  4 ++--
 docs/try-flink/flink-operations-playground.zh.md |  4 ++--
 docs/try-flink/table_api.zh.md                   |  4 ++--
 11 files changed, 67 insertions(+), 19 deletions(-)


[flink] 01/02: [FLINK-18254][docs][table] Add documentation for primary key syntax

Posted by ja...@apache.org.
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

commit 68428f8e9f23770e83dd9a9d369f76b272ee76f8
Author: yuzhao.cyz <yu...@gmail.com>
AuthorDate: Fri Jun 19 15:04:58 2020 +0800

    [FLINK-18254][docs][table] Add documentation for primary key syntax
    
    This closes #12713
---
 docs/dev/table/sql/create.md    | 27 ++++++++++++++++++++++++++-
 docs/dev/table/sql/create.zh.md | 25 ++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/docs/dev/table/sql/create.md b/docs/dev/table/sql/create.md
index b48aa44..00eb2ca 100644
--- a/docs/dev/table/sql/create.md
+++ b/docs/dev/table/sql/create.md
@@ -127,6 +127,7 @@ CREATE TABLE [catalog_name.][db_name.]table_name
   (
     { <column_definition> | <computed_column_definition> }[ , ...n]
     [ <watermark_definition> ]
+    [ <table_constraint> ][ , ...n]
   )
   [COMMENT table_comment]
   [PARTITIONED BY (partition_column_name1, partition_column_name2, ...)]
@@ -134,7 +135,13 @@ CREATE TABLE [catalog_name.][db_name.]table_name
   [ LIKE source_table [( <like_options> )] ]
    
 <column_definition>:
-  column_name column_type [COMMENT column_comment]
+  column_name column_type [ <column_constraint> ] [COMMENT column_comment]
+  
+<column_constraint>:
+  [CONSTRAINT constraint_name] PRIMARY KEY NOT ENFORCED
+
+<table_constraint>:
+  [CONSTRAINT constraint_name] PRIMARY KEY (column_name, ...) NOT ENFORCED
 
 <computed_column_definition>:
   column_name AS computed_column_expression [COMMENT column_comment]
@@ -202,6 +209,24 @@ CREATE TABLE Orders (
 ) WITH ( . . . );
 {% endhighlight %}
 
+**PRIMARY KEY**
+
+Primary key constraint is a hint for Flink to leverage for optimizations. It tells that a column or a set of columns of a table or a view are unique and they **do not** contain null.
+Neither of columns in a primary can be nullable. Primary key therefore uniquely identify a row in a table.
+
+Primary key constraint can be either declared along with a column definition (a column constraint) or as a single line (a table constraint).
+For both cases, it should only be declared as a singleton. If you define multiple primary key constraints at the same time, an exception would be thrown.
+
+##### Validity Check
+
+SQL standard specifies that a constraint can either be `ENFORCED` or `NOT ENFORCED`. This controls if the constraint checks are performed on the incoming/outgoing data.
+Flink does not own the data therefore the only mode we want to support is the `NOT ENFORCED` mode.
+It is up to the user to ensure that the query enforces key integrity.
+
+Flink will assume correctness of the primary key by assuming that the columns nullability is aligned with the columns in primary key. Connectors should ensure those are aligned.
+
+**Notes:** In a CREATE TABLE statement, creating a primary key constraint will alter the columns nullability, that means, a column with primary key constraint is not nullable.
+
 **PARTITIONED BY**
 
 Partition the created table by the specified columns. A directory is created for each partition if this table is used as a filesystem sink.
diff --git a/docs/dev/table/sql/create.zh.md b/docs/dev/table/sql/create.zh.md
index a640689..34c9bc8 100644
--- a/docs/dev/table/sql/create.zh.md
+++ b/docs/dev/table/sql/create.zh.md
@@ -127,6 +127,7 @@ CREATE TABLE [catalog_name.][db_name.]table_name
   (
     { <column_definition> | <computed_column_definition> }[ , ...n]
     [ <watermark_definition> ]
+    [ <table_constraint> ][ , ...n]
   )
   [COMMENT table_comment]
   [PARTITIONED BY (partition_column_name1, partition_column_name2, ...)]
@@ -134,7 +135,13 @@ CREATE TABLE [catalog_name.][db_name.]table_name
   [ LIKE source_table [( <like_options> )] ]
 
 <column_definition>:
-  column_name column_type [COMMENT column_comment]
+  column_name column_type [ <column_constraint> ] [COMMENT column_comment]
+
+<column_constraint>:
+  [CONSTRAINT constraint_name] PRIMARY KEY NOT ENFORCED
+
+<table_constraint>:
+  [CONSTRAINT constraint_name] PRIMARY KEY (column_name, ...) NOT ENFORCED
 
 <computed_column_definition>:
   column_name AS computed_column_expression [COMMENT column_comment]
@@ -202,6 +209,22 @@ CREATE TABLE Orders (
 ) WITH ( . . . );
 {% endhighlight %}
 
+
+**PRIMARY KEY**
+
+主键用作 Flink 优化的一种提示信息。主键限制表明一张表或视图的某个(些)列是唯一的并且不包含 Null 值。
+主键声明的列都是非 nullable 的。因此主键可以被用作表行级别的唯一标识。
+
+主键可以和列的定义一起声明,也可以独立声明为表的限制属性,不管是哪种方式,主键都不可以重复定义,否则 Flink 会报错。
+
+##### 有效性检查
+
+SQL 标准主键限制可以有两种模式:`ENFORCED` 或者 `NOT ENFORCED`。 它申明了是否输入/出数据会做合法性检查(是否唯一)。Flink 不存储数据因此只支持 `NOT ENFORCED` 模式,即不做检查,用户需要自己保证唯一性。
+
+Flink 假设声明了主键的列都是不包含 Null 值的,Connector 在处理数据时需要自己保证语义正确。
+
+**Notes:** 在 CREATE TABLE 语句中,创建主键会修改列的 nullable 属性,主键声明的列默认都是非 Nullable 的。
+
 **PARTITIONED BY**
 
 根据指定的列对已经创建的表进行分区。若表使用 filesystem sink ,则将会为每个分区创建一个目录。


[flink] 02/02: [hotfix][docs-zh] Translate navigation title into Chinese

Posted by ja...@apache.org.
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

commit b433a2841bb17b5b149da50a0bd3f3a55f642996
Author: Jark Wu <ja...@apache.org>
AuthorDate: Sat Jun 20 10:32:48 2020 +0800

    [hotfix][docs-zh] Translate navigation title into Chinese
---
 docs/concepts/flink-architecture.zh.md           | 2 +-
 docs/concepts/stateful-stream-processing.zh.md   | 4 ++--
 docs/concepts/timely-stream-processing.zh.md     | 4 ++--
 docs/learn-flink/etl.zh.md                       | 4 ++--
 docs/learn-flink/fault_tolerance.zh.md           | 4 ++--
 docs/learn-flink/streaming_analytics.zh.md       | 4 ++--
 docs/try-flink/datastream_api.zh.md              | 4 ++--
 docs/try-flink/flink-operations-playground.zh.md | 4 ++--
 docs/try-flink/table_api.zh.md                   | 4 ++--
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/docs/concepts/flink-architecture.zh.md b/docs/concepts/flink-architecture.zh.md
index 0855042..d199889 100644
--- a/docs/concepts/flink-architecture.zh.md
+++ b/docs/concepts/flink-architecture.zh.md
@@ -2,7 +2,7 @@
 title: Flink 架构
 nav-id: flink-architecture
 nav-pos: 4
-nav-title: Flink Architecture
+nav-title: Flink 架构
 nav-parent_id: concepts
 ---
 <!--
diff --git a/docs/concepts/stateful-stream-processing.zh.md b/docs/concepts/stateful-stream-processing.zh.md
index d991e83..29ea1f1 100644
--- a/docs/concepts/stateful-stream-processing.zh.md
+++ b/docs/concepts/stateful-stream-processing.zh.md
@@ -1,8 +1,8 @@
 ---
-title: Stateful Stream Processing
+title: 有状态流处理
 nav-id: stateful-stream-processing
 nav-pos: 2
-nav-title: Stateful Stream Processing
+nav-title: 有状态流处理
 nav-parent_id: concepts
 ---
 <!--
diff --git a/docs/concepts/timely-stream-processing.zh.md b/docs/concepts/timely-stream-processing.zh.md
index 38bab79..8cf20e0 100644
--- a/docs/concepts/timely-stream-processing.zh.md
+++ b/docs/concepts/timely-stream-processing.zh.md
@@ -1,8 +1,8 @@
 ---
-title: Timely Stream Processing
+title: 及时流处理
 nav-id: timely-stream-processing
 nav-pos: 3
-nav-title: Timely Stream Processing
+nav-title: 及时流处理
 nav-parent_id: concepts
 ---
 <!--
diff --git a/docs/learn-flink/etl.zh.md b/docs/learn-flink/etl.zh.md
index 667f2f0..881d0af 100644
--- a/docs/learn-flink/etl.zh.md
+++ b/docs/learn-flink/etl.zh.md
@@ -1,8 +1,8 @@
 ---
-title: Data Pipelines & ETL
+title: 数据管道 & ETL
 nav-id: etl
 nav-pos: 3
-nav-title: Data Pipelines & ETL
+nav-title: 数据管道 & ETL
 nav-parent_id: learn-flink
 ---
 <!--
diff --git a/docs/learn-flink/fault_tolerance.zh.md b/docs/learn-flink/fault_tolerance.zh.md
index 189026a..98c5fa8 100644
--- a/docs/learn-flink/fault_tolerance.zh.md
+++ b/docs/learn-flink/fault_tolerance.zh.md
@@ -1,8 +1,8 @@
 ---
-title: Fault Tolerance via State Snapshots
+title: 通过状态快照实现容错处理
 nav-id: fault-tolerance
 nav-pos: 6
-nav-title: Fault Tolerance
+nav-title: 容错处理
 nav-parent_id: learn-flink
 ---
 <!--
diff --git a/docs/learn-flink/streaming_analytics.zh.md b/docs/learn-flink/streaming_analytics.zh.md
index 65fbe43..21541cf 100644
--- a/docs/learn-flink/streaming_analytics.zh.md
+++ b/docs/learn-flink/streaming_analytics.zh.md
@@ -1,8 +1,8 @@
 ---
-title: Streaming Analytics
+title: 流式分析
 nav-id: analytics
 nav-pos: 4
-nav-title: Streaming Analytics
+nav-title: 流式分析
 nav-parent_id: learn-flink
 ---
 <!--
diff --git a/docs/try-flink/datastream_api.zh.md b/docs/try-flink/datastream_api.zh.md
index e28cc5d..1e00af0 100644
--- a/docs/try-flink/datastream_api.zh.md
+++ b/docs/try-flink/datastream_api.zh.md
@@ -1,6 +1,6 @@
 ---
-title: "Fraud Detection with the DataStream API"
-nav-title: 'Fraud Detection with the DataStream API'
+title: "基于 DataStream API 实现欺诈检测"
+nav-title: '基于 DataStream API 实现欺诈检测'
 nav-parent_id: try-flink
 nav-pos: 1
 ---
diff --git a/docs/try-flink/flink-operations-playground.zh.md b/docs/try-flink/flink-operations-playground.zh.md
index ebcbe02..083fb84 100644
--- a/docs/try-flink/flink-operations-playground.zh.md
+++ b/docs/try-flink/flink-operations-playground.zh.md
@@ -1,6 +1,6 @@
 ---
-title: "Flink Operations Playground"
-nav-title: 'Flink Operations Playground'
+title: "Flink 运维操场"
+nav-title: 'Flink 运维操场'
 nav-parent_id: try-flink
 nav-pos: 4
 ---
diff --git a/docs/try-flink/table_api.zh.md b/docs/try-flink/table_api.zh.md
index 530ec1a..3fc3e13 100644
--- a/docs/try-flink/table_api.zh.md
+++ b/docs/try-flink/table_api.zh.md
@@ -1,6 +1,6 @@
 ---
-title: "Real Time Reporting with the Table API"
-nav-title: 'Real Time Reporting with the Table API'
+title: "基于 Table API 实现实时报表"
+nav-title: '基于 Table API 实现实时报表'
 nav-parent_id: try-flink
 nav-pos: 2
 ---