Skip to content

Commit

Permalink
[hotfix] [docs] Improve Supported Types section of Table API & SQL docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
fhueske committed Nov 7, 2017
1 parent 9be150e commit f1ea6a6
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 88 deletions.
63 changes: 29 additions & 34 deletions docs/dev/table/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ val result4 = tableEnv.sqlQuery(
Data Types
----------

The SQL runtime is built on top of Flink's DataSet and DataStream APIs. Internally, it also uses Flink's `TypeInformation` to distinguish between types. The SQL support does not include all Flink types so far. All supported simple types are listed in `org.apache.flink.table.api.Types`. The following table summarizes the relation between SQL Types, Table API types, and the resulting Java class.
The SQL runtime is built on top of Flink's DataSet and DataStream APIs. Internally, it also uses Flink's `TypeInformation` to define data types. Fully supported types are listed in `org.apache.flink.table.api.Types`. The following table summarizes the relation between SQL Types, Table API types, and the resulting Java class.

| Table API | SQL | Java type |
| :--------------------- | :-------------------------- | :--------------------- |
Expand All @@ -823,21 +823,14 @@ The SQL runtime is built on top of Flink's DataSet and DataStream APIs. Internal
| `Types.MAP` | `MAP` | `java.util.HashMap` |
| `Types.MULTISET` | `MULTISET` | e.g. `java.util.HashMap<String, Integer>` for a multiset of `String` |


Advanced types such as generic types, composite types (e.g. POJOs or Tuples), and array types (object or primitive arrays) can be fields of a row.

Generic types are treated as a black box within Table API and SQL yet.

Composite types, however, are fully supported types where fields of a composite type can be accessed using the `.get()` operator in Table API and dot operator (e.g. `MyTable.pojoColumn.myField`) in SQL. Composite types can also be flattened using `.flatten()` in Table API or `MyTable.pojoColumn.*` in SQL.

Array types can be accessed using the `myArray.at(1)` operator in Table API and `myArray[1]` operator in SQL. Array literals can be created using `array(1, 2, 3)` in Table API and `ARRAY[1, 2, 3]` in SQL.
Generic types and composite types (e.g., POJOs or Tuples) can be fields of a row as well. Generic types are treated as a black box and can be passed on or processed by [user-defined functions](udfs.html). Composite types can be accessed with [built-in functions](#built-in-functions) (see *Value access functions* section).

{% top %}

Built-In Functions
------------------

Both the Table API and SQL come with a set of built-in functions for data transformations. This section gives a brief overview of the available functions so far.
Flink's SQL support comes with a set of built-in functions for data transformations. This section gives a brief overview of the available functions.

<!--
This list of SQL functions should be kept in sync with SqlExpressionTest to reduce confusion due to the large amount of SQL functions.
Expand Down Expand Up @@ -1819,6 +1812,7 @@ CAST(value AS type)
</tbody>
</table>

<!-- Disabled temporarily in favor of composite type support
<table class="table table-bordered">
<thead>
<tr>
Expand All @@ -1828,7 +1822,7 @@ CAST(value AS type)
</thead>
<tbody>
<!-- Disabled temporarily in favor of composite type support
<tr>
<td>
{% highlight text %}
Expand All @@ -1850,32 +1844,10 @@ ROW (value [, value]* )
<p>Creates a row from a list of values.</p>
</td>
</tr>
-->

<tr>
<td>
{% highlight text %}
array ‘[’ index ‘]
{% endhighlight %}
</td>
<td>
<p>Returns the element at a particular position in an array. The index starts at 1.</p>
</td>
</tr>

<tr>
<td>
{% highlight text %}
ARRAY ‘[’ value [, value ]*]
{% endhighlight %}
</td>
<td>
<p>Creates an array from a list of values.</p>
</td>
</tr>
</tbody>
</table>
-->

<table class="table table-bordered">
<thead>
Expand Down Expand Up @@ -2283,6 +2255,18 @@ tableName.compositeType.*
</thead>

<tbody>

<tr>
<td>
{% highlight text %}
ARRAY ‘[’ value [, value ]*]
{% endhighlight %}
</td>
<td>
<p>Creates an array from a list of values.</p>
</td>
</tr>

<tr>
<td>
{% highlight text %}
Expand All @@ -2294,6 +2278,17 @@ CARDINALITY(ARRAY)
</td>
</tr>

<tr>
<td>
{% highlight text %}
array ‘[’ index ‘]
{% endhighlight %}
</td>
<td>
<p>Returns the element at a particular position in an array. The index starts at 1.</p>
</td>
</tr>

<tr>
<td>
{% highlight text %}
Expand Down
102 changes: 48 additions & 54 deletions docs/dev/table/tableApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ The `OverWindow` defines a range of rows over which aggregates are computed. `Ov
Data Types
----------

The Table API is built on top of Flink's DataSet and DataStream API. Internally, it also uses Flink's `TypeInformation` to distinguish between types. The Table API does not support all Flink types so far. All supported simple types are listed in `org.apache.flink.table.api.Types`. The following table summarizes the relation between Table API types, SQL types, and the resulting Java class.
The Table API is built on top of Flink's DataSet and DataStream APIs. Internally, it also uses Flink's `TypeInformation` to define data types. Fully supported types are listed in `org.apache.flink.table.api.Types`. The following table summarizes the relation between Table API types, SQL types, and the resulting Java class.

| Table API | SQL | Java type |
| :--------------------- | :-------------------------- | :--------------------- |
Expand All @@ -1565,15 +1565,9 @@ The Table API is built on top of Flink's DataSet and DataStream API. Internally,
| `Types.PRIMITIVE_ARRAY`| `ARRAY` | e.g. `int[]` |
| `Types.OBJECT_ARRAY` | `ARRAY` | e.g. `java.lang.Byte[]`|
| `Types.MAP` | `MAP` | `java.util.HashMap` |
| `Types.MULTISET` | `MULTISET` | e.g. `java.util.HashMap<String, Integer>` for a multiset of `String` |


Advanced types such as generic types, composite types (e.g. POJOs or Tuples), and array types (object or primitive arrays) can be fields of a row.

Generic types are treated as a black box within Table API and SQL yet.

Composite types, however, are fully supported types where fields of a composite type can be accessed using the `.get()` operator in Table API and dot operator (e.g. `MyTable.pojoColumn.myField`) in SQL. Composite types can also be flattened using `.flatten()` in Table API or `MyTable.pojoColumn.*` in SQL.

Array types can be accessed using the `myArray.at(1)` operator in Table API and `myArray[1]` operator in SQL. Array literals can be created using `array(1, 2, 3)` in Table API and `ARRAY[1, 2, 3]` in SQL.
Generic types and composite types (e.g., POJOs or Tuples) can be fields of a row as well. Generic types are treated as a black box and can be passed on or processed by [user-defined functions](udfs.html). Composite types can be accessed with [built-in functions](#built-in-functions) (see *Value access functions* section).

{% top %}

Expand Down Expand Up @@ -1654,7 +1648,7 @@ Temporal intervals can be represented as number of months (`Types.INTERVAL_MONTH
Built-In Functions
------------------

Both the Table API and SQL come with a set of built-in functions for data transformations. This section gives a brief overview of the available functions so far.
The Table API comes with a set of built-in functions for data transformations. This section gives a brief overview of the available functions.

<div class="codetabs" markdown="1">
<div data-lang="java" markdown="1">
Expand Down Expand Up @@ -2468,28 +2462,6 @@ ANY.cast(TYPE)

<tbody>

<tr>
<td>
{% highlight java %}
ARRAY.at(INT)
{% endhighlight %}
</td>
<td>
<p>Returns the element at a particular position in an array. The index starts at 1.</p>
</td>
</tr>

<tr>
<td>
{% highlight java %}
array(ANY [, ANY ]*)
{% endhighlight %}
</td>
<td>
<p>Creates an array from a list of values. The array will be an array of objects (not primitives).</p>
</td>
</tr>

<tr>
<td>
{% highlight java %}
Expand Down Expand Up @@ -2926,6 +2898,17 @@ ANY.flatten()

<tbody>

<tr>
<td>
{% highlight java %}
array(ANY [, ANY ]*)
{% endhighlight %}
</td>
<td>
<p>Creates an array from a list of values. The array will be an array of objects (not primitives).</p>
</td>
</tr>

<tr>
<td>
{% highlight java %}
Expand All @@ -2937,6 +2920,17 @@ ARRAY.cardinality()
</td>
</tr>

<tr>
<td>
{% highlight java %}
ARRAY.at(INT)
{% endhighlight %}
</td>
<td>
<p>Returns the element at a particular position in an array. The index starts at 1.</p>
</td>
</tr>

<tr>
<td>
{% highlight java %}
Expand Down Expand Up @@ -3764,28 +3758,6 @@ ANY.cast(TYPE)

<tbody>

<tr>
<td>
{% highlight scala %}
ARRAY.at(INT)
{% endhighlight %}
</td>
<td>
<p>Returns the element at a particular position in an array. The index starts at 1.</p>
</td>
</tr>

<tr>
<td>
{% highlight scala %}
array(ANY [, ANY ]*)
{% endhighlight %}
</td>
<td>
<p>Creates an array from a list of values. The array will be an array of objects (not primitives).</p>
</td>
</tr>

<tr>
<td>
{% highlight scala %}
Expand Down Expand Up @@ -4220,6 +4192,17 @@ dateFormat(TIMESTAMP, STRING)

<tbody>

<tr>
<td>
{% highlight scala %}
array(ANY [, ANY ]*)
{% endhighlight %}
</td>
<td>
<p>Creates an array from a list of values. The array will be an array of objects (not primitives).</p>
</td>
</tr>

<tr>
<td>
{% highlight scala %}
Expand All @@ -4231,6 +4214,17 @@ ARRAY.cardinality()
</td>
</tr>

<tr>
<td>
{% highlight scala %}
ARRAY.at(INT)
{% endhighlight %}
</td>
<td>
<p>Returns the element at a particular position in an array. The index starts at 1.</p>
</td>
</tr>

<tr>
<td>
{% highlight scala %}
Expand Down

0 comments on commit f1ea6a6

Please sign in to comment.