8000 docs: Add refresh_cron example for views by peasee · Pull Request #201 · spiceai/cookbook · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

docs: Add refresh_cron example for views #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions views/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,44 @@ SELECT * FROM supplier_order_waits WHERE nation = 'SAUDI ARABIA' LIMIT 10;
Time: 0.005394292 seconds. 10 rows.
```

## Step 5 (optional): Refresh on a defined schedule

Accelerated views support refreshing on a cron schedule.

Stop the Spice Runtime, then update the spicepod to remove the `acceleration.refresh_check_interval` from the view.

Define a new `acceleration.refresh_cron` for the view with a value of `* * * * *` to refresh every minute.

Example view spicepod:

```yaml
views:
- name: supplier_order_waits
acceleration:
enabled: true
refresh_cron: "* * * * *"
engine: duckdb

sql: |
...
```

Start the Spice Runtime, and observe scheduled refreshes:

```bash
spice run
```

Example output:

```bash
2025-05-18T20:20:11.150665Z INFO runtime::datafusion: View supplier_order_waits registered, acceleration (duckdb, 3600s refresh).
2025-05-18T20:20:11.151971Z INFO runtime::accelerated_table::refresh_task: Loading data for view supplier_order_waits
2025-05-18T20:20:12.414223Z INFO runtime::accelerated_table::refresh_task: Loaded 10,000 rows (481.43 kiB) for view supplier_order_waits in 1s 262ms.
2025-05-18T20:21:00.151971Z INFO runtime::accelerated_table::refresh_task: Loading data for view supplier_order_waits
2025-05-18T20:21:01.414223Z INFO runtime::accelerated_table::refresh_task: Loaded 10,000 rows (481.43 kiB) for view supplier_order_waits in 1s 262ms.
```

## Additional Resources

- [Views Documentation](https://spiceai.org/docs/components/views)
0