Skip to content

Commit

Permalink
[hotfix] [table] [docs] Improvements for the functions documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
twalthr committed Aug 14, 2018
1 parent ab1d1df commit 2f16894
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 122 deletions.
135 changes: 127 additions & 8 deletions docs/dev/table/functions.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Built-In Functions"
nav-parent_id: tableapi
nav-pos: 45
nav-pos: 31
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
Expand Down Expand Up @@ -30,7 +30,8 @@ If you think that the function is general enough, please <a href="https://issues
{:toc}

Scalar Functions
-----------------------------
----------------

The scalar functions take zero, one or more values as the input and return a single value as the result.

### Comparison Functions
Expand Down Expand Up @@ -3127,7 +3128,7 @@ DATE_FORMAT(timestamp, string)
{% endhighlight %}
</td>
<td>
<p>Returns a string that formats <i>timestamp</i> with a specified format <i>string</i>. The format specification is given in the <a href="sql.html#date-format-specifier">Date Format Specifier table</a>.</p>
<p>Returns a string that formats <i>timestamp</i> with a specified format <i>string</i>. The format specification is given in the <a href="#date-format-specifiers">Date Format Specifier table</a>.</p>
</td>
</tr>

Expand Down Expand Up @@ -3383,7 +3384,7 @@ dateFormat(TIMESTAMP, STRING)
{% endhighlight %}
</td>
<td>
<p>Returns a string that formats <i>TIMESTAMP</i> with a specified format <i>STRING</i>. The format specification is given in the <a href="sql.html#date-format-specifier">Date Format Specifier table</a>.</p>
<p>Returns a string that formats <i>TIMESTAMP</i> with a specified format <i>STRING</i>. The format specification is given in the <a href="#date-format-specifiers">Date Format Specifier table</a>.</p>
<p>E.g., <code>dateFormat(ts, '%Y, %d %M')</code> results in strings formatted as "2017, 05 May".</p>
</td>
</tr>
Expand Down Expand Up @@ -3628,7 +3629,7 @@ dateFormat(TIMESTAMP, STRING)
{% endhighlight %}
</td>
<td>
<p>Returns a string that formats <i>TIMESTAMP</i> with a specified format <i>STRING</i>. The format specification is given in the <a href="sql.html#date-format-specifier">Date Format Specifier table</a>.</p>
<p>Returns a string that formats <i>TIMESTAMP</i> with a specified format <i>STRING</i>. The format specification is given in the <a href="#date-format-specifiers">Date Format Specifier table</a>.</p>
<p>E.g., <code>dateFormat('ts, "%Y, %d %M")</code> results in strings formatted as "2017, 05 May".</p>
</td>
</tr>
Expand Down Expand Up @@ -3811,7 +3812,7 @@ ANY.cast(TYPE)
{% endhighlight %}
</td>
<td>
<p>Returns a new <i>ANY</i> being cast to type <i>TYPE</i>. See the supported types <a href="sql.html#data-types">here</a>.</p>
<p>Returns a new <i>ANY</i> being cast to type <i>TYPE</i>. See the supported types <a href="tableApi.html#data-types">here</a>.</p>
<p>E.g., <code>'42'.cast(INT)</code> returns 42.</p>
</td>
</tr>
Expand All @@ -3836,7 +3837,7 @@ ANY.cast(TYPE)
{% endhighlight %}
</td>
<td>
<p>Returns a new <i>ANY</i> being cast to type <i>TYPE</i>. See the supported types <a href="sql.html#data-types">here</a>.</p>
<p>Returns a new <i>ANY</i> being cast to type <i>TYPE</i>. See the supported types <a href="tableApi.html#data-types">here</a>.</p>
<p>E.g., <code>"42".cast(Types.INT)</code> returns 42.</p>
</td>
</tr>
Expand Down Expand Up @@ -4759,7 +4760,8 @@ ANY.as(NAME1, NAME2, ...)
</div>

Aggregate Functions
-----------------------------
-------------------

The aggregate functions take an expression across all the rows as the input and return a single aggregated value as the result.

<div class="codetabs" markdown="1">
Expand Down Expand Up @@ -5168,3 +5170,120 @@ FIELD.collect
</div>

{% top %}

Date Format Specifiers
----------------------

The following table lists specifiers for date format functions.

<table class="table table-bordered">
<thead>
<tr>
<th class="text-left" style="width: 40%">Specifier</th>
<th class="text-center">Description</th>
</tr>
</thead>
<tbody>
<tr><td>{% highlight text %}%a{% endhighlight %}</td>
<td>Abbreviated weekday name (<code>Sun</code> .. <code>Sat</code>)</td>
</tr>
<tr><td>{% highlight text %}%b{% endhighlight %}</td>
<td>Abbreviated month name (<code>Jan</code> .. <code>Dec</code>)</td>
</tr>
<tr><td>{% highlight text %}%c{% endhighlight %}</td>
<td>Month, numeric (<code>1</code> .. <code>12</code>)</td>
</tr>
<tr><td>{% highlight text %}%D{% endhighlight %}</td>
<td>Day of the month with English suffix (<code>0th</code>, <code>1st</code>, <code>2nd</code>, <code>3rd</code>, ...)</td>
</tr>
<tr><td>{% highlight text %}%d{% endhighlight %}</td>
<td>Day of the month, numeric (<code>01</code> .. <code>31</code>)</td>
</tr>
<tr><td>{% highlight text %}%e{% endhighlight %}</td>
<td>Day of the month, numeric (<code>1</code> .. <code>31</code>)</td>
</tr>
<tr><td>{% highlight text %}%f{% endhighlight %}</td>
<td>Fraction of second (6 digits for printing: <code>000000</code> .. <code>999000</code>; 1 - 9 digits for parsing: <code>0</code> .. <code>999999999</code>) (Timestamp is truncated to milliseconds.) </td>
</tr>
<tr><td>{% highlight text %}%H{% endhighlight %}</td>
<td>Hour (<code>00</code> .. <code>23</code>)</td>
</tr>
<tr><td>{% highlight text %}%h{% endhighlight %}</td>
<td>Hour (<code>01</code> .. <code>12</code>)</td>
</tr>
<tr><td>{% highlight text %}%I{% endhighlight %}</td>
<td>Hour (<code>01</code> .. <code>12</code>)</td>
</tr>
<tr><td>{% highlight text %}%i{% endhighlight %}</td>
<td>Minutes, numeric (<code>00</code> .. <code>59</code>)</td>
</tr>
<tr><td>{% highlight text %}%j{% endhighlight %}</td>
<td>Day of year (<code>001</code> .. <code>366</code>)</td>
</tr>
<tr><td>{% highlight text %}%k{% endhighlight %}</td>
<td>Hour (<code>0</code> .. <code>23</code>)</td>
</tr>
<tr><td>{% highlight text %}%l{% endhighlight %}</td>
<td>Hour (<code>1</code> .. <code>12</code>)</td>
</tr>
<tr><td>{% highlight text %}%M{% endhighlight %}</td>
<td>Month name (<code>January</code> .. <code>December</code>)</td>
</tr>
<tr><td>{% highlight text %}%m{% endhighlight %}</td>
<td>Month, numeric (<code>01</code> .. <code>12</code>)</td>
</tr>
<tr><td>{% highlight text %}%p{% endhighlight %}</td>
<td><code>AM</code> or <code>PM</code></td>
</tr>
<tr><td>{% highlight text %}%r{% endhighlight %}</td>
<td>Time, 12-hour (<code>hh:mm:ss</code> followed by <code>AM</code> or <code>PM</code>)</td>
</tr>
<tr><td>{% highlight text %}%S{% endhighlight %}</td>
<td>Seconds (<code>00</code> .. <code>59</code>)</td>
</tr>
<tr><td>{% highlight text %}%s{% endhighlight %}</td>
<td>Seconds (<code>00</code> .. <code>59</code>)</td>
</tr>
<tr><td>{% highlight text %}%T{% endhighlight %}</td>
<td>Time, 24-hour (<code>hh:mm:ss</code>)</td>
</tr>
<tr><td>{% highlight text %}%U{% endhighlight %}</td>
<td>Week (<code>00</code> .. <code>53</code>), where Sunday is the first day of the week</td>
</tr>
<tr><td>{% highlight text %}%u{% endhighlight %}</td>
<td>Week (<code>00</code> .. <code>53</code>), where Monday is the first day of the week</td>
</tr>
<tr><td>{% highlight text %}%V{% endhighlight %}</td>
<td>Week (<code>01</code> .. <code>53</code>), where Sunday is the first day of the week; used with <code>%X</code></td>
</tr>
<tr><td>{% highlight text %}%v{% endhighlight %}</td>
<td>Week (<code>01</code> .. <code>53</code>), where Monday is the first day of the week; used with <code>%x</code></td>
</tr>
<tr><td>{% highlight text %}%W{% endhighlight %}</td>
<td>Weekday name (<code>Sunday</code> .. <code>Saturday</code>)</td>
</tr>
<tr><td>{% highlight text %}%w{% endhighlight %}</td>
<td>Day of the week (<code>0</code> .. <code>6</code>), where Sunday is the first day of the week</td>
</tr>
<tr><td>{% highlight text %}%X{% endhighlight %}</td>
<td>Year for the week where Sunday is the first day of the week, numeric, four digits; used with <code>%V</code></td>
</tr>
<tr><td>{% highlight text %}%x{% endhighlight %}</td>
<td>Year for the week, where Monday is the first day of the week, numeric, four digits; used with <code>%v</code></td>
</tr>
<tr><td>{% highlight text %}%Y{% endhighlight %}</td>
<td>Year, numeric, four digits</td>
</tr>
<tr><td>{% highlight text %}%y{% endhighlight %}</td>
<td>Year, numeric (two digits) </td>
</tr>
<tr><td>{% highlight text %}%%{% endhighlight %}</td>
<td>A literal <code>%</code> character</td>
</tr>
<tr><td>{% highlight text %}%x{% endhighlight %}</td>
<td><code>x</code>, for any <code>x</code> not listed above</td>
</tr>
</tbody>
</table>

{% top %}
119 changes: 6 additions & 113 deletions docs/dev/table/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,13 @@ The SQL runtime is built on top of Flink's DataSet and DataStream APIs. Internal
| `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` |
| `Types.ROW` | `ROW` | `org.apache.flink.types.Row` |

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).
Generic types and (nested) composite types (e.g., POJOs, tuples, rows, Scala case classes) can be fields of a row as well.

