Getting started with Spice.ai OSS
Follow these steps to get started with Spice.​
Step 1. Install the Spice CLI:
- macOS, Linux, and WSL
- Windows
curl https://install.spiceai.org | /bin/bash
Or using brew
:
brew install spiceai/spiceai/spice
curl -L "https://install.spiceai.org/Install.ps1" -o Install.ps1 && PowerShell -ExecutionPolicy Bypass -File ./Install.ps1
Step 2. Initialize a new Spice app with the spice init
command:
spice init spice_qs
A spicepod.yaml
file is created in the spice_qs
directory. Change to that directory:
cd spice_qs
Step 3. Start the Spice runtime:
spice run
Example output will be shown as follows:
Spice.ai runtime starting...
Using latest 'local' runtime version.
2024-02-21T06:11:56.381793Z INFO runtime::http: Spice Runtime HTTP listening on 127.0.0.1:3000
2024-02-21T06:11:56.381853Z INFO runtime::flight: Spice Runtime Flight listening on 127.0.0.1:50051
2024-02-21T06:11:56.382038Z INFO runtime::opentelemetry: Spice Runtime OpenTelemetry listening on 127.0.0.1:50052
The runtime is now started and ready for queries.
Step 4. In a new terminal window, add the spiceai/quickstart
Spicepod. A Spicepod is a package of configuration defining datasets and ML models.
spice add spiceai/quickstart
The spicepod.yaml
file will be updated with the spiceai/quickstart
dependency.
version: v1beta1
kind: Spicepod
name: PROJECT_NAME
dependencies:
- spiceai/quickstart
The spiceai/quickstart
Spicepod will add a taxi_trips
data table to the runtime which is now available to query by SQL.
2024-02-22T05:53:48.222952Z INFO runtime: Loaded dataset: taxi_trips
2024-02-22T05:53:48.223101Z INFO runtime::dataconnector: Refreshing data for taxi_trips
Step 5. Start the Spice SQL REPL:
spice sql
The SQL REPL inferface will be shown:
Welcome to the interactive Spice.ai SQL Query Utility! Type 'help' for help.
show tables; -- list available tables
sql>
Enter show tables;
to display the available tables for query:
sql> show tables
+------------+
| table_name |
+------------+
| taxi_trips |
+------------+
Query took: 0.007505084 seconds. 1/1 rows displayed.
Enter a query to display the longest taxi trips:
sql> SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;
Output:
+---------------+--------------+
| trip_distance | total_amount |
+---------------+--------------+
| 312722.3 | 22.15 |
| 97793.92 | 36.31 |
| 82015.45 | 21.56 |
| 72975.97 | 20.04 |
| 71752.26 | 49.57 |
| 59282.45 | 33.52 |
| 59076.43 | 23.17 |
| 58298.51 | 18.63 |
| 51619.36 | 24.2 |
| 44018.64 | 52.43 |
+---------------+--------------+
Query took: 0.035694958 seconds. 10/10 rows displayed.
Next Steps​
🔗 Quickstarts
Spice.ai Quickstart Tutorials.
🔗 Samples
Dive deeper with in-depth samples.