flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-9712) Support enrichment joins in Flink SQL/Table API
Date Tue, 02 Oct 2018 17:42:04 GMT

    [ https://issues.apache.org/jira/browse/FLINK-9712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16635875#comment-16635875

ASF GitHub Bot commented on FLINK-9712:

fhueske commented on a change in pull request #6741: [FLINK-9712][table,docs] Document processing
time Temporal Table Joins
URL: https://github.com/apache/flink/pull/6741#discussion_r222004085

 File path: docs/dev/table/streaming/temporal_tables.md
 @@ -0,0 +1,286 @@
+title: "Temporal Tables"
+nav-parent_id: streaming_tableapi
+nav-pos: 4
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+Temporal Tables represent a concept of a table that changes over time.
+Flink can keep track of those changes and allows for accessing the table's content at a certain
point in time within a query
+* This will be replaced by the TOC
+Let's assume that we have the following tables.
+{% highlight sql %}
+SELECT * FROM Orders;
+rowtime amount currency
+======= ====== =========
+10:15        2 Euro
+10:30        1 US Dollar
+10:32       50 Yen
+10:52        3 Euro
+11:04        5 US Dollar
+{% endhighlight %}
+`Orders` is an append-only table that represents payments for given `amount` and given `currency`.
+For example at `10:15` there was an order for an amount of `2 Euro`.
+{% highlight sql %}
+SELECT * FROM RatesHistory;
+rowtime currency   rate
+======= ======== ======
+09:00   US Dollar   102
+09:00   Euro        114
+09:00   Yen           1
+10:45   Euro        116
+11:15   Euro        119
+{% endhighlight %}
+`RatesHistory` represents an ever changing append-only stream of currency exchange rates,
with respect to `Yen` (which has a rate of `1`).
+For example exchange rate for a period from `09:00` to `10:45` of `Euro` to `Yen` was `114`.
+From `10:45` to `11:15` it was `116`.
+Task is now to calculate a value of all of the `Orders` converted to common currency (`Yen`).
+For example we would like to convert the order
+{% highlight sql %}
+rowtime amount currency
+======= ====== =========
+10:15        2 Euro
+{% endhighlight %}
+using the appropriate conversion rate for the given `rowtime` (`114`).
+Without using Temporal Tables in order to do so, one would need to write such query:
+{% highlight sql %}
+  SUM(o.amount * r.rate) AS amount
+FROM Orders AS o,
+  RatesHistory AS r
+WHERE r.currency = o.currency
+AND r.rowtime = (
+  SELECT MAX(rowtime)
+  FROM Rates AS r2
+  WHERE r2.currency = o.currency
+  AND r2.rowtime <= o.rowtime);
+{% endhighlight %}
+Temporal Tables are a concept that aims to simplify this query,
 Review comment:
   At this point, we should define what a temporal table is. 
   Something like
   > A Temporal Table is a parameterized view on an append-only table that interprets the
rows of the append-only table as the changelog of a table and provides the version of that
table at a specific point in time. Interpreting the append-only table as a changelog requires
the specification of a primary key attribute and a timestamp attribute. The primary key determines
which rows are overwritten and the timestamp determines the time during which a row is valid.
In the above example `currency` would be a primary key for `RatesHistory` table and `rowtime`
would be the timestamp attribute.
   > In Flink, a Temporal Table is represented by a Temporal Table Function.

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

> Support enrichment joins in Flink SQL/Table API
> -----------------------------------------------
>                 Key: FLINK-9712
>                 URL: https://issues.apache.org/jira/browse/FLINK-9712
>             Project: Flink
>          Issue Type: New Feature
>          Components: Table API &amp; SQL
>    Affects Versions: 1.5.0
>            Reporter: Piotr Nowojski
>            Assignee: Piotr Nowojski
>            Priority: Major
>              Labels: pull-request-available
> As described here:
> https://docs.google.com/document/d/1KaAkPZjWFeu-ffrC9FhYuxE6CIKsatHTTxyrxSBR8Sk/edit?usp=sharing

This message was sent by Atlassian JIRA

View raw message