Fields of composite types with arbitrary nesting can be accessed with [value access functions](functions.html#value-access-functions).

Generic types are treated as a black box and can be passed on or processed by [user-defined functions](udfs.html).

{% top %}

Expand All @@ -907,117 +912,5 @@ A, ABS, ABSOLUTE, ACTION, ADA, ADD, ADMIN, AFTER, ALL, ALLOCATE, ALLOW, ALTER, A

{% endhighlight %}

#### Date Format Specifier

<table class="table table-bordered">
<thead>
<tr>
<th class="text-left" style="width: 40%">Specifier</th>
<th class="text-center">Description</th>
</tr>
</thead>
<tbody>
<tr><td>{% highlight text %}%a{% endhighlight %}</td>
<td>Abbreviated weekday name (<code>Sun</code> .. <code>Sat</code>)</td>
</tr>
<tr><td>{% highlight text %}%b{% endhighlight %}</td>
<td>Abbreviated month name (<code>Jan</code> .. <code>Dec</code>)</td>
</tr>
<tr><td>{% highlight text %}%c{% endhighlight %}</td>
<td>Month, numeric (<code>1</code> .. <code>12</code>)</td>
</tr>
<tr><td>{% highlight text %}%D{% endhighlight %}</td>
<td>Day of the month with English suffix (<code>0th</code>, <code>1st</code>, <code>2nd</code>, <code>3rd</code>, ...)</td>
</tr>
<tr><td>{% highlight text %}%d{% endhighlight %}</td>
<td>Day of the month, numeric (<code>01</code> .. <code>31</code>)</td>
</tr>
<tr><td>{% highlight text %}%e{% endhighlight %}</td>
<td>Day of the month, numeric (<code>1</code> .. <code>31</code>)</td>
</tr>
<tr><td>{% highlight text %}%f{% endhighlight %}</td>
<td>Fraction of second (6 digits for printing: <code>000000</code> .. <code>999000</code>; 1 - 9 digits for parsing: <code>0</code> .. <code>999999999</code>) (Timestamp is truncated to milliseconds.) </td>
</tr>
<tr><td>{% highlight text %}%H{% endhighlight %}</td>
<td>Hour (<code>00</code> .. <code>23</code>)</td>
</tr>
<tr><td>{% highlight text %}%h{% endhighlight %}</td>
<td>Hour (<code>01</code> .. <code>12</code>)</td>
</tr>
<tr><td>{% highlight text %}%I{% endhighlight %}</td>
<td>Hour (<code>01</code> .. <code>12</code>)</td>
</tr>
<tr><td>{% highlight text %}%i{% endhighlight %}</td>
<td>Minutes, numeric (<code>00</code> .. <code>59</code>)</td>
</tr>
<tr><td>{% highlight text %}%j{% endhighlight %}</td>
<td>Day of year (<code>001</code> .. <code>366</code>)</td>
</tr>
<tr><td>{% highlight text %}%k{% endhighlight %}</td>
<td>Hour (<code>0</code> .. <code>23</code>)</td>
</tr>
<tr><td>{% highlight text %}%l{% endhighlight %}</td>
<td>Hour (<code>1</code> .. <code>12</code>)</td>
</tr>
<tr><td>{% highlight text %}%M{% endhighlight %}</td>
<td>Month name (<code>January</code> .. <code>December</code>)</td>
</tr>
<tr><td>{% highlight text %}%m{% endhighlight %}</td>
<td>Month, numeric (<code>01</code> .. <code>12</code>)</td>
</tr>
<tr><td>{% highlight text %}%p{% endhighlight %}</td>
<td><code>AM</code> or <code>PM</code></td>
</tr>
<tr><td>{% highlight text %}%r{% endhighlight %}</td>
<td>Time, 12-hour (<code>hh:mm:ss</code> followed by <code>AM</code> or <code>PM</code>)</td>
</tr>
<tr><td>{% highlight text %}%S{% endhighlight %}</td>
<td>Seconds (<code>00</code> .. <code>59</code>)</td>
</tr>
<tr><td>{% highlight text %}%s{% endhighlight %}</td>
<td>Seconds (<code>00</code> .. <code>59</code>)</td>
</tr>
<tr><td>{% highlight text %}%T{% endhighlight %}</td>
<td>Time, 24-hour (<code>hh:mm:ss</code>)</td>
</tr>
<tr><td>{% highlight text %}%U{% endhighlight %}</td>
<td>Week (<code>00</code> .. <code>53</code>), where Sunday is the first day of the week</td>
</tr>
<tr><td>{% highlight text %}%u{% endhighlight %}</td>
<td>Week (<code>00</code> .. <code>53</code>), where Monday is the first day of the week</td>
</tr>
<tr><td>{% highlight text %}%V{% endhighlight %}</td>
<td>Week (<code>01</code> .. <code>53</code>), where Sunday is the first day of the week; used with <code>%X</code></td>
</tr>
<tr><td>{% highlight text %}%v{% endhighlight %}</td>
<td>Week (<code>01</code> .. <code>53</code>), where Monday is the first day of the week; used with <code>%x</code></td>
</tr>
<tr><td>{% highlight text %}%W{% endhighlight %}</td>
<td>Weekday name (<code>Sunday</code> .. <code>Saturday</code>)</td>
</tr>
<tr><td>{% highlight text %}%w{% endhighlight %}</td>
<td>Day of the week (<code>0</code> .. <code>6</code>), where Sunday is the first day of the week</td>
</tr>
<tr><td>{% highlight text %}%X{% endhighlight %}</td>
<td>Year for the week where Sunday is the first day of the week, numeric, four digits; used with <code>%V</code></td>
</tr>
<tr><td>{% highlight text %}%x{% endhighlight %}</td>
<td>Year for the week, where Monday is the first day of the week, numeric, four digits; used with <code>%v</code></td>
</tr>
<tr><td>{% highlight text %}%Y{% endhighlight %}</td>
<td>Year, numeric, four digits</td>
</tr>
<tr><td>{% highlight text %}%y{% endhighlight %}</td>
<td>Year, numeric (two digits) </td>
</tr>
<tr><td>{% highlight text %}%%{% endhighlight %}</td>
<td>A literal <code>%</code> character</td>
</tr>
<tr><td>{% highlight text %}%x{% endhighlight %}</td>
<td><code>x</code>, for any <code>x</code> not listed above</td>
</tr>
</tbody>
</table>

{% top %}

7 changes: 6 additions & 1 deletion docs/dev/table/tableApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -1577,8 +1577,13 @@ The Table API is built on top of Flink's DataSet and DataStream APIs. Internally
| `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` |
| `Types.ROW` | `ROW` | `org.apache.flink.types.Row` |

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).
Generic types and (nested) composite types (e.g., POJOs, tuples, rows, Scala case classes) can be fields of a row as well.

Fields of composite types with arbitrary nesting can be accessed with [value access functions](functions.html#value-access-functions).

Generic types are treated as a black box and can be passed on or processed by [user-defined functions](udfs.html).

{% top %}

Expand Down

0 comments on commit 2f16894

Please sign in to comment.