luoyuxia commented on code in PR #23109: URL: https://github.com/apache/flink/pull/23109#discussion_r1308392512
########## docs/content/docs/dev/table/sql/queries/time-travel.md: ########## @@ -0,0 +1,77 @@ +--- +title: Time Travel +weight: 18 +type: docs +--- +<!-- +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 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +# Time Travel + +{{< label Batch >}} {{< label Streaming >}} + +`Time travel` is a SQL syntax used for querying historical data. It allows users to specify a point in time and query the corresponding table data. +<span class="label label-danger">Attention</span> Currently, `time travel` requires the corresponding catalog that the table belongs to implements the {{< gh_link file="flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/Catalog.java" name="getTable(ObjectPath tablePath, long timestamp)" >}} method. + +The `timestamp_expression` represents the historical point in time you're interested in. This can be a specific timestamp or an expression related to time, such as relative time or a function. + +```sql +SELECT select_list FROM table_name FOR SYSTEM_TIME AS OF timestamp_expression +``` + +**Parameter Specification:** + +- `FOR SYSTEM_TIME AS OF timestamp_expression`:Used to query data before a specific time point, this expression can only be applied to physical tables and not views or subqueries. + +## Limitation + +<span class="label label-danger">Attention</span> The time expressions used in `time travel` only support `TIMESTAMP` constant expressions, `TIMESTAMP` addition and subtraction operations, as well as some built-in functions and UDFs. + +### Constant Expression Review Comment: I feel like `Constant Expression` & `Constant Expression Addition and Subtraction` & `Time Function or UDF (Partial Supported)` is a little of confused in here. The structure is not intuitive. Considering actually `TIMESTAMP '2023-07-31 00:00:00' - INTERVAL '1' DAY` is a udf expression, I'd like put all of into an `Example` part like ```sql #use constant expression SELECT select_list FROM paimon_tb FOR SYSTEM_TIME AS OF TIMESTAMP '2023-07-31 00:00:00' # use expression with udfs that can be reduced to constant SELECT select_list FROM paimon_tb FOR SYSTEM_TIME AS OF TIMESTAMP '2023-07-31 00:00:00' - INTERVAL '1' DAY ``` I mean add an `Example` part and then remove `Constant Expression` & `Constant Expression Addition and Subtraction` & `Time Function or UDF (Partial Supported)`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org