Skip to content

Commit

Permalink
[FLINK-17920][python][docs] Add the Python example of the Interval Jo…
Browse files Browse the repository at this point in the history
…in (apache#12779)
  • Loading branch information
shuiqiangchen committed Jun 29, 2020
1 parent 58c2047 commit a6573ee
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
26 changes: 22 additions & 4 deletions docs/dev/table/tableApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ Table fullOuterResult = left.fullOuterJoin(right, $("a").isEqual($("d")))
<td>
<p><b>Note:</b> Interval joins are a subset of regular joins that can be processed in a streaming fashion.</p>

<p>A interval join requires at least one equi-join predicate and a join condition that bounds the time on both sides. Such a condition can be defined by two appropriate range predicates (<code>&lt;, &lt;=, &gt;=, &gt;</code>) or a single equality predicate that compares <a href="streaming/time_attributes.html">time attributes</a> of the same type (i.e., processing time or event time) of both input tables.</p>
<p>An interval join requires at least one equi-join predicate and a join condition that bounds the time on both sides. Such a condition can be defined by two appropriate range predicates (<code>&lt;, &lt;=, &gt;=, &gt;</code>) or a single equality predicate that compares <a href="streaming/time_attributes.html">time attributes</a> of the same type (i.e., processing time or event time) of both input tables.</p>
<p>For example, the following predicates are valid interval join conditions:</p>

<ul>
Expand Down Expand Up @@ -1322,7 +1322,7 @@ val fullOuterResult = left.fullOuterJoin(right, $"a" === $"d").select($"a", $"b"
<td>
<p><b>Note:</b> Interval joins are a subset of regular joins that can be processed in a streaming fashion.</p>

<p>A interval join requires at least one equi-join predicate and a join condition that bounds the time on both sides. Such a condition can be defined by two appropriate range predicates (<code>&lt;, &lt;=, &gt;=, &gt;</code>) or a single equality predicate that compares <a href="streaming/time_attributes.html">time attributes</a> of the same type (i.e., processing time or event time) of both input tables.</p>
<p>An interval join requires at least one equi-join predicate and a join condition that bounds the time on both sides. Such a condition can be defined by two appropriate range predicates (<code>&lt;, &lt;=, &gt;=, &gt;</code>) or a single equality predicate that compares <a href="streaming/time_attributes.html">time attributes</a> of the same type (i.e., processing time or event time) of both input tables.</p>
<p>For example, the following predicates are valid interval join conditions:</p>

<ul>
Expand Down Expand Up @@ -1459,9 +1459,27 @@ full_outer_result = left.full_outer_join(right, "a = d").select("a, b, e")
<span class="label label-primary">Batch</span>
<span class="label label-primary">Streaming</span>
</td>
<td>
<p>Currently not supported in python API.</p>
<td>
<p><b>Note:</b> Interval joins are a subset of regular joins that can be processed in a streaming fashion.</p>
<p>An interval join requires at least one equi-join predicate and a join condition that bounds the time on both sides. Such a condition can be defined by two appropriate range predicates (<code>&lt;, &lt;=, &gt;=, &gt;</code>) or a single equality predicate that compares <a href="streaming/time_attributes.html">time attributes</a> of the same type (i.e., processing time or event time) of both input tables.</p>
<p>For example, the following predicates are valid interval join conditions:</p>
<ul>
<li><code>ltime = rtime</code></li>
<li><code>ltime &gt;= rtime &amp;&amp; ltime &lt; rtime + 2.second</code></li>
</ul>
{% highlight python %}
left = table_env.from_path("Source1").select("a, b, c, rowtime1")
right = table_env.from_path("Source2").select("d, e, f, rowtime2")

result = left.join(right).where("a = d && rowtime1 >= rowtime2 - 1.second
&& rowtime1 <= rowtime2 + 2.second").select("a, b, e, rowtime1")
{% endhighlight %}
</td>

</tr>
<tr>
<td>
Expand Down
21 changes: 18 additions & 3 deletions docs/dev/table/tableApi.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -1458,9 +1458,24 @@ full_outer_result = left.full_outer_join(right, "a = d").select("a, b, e")
<span class="label label-primary">批处理</span>
<span class="label label-primary">流处理</span>
</td>
<td>
<p>Python API暂不支持。</p>
</td>
<td>
<p><b>注意:</b> Interval Join 是所有常规流式数据处理join操作中的其中一种场景。</p>
<p>Interval Join 要求至少有一个等值连接条件以及一个用于划定时间间隔的条件。对两条数据流时间的划定可以通过两个范围比较确定一个合适时间区间(<code>&lt;, &lt;=, &gt;=, &gt;</code>), 也可以简单的通过对相同<a href="streaming/time_attributes.html">时间属性</a>(当前处理时间或事件时间)的时间值进行等值比较确定。</p>
<p>如下示例是合法的Interval Join条件:</p>
<ul>
<li><code>ltime = rtime</code></li>
<li><code>ltime &gt;= rtime &amp;&amp; ltime &lt; rtime + 2.second</code></li>
</ul>
{% highlight python %}
left = table_env.from_path("Source1").select("a, b, c, rowtime1")
right = table_env.from_path("Source2").select("d, e, f, rowtime2")

result = left.join(right).where("a = d && rowtime1 >= rowtime2 - 1.second
&& rowtime1 <= rowtime2 + 2.second").select("a, b, e, rowtime1")
{% endhighlight %}
</td>
</tr>
<tr>
<td>
Expand Down

0 comments on commit a6573ee

Please sign in to comment.