Snapshots and Time Travel

run(ctx, spark, "SELECT * FROM hms.db.orders.history ORDER BY made_current_at")
+-----------------------+-------------------+-------------------+-------------------+
|made_current_at        |snapshot_id        |parent_id          |is_current_ancestor|
+-----------------------+-------------------+-------------------+-------------------+
|2026-08-23 12:39:51.065|1938319986946564586|NULL               |true               |
|2026-08-23 12:39:51.287|759497885138563489 |1938319986946564586|true               |
|2026-08-23 12:39:52.021|6239830616431609416|759497885138563489 |true               |
+-----------------------+-------------------+-------------------+-------------------+

Three rows, one per data commit — the CREATE TABLE never appears here, because history tracks snapshots and DDL does not make one. Note the sub-second gaps: three commits inside a single second, which is exactly the interleaving the Lab: two writers, one table part exploits.

Grab the very first snapshot ID in Go and query the table as it looked right after the first commit — before the From a Go struct slice, the way a real ingestion job would section's Go-struct insert and the INSERT INTO ... SELECT, the way a real ETL step reads from one table into another section's staging-table insert ever happened:

df, err := spark.Sql(ctx, `
SELECT snapshot_id FROM hms.db.orders.history
ORDER BY made_current_at LIMIT 1`)
if err != nil {
	log.Fatal(err)
}
rows, err := df.Collect(ctx)
if err != nil {
	log.Fatal(err)
}
firstSnapshotID := rows[0].Value("snapshot_id").(int64) // types.Row.Value, per §4

run(ctx, spark, fmt.Sprintf(
	"SELECT * FROM hms.db.orders VERSION AS OF %v ORDER BY order_id", firstSnapshotID))
+--------+-----------+-------------------+------+---------+-------+
|order_id|customer_id|order_ts           |amount|status   |country|
+--------+-----------+-------------------+------+---------+-------+
|1001    |501        |2026-01-15 09:12:00|129.99|COMPLETED|US     |
|1002    |502        |2026-01-15 14:45:00|59.50 |COMPLETED|CA     |
|1003    |501        |2026-01-16 08:03:00|249.00|PENDING  |US     |
|1004    |503        |2026-01-16 19:30:00|15.25 |COMPLETED|UK     |
+--------+-----------+-------------------+------+---------+-------+

Four rows — exactly the Literal INSERT ... VALUES batch, nothing from the From a Go struct slice, the way a real ingestion job would section or INSERT INTO ... SELECT, the way a real ETL step reads from one table into another. TIMESTAMP AS OF answers the same question phrased differently, by wall-clock time instead of snapshot ID:

run(ctx, spark, `
SELECT count(*) FROM hms.db.orders
TIMESTAMP AS OF '2026-08-16 09:41:11'`)

And a real rollback — not a read-only query, an actual write that changes what current-snapshot-id points to, appending a new entry to snapshot-log without touching the snapshots DAG at all (exactly the distinction the main guide's self-test Q7 draws):

run(ctx, spark, fmt.Sprintf(
	"CALL hms.system.rollback_to_snapshot('db.orders', %v)", firstSnapshotID))