Page properties |
---|
Document the state by adding a label to the FLIP page with one of "discussion", "accepted", "released", "rejected".
|
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 |
---|
|
SELECT * FROM paimon_tb AS OF TIMESTAMP '2023-04-27 00:00:00' |
Public interfaces
Add a new source ability interface. Different connectors can implement this interfaces to support time travel.
Code Block |
---|
|
/**
Enables to push down the timestamp of snapshot into a {@link ScanTableSource}.
*
* <p>When a source connector implements the SupportsTimeTravel interface, users can leverage its
* time-travel functionality to analyze historical data, perform backfilling operations, and more.
* This can be particularly useful for debugging and data recovery purposes.
*/
@PublicEvolving
public interface SupportsTimeTravel {
/**
* @param timestamp The timestamp of the snapshot to apply.
*/
void applySnapshot(long timestamp);
}
|
Proposed Changes
1. Add the Source Ability interface to support TimeTravel systems in implementing TimeTravel capabilities.
2. Add corresponding table optimization rules so that during LogicalPlan optimization, the Snapshot interval can be pushed up to the ScanTableSource.
3. To avoid conflicts with Temporal Join, we should apply TimeTravel transformation rules before apply the Temporal Join transformation rules.
Compatibility, Deprecation, and Migration Plan
- What impact (if any) will there be on existing users?
- If we are changing behavior how will we phase out the older behavior?
- If we need special migration tools, describe them here.
- When will we remove the existing behavior?
Test Plan
Describe in few sentences how the FLIP will be tested. We are mostly interested in system tests (since unit-tests are specific to implementation details). How will we know that the implementation works as expected? How will we know nothing broke?
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 |
---|
SqlSnapshot Snapshot(SqlNode tableRef) :
{
final Span s;
final SqlNode e;
}
{
{ s = span(); } <FOR> <SYSTEM_TIME> <AS> <OF>
// Syntax for temporal table in
// standard SQL 2011 IWD 9075-2:201?(E) 7.6 <table reference>
// supports grammar as following:
// 1. datetime literal
// 2. datetime value function, i.e. CURRENT_TIMESTAMP
// 3. datetime term in 1 or 2 +(or -) interval term
// We extend to support column reference, use Expression
// to simplify the parsing code.
e = Expression(ExprContext.ACCEPT_NON_QUERY) {
return new SqlSnapshot(s.end(this), tableRef, e);
}
} |
Currently , we can't support the following synax.
Code Block |
---|
|
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' |
Code Block |
---|
|
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
If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.