You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ji...@apache.org on 2018/12/27 00:50:47 UTC

[flink] branch master updated: [FLINK-11142][docs] Point out fields can be projected out for Position-based Mapping

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

jincheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new fcbf91d  [FLINK-11142][docs] Point out fields can be projected out for Position-based Mapping
fcbf91d is described below

commit fcbf91d4b3858500aa939aa3a6299012fed84a29
Author: hequn8128 <ch...@gmail.com>
AuthorDate: Mon Dec 24 11:43:38 2018 +0800

    [FLINK-11142][docs] Point out fields can be projected out for Position-based Mapping
    
    This closes #7352
---
 docs/dev/table/common.md | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/docs/dev/table/common.md b/docs/dev/table/common.md
index 6c7f92b..5d2521f 100644
--- a/docs/dev/table/common.md
+++ b/docs/dev/table/common.md
@@ -800,7 +800,7 @@ The mapping of a data type to a table schema can happen in two ways: **based on
 
 **Position-based Mapping**
 
-Position-based mapping can be used to give fields a more meaningful name while keeping the field order. This mapping is available for composite data types *with a defined field order* as well as atomic types. Composite data types such as tuples, rows, and case classes have such a field order. However, fields of a POJO must be mapped based on the field names (see next section).
+Position-based mapping can be used to give fields a more meaningful name while keeping the field order. This mapping is available for composite data types *with a defined field order* as well as atomic types. Composite data types such as tuples, rows, and case classes have such a field order. However, fields of a POJO must be mapped based on the field names (see next section). Fields can be projected out but can't be renamed using an alias `as`.
 
 When defining a position-based mapping, the specified names must not exist in the input data type, otherwise the API will assume that the mapping should happen based on the field names. If no field names are specified, the default field names and field order of the composite type are used or `f0` for atomic types. 
 
@@ -815,6 +815,9 @@ DataStream<Tuple2<Long, Integer>> stream = ...
 // convert DataStream into Table with default field names "f0" and "f1"
 Table table = tableEnv.fromDataStream(stream);
 
+// convert DataStream into Table with field "myLong" only
+Table table = tableEnv.fromDataStream(stream, "myLong");
+
 // convert DataStream into Table with field names "myLong" and "myInt"
 Table table = tableEnv.fromDataStream(stream, "myLong, myInt");
 {% endhighlight %}
@@ -830,8 +833,11 @@ val stream: DataStream[(Long, Int)] = ...
 // convert DataStream into Table with default field names "_1" and "_2"
 val table: Table = tableEnv.fromDataStream(stream)
 
+// convert DataStream into Table with field "myLong" only
+val table: Table = tableEnv.fromDataStream(stream, 'myLong)
+
 // convert DataStream into Table with field names "myLong" and "myInt"
-val table: Table = tableEnv.fromDataStream(stream, 'myLong 'myInt)
+val table: Table = tableEnv.fromDataStream(stream, 'myLong, 'myInt)
 {% endhighlight %}
 </div>
 </div>