TIME TRAVEL (AT / BEFORE / FOR SYSTEM_TIME AS OF)
Feb 23, 2026
·
5
min read
Category: Time Travel & Versioning
Platform Support:
✅ Snowflake (AT, BEFORE) | ✅ BigQuery (FOR SYSTEM_TIME AS OF) | ✅ Databricks (VERSION AS OF, TIMESTAMP AS OF)
Description
Query historical data at a specific point in time or version. Allows accessing previous states of tables for auditing, recovery, and temporal analysis. Each platform implements time travel differently but achieves similar goals.
Syntax by Platform
Snowflake:
BigQuery:
Databricks (Delta Lake):
Platform-Specific Notes
Snowflake:
Retention: 1 day (Standard), up to 90 days (Enterprise)
Can query by timestamp, offset, or statement ID
UNDROP TABLE to recover dropped tables
Time Travel works on all table types
No additional cost for Time Travel storage
BigQuery:
Retention: 7 days automatically
FOR SYSTEM_TIME AS OF clause
Works with both partitioned and non-partitioned tables
No additional storage cost for Time Travel
Cannot query beyond 7-day window
Databricks:
Requires Delta Lake format
Retention: 30 days default (configurable)
Can query by version number or timestamp
DESCRIBE HISTORY to see available versions
Version numbers increment with each write operation
Example 1: Query Historical Data
Snowflake:
BigQuery:
Databricks:
Current products table (2024-01-20):
product_id | product_name | price | last_updated |
|---|---|---|---|
1 | Laptop | 899.99 | 2024-01-20 |
2 | Mouse | 24.99 | 2024-01-19 |
3 | Keyboard | 89.99 | 2024-01-20 |
Historical products table (2024-01-19):
product_id | product_name | price | last_updated |
|---|---|---|---|
1 | Laptop | 999.99 | 2024-01-15 |
2 | Mouse | 29.99 | 2024-01-10 |
3 | Keyboard | 89.99 | 2024-01-18 |
Example 2: Compare Current vs Historical
Snowflake:
BigQuery:
Databricks:
Result:
product_id | product_name | current_price | price_yesterday | price_change | pct_change |
|---|---|---|---|---|---|
1 | Laptop | 899.99 | 999.99 | -100.00 | -10.00 |
2 | Mouse | 24.99 | 29.99 | -5.00 | -16.67 |
Example 3: Recover Accidentally Deleted Data
Snowflake:
BigQuery:
Databricks:
Example 4: Audit Trail Analysis
Snowflake:
Result shows all state changes:
check_time | customer_id | status | tier | |
|---|---|---|---|---|
2024-01-13 10:00 | 12345 | Active | Standard | |
2024-01-13 11:00 | 12345 | Active | Standard | |
2024-01-15 14:00 | 12345 | Active | Standard | |
2024-01-17 09:00 | 12345 | Active | Premium |
Example 5: Version History (Databricks)
Databricks:
Example 6: Temporal Joins
All Platforms:
Time Travel Retention Comparison
Platform | Default Retention | Maximum Retention | Cost |
|---|---|---|---|
Snowflake | 1 day (Standard) | 90 days (Enterprise) | Included |
BigQuery | 7 days | 7 days | Included |
Databricks | 30 days | Configurable | Storage cost |
Common Use Cases
Data recovery: Restore accidentally deleted/modified data
Auditing: Track changes over time
Debugging: Investigate data quality issues
Regulatory compliance: Maintain historical records
A/B testing: Compare before/after states
Temporal analysis: Understand data evolution
Rollback: Undo unwanted changes
Best Practices
Document retention periods: Know your platform's limits
Test recovery procedures: Practice before you need it
Use for auditing: Track important changes
Monitor Time Travel queries: Can be expensive
Consider long-term archival: Beyond Time Travel retention
Snapshot important changes: CREATE TABLE AS SELECT for backups
Log query IDs: For Snowflake BEFORE(STATEMENT)
Set retention appropriately: Balance cost vs needs (Databricks)
Limitations
Snowflake: Cannot query beyond retention period
BigQuery: Fixed 7-day limit
Databricks: Requires Delta Lake format
All: Performance may degrade for very old timestamps
All: Time Travel doesn't replace backup strategy





