[ 
https://issues.apache.org/jira/browse/CALCITE-1912?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16109836#comment-16109836
 ] 

Julian Hyde commented on CALCITE-1912:
--------------------------------------

This feature would cover temporal support as described in SQL:2011, and 
implemented in Oracle (among others).

Joins of streams to temporal tables (e.g. joining the Orders stream to the 
Products table for the price as of the time the order was placed) is outside 
the scope of this case.

If possible, I would very much like this feature to go beyond SQL parsing and 
validation, and to be able to execute temporal queries in core Calcite. This 
implies that we would have a temporal table in one of the standard data sets. 
And we would have a way of declaring a temporal table in a JSON model file.

Here is an example:

{code}
      "tables": [
        {
          "name": "TEMPORAL_EMPS",
          "type": "custom",
          "factory": "org.apache.calcite.adapter.csv.CsvTableFactory",
          "temporal": {
            "start": "EMP_VT_TIME_START",
            "end": "EMP_VT_TIME_END"
          }
        }
      ]
{code}

To implement

{code}SELECT empno, sal
FROM TEMPORAL_EMPS FOR SYSTEM_TIME AS OF DATE '2017-02-03'{code}

Calcite would generate a plan equivalent to

{code}SELECT empno, sal
FROM TEMPORAL_EMPS
WHERE EMP_VT_TIME_START <= DATE '2017-02-03'
AND (EMP_VT_TIME_END IS NULL
    OR EMP_VT_TIME_END > DATE '2017-02-03'){code}


> Support "FOR SYSTEM_TIME AS OF" in regular queries
> --------------------------------------------------
>
>                 Key: CALCITE-1912
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1912
>             Project: Calcite
>          Issue Type: New Feature
>            Reporter: Jark Wu
>            Assignee: Julian Hyde
>
> As discussed in mailling list[1], we hope to support "FOR SYSTEM_TIME AS OF" 
> in Calcite to retrieve table contents as of a given point in time. 
> [1] 
> https://lists.apache.org/thread.html/f877f356a8365bf74ea7d8e4a171224104d653cf73861afb2901a58f@%3Cdev.calcite.apache.org%3E



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to