Skip to content

Commit 7943e94

Browse files
Docs: Add information on how to read from branches and tags in Spark query docs (apache#6573)
1 parent c05bde8 commit 7943e94

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/spark-queries.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ To select a specific table snapshot or the snapshot at some time in the DataFram
126126

127127
* `snapshot-id` selects a specific table snapshot
128128
* `as-of-timestamp` selects the current snapshot at a timestamp, in milliseconds
129+
* `branch` selects the head snapshot of the specified branch. Note that currently branch cannot be combined with as-of-timestamp.
130+
* `tag` selects the snapshot associated with the specified tag
129131

130132
```scala
131133
// time travel to October 26, 1986 at 01:21:00
@@ -143,6 +145,22 @@ spark.read
143145
.load("path/to/table")
144146
```
145147

148+
```scala
149+
// time travel to tag historical-snapshot
150+
spark.read
151+
.option(SparkReadOptions.TAG, "historical-snapshot")
152+
.format("iceberg")
153+
.load("path/to/table")
154+
```
155+
156+
```scala
157+
// time travel to the head snapshot of audit-branch
158+
spark.read
159+
.option(SparkReadOptions.BRANCH, "audit-branch")
160+
.format("iceberg")
161+
.load("path/to/table")
162+
```
163+
146164
{{< hint info >}}
147165
Spark 3.0 and earlier versions do not support using `option` with `table` in DataFrameReader commands. All options will be silently
148166
ignored. Do not use `table` when attempting to time-travel or use other options. See [SPARK-32592](https://issues.apache.org/jira/browse/SPARK-32592).

0 commit comments

Comments
 (0)