Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


@PublicEvolving
public interface Catalog {

Page properties

Document the state by adding a label to the FLIP page with one of "discussion", "accepted", "released", "rejected".

Discussion threadhere (<- link to https://lists.apache.org/list.html?dev@flink.apache.org)
Vote threadhere (<- link to https://lists.apache.org/list.html?dev@flink.apache.org)
JIRAhere (<- link to https://issues.apache.org/jira/browse/FLINK-XXXX)
Release<Flink Version>


Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

Describe the problems you are trying to solve.

Public Interfaces

Syntax

We propose add the following syntax for time travel statement. 

Code Block
languagesql
-- Specify a specific time
SELECT * FROM paimon_tb AS OF TIMESTAMP '2023-04-27 00:00:00'

-- Specify a constant expression
SELECT * FROM paimon_tb AS OF TIMESTAMP '2023-04-27 00:00:00' - INTERVAL '1' DAY


Public interfaces

Catalog

Code Block
languagejava
@PublicEvolving
public interface Catalog {

   /**
     * Returns a {@link CatalogTable} or {@link CatalogView} identified by the given {@link
     * ObjectPath}. The framework will resolve the metadata objects when necessary.
     *
     * @param tablePath Path of the table or view
     * @param timestamp Timestamp of the table snapshot
     * @return The requested table or view
     * @throws TableNotExistException if the target does not exist
     * @throws CatalogException in case of any runtime exception
     */
    default CatalogBaseTable getTable(ObjectPath tablePath, long timestamp)
            throws TableNotExistException, CatalogException {
        throw new UnsupportedOperationException(
                String.format("Table %s does not support time travel.", tablePath));
    }

}



Proposed Changes


Compatibility, Deprecation, and Migration Plan


Test Plan

UT&IT


Other Syntax of timetravel

Due to the current limitations of Calcite syntax, we can only support specifying a single time and cannot specify a time range.

...

Code Block
languagesql
SELECT ENo,EName,Sys_Start,Sys_End
FROM Emp FOR SYSTEM_TIME FROM
 TIMESTAMP '2011-01-02 00:00:00’TO
 TIMESTAMP '2011-12-31 00:00:00' 

OR 

Code Block
languagesql
SELECT ENo,EName,Sys_Start,Sys_End
FROM Emp FOR SYSTEM_TIME BETWEEN
 TIMESTAMP '2011-01-02 00:00:00'AND
 TIMESTAMP '2011-12-31 00:00:00' 



Rejected Alternatives

Add SupportsTimeTravel source ability  

Add a new source ability interface. Different connectors can implement this interfaces to support time travel.

...