This is an automated email from the ASF dual-hosted git repository. dwysakowicz 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 ffcad1a [FLINK-17931] Document fromValues clause in Table API ffcad1a is described below commit ffcad1a4c938d0fd11634c2498a9760dbe333ea7 Author: Dawid Wysakowicz <dwysakow...@apache.org> AuthorDate: Mon May 25 16:08:38 2020 +0200 [FLINK-17931] Document fromValues clause in Table API This closes #12325 --- docs/dev/table/tableApi.md | 88 +++++++++++++++++++++++++++++++++++++++++++ docs/dev/table/tableApi.zh.md | 88 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) diff --git a/docs/dev/table/tableApi.md b/docs/dev/table/tableApi.md index e39af04..1a7a8b8 100644 --- a/docs/dev/table/tableApi.md +++ b/docs/dev/table/tableApi.md @@ -227,6 +227,50 @@ Table orders = tableEnv.from("Orders"); {% endhighlight %} </td> </tr> + <tr> + <td> + <strong>Values</strong><br> + <span class="label label-primary">Batch</span> <span class="label label-primary">Streaming</span> + </td> + <td> + <p>Similar to the VALUES clause in a SQL query. Produces an inline table out of the provided rows.</p> + <p>You can use a `row(...)` expression to create composite rows:</p> +{% highlight java %} +Table table = tEnv.fromValues( + row(1, "ABC"), + row(2L, "ABCDE") +); +{% endhighlight %} + <p>will produce a Table with a schema as follows:</p> +{% highlight text %} +root +|-- f0: BIGINT NOT NULL // original types INT and BIGINT are generalized to BIGINT +|-- f1: VARCHAR(5) NOT NULL // original types CHAR(3) and CHAR(5) are generalized + // to VARCHAR(5). VARCHAR is used instead of CHAR so that + // no padding is applied +{% endhighlight %} + <p>The method will derive the types automatically from the input expressions. If types + at a certain position differ, the method will try to find a common super type for all types. If a common + super type does not exist, an exception will be thrown.</p> + <p>You can also specify the requested type explicitly. It might be helpful for assigning more generic types like e.g. DECIMAL or naming the columns.</p> +{% highlight java %} +Table table = tEnv.fromValues( + DataTypes.ROW( + DataTypes.FIELD("id", DataTypes.DECIMAL(10, 2)), + DataTypes.FIELD("name", DataTypes.STRING()) + ), + row(1, "ABC"), + row(2L, "ABCDE") +); +{% endhighlight %} + <p>will produce a Table with a schema as follows:</p> +{% highlight text %} +root +|-- id: DECIMAL(10, 2) +|-- name: STRING +{% endhighlight %} + </td> + </tr> <tr> <td> <strong>Select</strong><br> @@ -304,6 +348,50 @@ val orders: Table = tableEnv.from("Orders") </tr> <tr> <td> + <strong>Values</strong><br> + <span class="label label-primary">Batch</span> <span class="label label-primary">Streaming</span> + </td> + <td> + <p>Similar to the VALUES clause in a SQL query. Produces an inline table out of the provided rows.</p> + <p>You can use a `row(...)` expression to create composite rows:</p> +{% highlight scala %} +val table = tEnv.fromValues( + row(1, "ABC"), + row(2L, "ABCDE") +) +{% endhighlight %} + <p>will produce a Table with a schema as follows:</p> +{% highlight text %} +root +|-- f0: BIGINT NOT NULL // original types INT and BIGINT are generalized to BIGINT +|-- f1: VARCHAR(5) NOT NULL // original types CHAR(3) and CHAR(5) are generalized + // to VARCHAR(5). VARCHAR is used instead of CHAR so that + // no padding is applied +{% endhighlight %} + <p>The method will derive the types automatically from the input expressions. If types + at a certain position differ, the method will try to find a common super type for all types. If a common + super type does not exist, an exception will be thrown.</p> + <p>You can also specify the requested type explicitly. It might be helpful for assigning more generic types like e.g. DECIMAL or naming the columns.</p> +{% highlight scala %} +val table = tEnv.fromValues( + DataTypes.ROW( + DataTypes.FIELD("id", DataTypes.DECIMAL(10, 2)), + DataTypes.FIELD("name", DataTypes.STRING()) + ), + row(1, "ABC"), + row(2L, "ABCDE") +) +{% endhighlight %} + <p>will produce a Table with a schema as follows:</p> +{% highlight text %} +root +|-- id: DECIMAL(10, 2) +|-- name: STRING +{% endhighlight %} + </td> + </tr> + <tr> + <td> <strong>Select</strong><br> <span class="label label-primary">Batch</span> <span class="label label-primary">Streaming</span> </td> diff --git a/docs/dev/table/tableApi.zh.md b/docs/dev/table/tableApi.zh.md index 9db6055a..91eb03e 100644 --- a/docs/dev/table/tableApi.zh.md +++ b/docs/dev/table/tableApi.zh.md @@ -229,6 +229,50 @@ Table orders = tableEnv.from("Orders"); </tr> <tr> <td> + <strong>Values</strong><br> + <span class="label label-primary">Batch</span> <span class="label label-primary">Streaming</span> + </td> + <td> + <p>Similar to the VALUES clause in a SQL query. Produces an inline table out of the provided rows.</p> + <p>You can use a `row(...)` expression to create composite rows:</p> +{% highlight java %} +Table table = tEnv.fromValues( + row(1, "ABC"), + row(2L, "ABCDE") +); +{% endhighlight %} + <p>will produce a Table with a schema as follows:</p> +{% highlight text %} +root +|-- f0: BIGINT NOT NULL // original types INT and BIGINT are generalized to BIGINT +|-- f1: VARCHAR(5) NOT NULL // original types CHAR(3) and CHAR(5) are generalized + // to VARCHAR(5). VARCHAR is used instead of CHAR so that + // no padding is applied +{% endhighlight %} + <p>The method will derive the types automatically from the input expressions. If types + at a certain position differ, the method will try to find a common super type for all types. If a common + super type does not exist, an exception will be thrown.</p> + <p>You can also specify the requested type explicitly. It might be helpful for assigning more generic types like e.g. DECIMAL or naming the columns.</p> +{% highlight java %} +Table table = tEnv.fromValues( + DataTypes.ROW( + DataTypes.FIELD("id", DataTypes.DECIMAL(10, 2)), + DataTypes.FIELD("name", DataTypes.STRING()) + ), + row(1, "ABC"), + row(2L, "ABCDE") +); +{% endhighlight %} + <p>will produce a Table with a schema as follows:</p> +{% highlight text %} +root +|-- id: DECIMAL(10, 2) +|-- name: STRING +{% endhighlight %} + </td> + </tr> + <tr> + <td> <strong>Select</strong><br> <span class="label label-primary">Batch</span> <span class="label label-primary">Streaming</span> </td> @@ -304,6 +348,50 @@ val orders: Table = tableEnv.from("Orders") </tr> <tr> <td> + <strong>Values</strong><br> + <span class="label label-primary">Batch</span> <span class="label label-primary">Streaming</span> + </td> + <td> + <p>Similar to the VALUES clause in a SQL query. Produces an inline table out of the provided rows.</p> + <p>You can use a `row(...)` expression to create composite rows:</p> +{% highlight scala %} +val table = tEnv.fromValues( + row(1, "ABC"), + row(2L, "ABCDE") +) +{% endhighlight %} + <p>will produce a Table with a schema as follows:</p> +{% highlight text %} +root +|-- f0: BIGINT NOT NULL // original types INT and BIGINT are generalized to BIGINT +|-- f1: VARCHAR(5) NOT NULL // original types CHAR(3) and CHAR(5) are generalized + // to VARCHAR(5). VARCHAR is used instead of CHAR so that + // no padding is applied +{% endhighlight %} + <p>The method will derive the types automatically from the input expressions. If types + at a certain position differ, the method will try to find a common super type for all types. If a common + super type does not exist, an exception will be thrown.</p> + <p>You can also specify the requested type explicitly. It might be helpful for assigning more generic types like e.g. DECIMAL or naming the columns.</p> +{% highlight scala %} +val table = tEnv.fromValues( + DataTypes.ROW( + DataTypes.FIELD("id", DataTypes.DECIMAL(10, 2)), + DataTypes.FIELD("name", DataTypes.STRING()) + ), + row(1, "ABC"), + row(2L, "ABCDE") +) +{% endhighlight %} + <p>will produce a Table with a schema as follows:</p> +{% highlight text %} +root +|-- id: DECIMAL(10, 2) +|-- name: STRING +{% endhighlight %} + </td> + </tr> + <tr> + <td> <strong>Select</strong><br> <span class="label label-primary">Batch</span> <span class="label label-primary">Streaming</span> </td>