-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding MSSQL quickstart * Fixing capitalization * Making secret name more consistent * Making `.env` consistent across all quickstarts * Removing AI model * Improving MSSQL quickstart * Removing extra newline * Modifying MSSQL quickstart to be simpler * Updating query and expected results
- Loading branch information
Showing
7 changed files
with
138 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.DS_Store | ||
acceleration/indexes/large_eth_traces.parquet | ||
acceleration/indexes/spicepod.yaml | ||
.env | ||
.env.local |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SPICE_MSSQL_CONNECTION_STRING1="Server=tcp:localhost,11433;Initial Catalog=AdventureWorks;Persist Security Info=False;User ID=sa;Password=Password123@;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;" | ||
SPICE_MSSQL_CONNECTION_STRING2="Server=tcp:localhost,11533;Initial Catalog=AdventureWorks;Persist Security Info=False;User ID=sa;Password=Password123@;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# MSSQL Connector Quickstart | ||
|
||
This quickstart is meant to get you up and running with Spice's MSSQL data connector. It runs two instances of MSSQL server: 2019 and 2022. Both | ||
instances are accessible from within Spice to demonstrate that you can query across multiple servers. | ||
|
||
## Pre-requisites | ||
|
||
- Spice is installed (see the [Getting Started](https://docs.spiceai.org/getting-started) documentation). | ||
- Docker running on your system | ||
|
||
## Steps | ||
|
||
1. Start the MSSQL instances using `docker compose up -d`. In a production scenario you'd want to use [secrets](https://docs.spiceai.org/components/secret-stores) to protect your secrets | ||
2. Start up Spice using `spice run` | ||
3. In another shell, fire up the Spice SQL REPL using `spice sql` | ||
|
||
## Example Queries | ||
|
||
### Verify that the row counts in the 2019 server matches the 2022 server | ||
|
||
```sql | ||
SELECT | ||
count_2019, | ||
count_2022, | ||
count_2019=count_2022 AS equal | ||
FROM ( | ||
SELECT | ||
COUNT(*) AS count_2019, | ||
MAX(count_2022) AS count_2022 | ||
FROM Sales.Customer | ||
JOIN ( | ||
SELECT | ||
COUNT(*) AS count_2022 | ||
FROM Sales.Customer2022 | ||
) ON 1=1 | ||
) | ||
``` | ||
|
||
Output: | ||
|
||
```shell | ||
+------------+------------+-------+ | ||
| count_2019 | count_2022 | equal | | ||
+------------+------------+-------+ | ||
| 19820 | 19820 | true | | ||
+------------+------------+-------+ | ||
``` | ||
|
||
### Order information per customer | ||
|
||
```sql | ||
SELECT c."CustomerID", | ||
MAX(CAST("OrderDate" AS DATE)) AS LatestOrderDate, | ||
ROUND(AVG("TotalDue"), 2) AS AverageOrderValue, | ||
COUNT("SalesOrderID") AS TotalNumberOfOrders | ||
FROM Sales.Customer c | ||
LEFT OUTER JOIN Sales.SalesOrderHeader soh | ||
ON c."CustomerID" = soh."CustomerID" | ||
GROUP BY c."CustomerID" | ||
ORDER BY TotalNumberOfOrders DESC | ||
LIMIT 10 | ||
``` | ||
|
||
Output: | ||
|
||
```shell | ||
+------------+-----------------+-------------------+---------------------+ | ||
| CustomerID | latestorderdate | averageordervalue | totalnumberoforders | | ||
+------------+-----------------+-------------------+---------------------+ | ||
| 11176 | 2014-06-29 | 52.09 | 28 | | ||
| 11091 | 2014-06-10 | 46.94 | 28 | | ||
| 11330 | 2014-06-24 | 46.51 | 27 | | ||
| 11300 | 2014-06-02 | 61.41 | 27 | | ||
| 11711 | 2014-06-28 | 45.17 | 27 | | ||
| 11331 | 2014-06-26 | 54.4 | 27 | | ||
| 11287 | 2014-06-30 | 47.76 | 27 | | ||
| 11185 | 2014-06-28 | 66.15 | 27 | | ||
| 11276 | 2014-06-24 | 40.45 | 27 | | ||
| 11200 | 2014-06-22 | 59.89 | 27 | | ||
+------------+-----------------+-------------------+---------------------+ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
services: | ||
mssql1: | ||
image: "slyons/adventureworks:latest-2019" | ||
environment: | ||
- ACCEPT_EULA=Y | ||
- SA_PASSWORD=Password123@ | ||
restart: unless-stopped | ||
ports: | ||
- "11433:1433" | ||
healthcheck: | ||
test: [ "CMD", "./ready.sh"] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 5 | ||
mssql2: | ||
image: "slyons/adventureworks:latest-2022" | ||
environment: | ||
- ACCEPT_EULA=Y | ||
- SA_PASSWORD=Password123@ | ||
restart: unless-stopped | ||
ports: | ||
- "11533:1433" | ||
healthcheck: | ||
test: [ "CMD", "./ready.sh"] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: v1beta1 | ||
kind: Spicepod | ||
name: spicepod-mssql | ||
|
||
datasets: | ||
- from: mssql:Sales.Customer | ||
name: Sales.Customer | ||
params: | ||
mssql_connection_string: ${ secrets:SPICE_MSSQL_CONNECTION_STRING1 } | ||
acceleration: | ||
enabled: true | ||
|
||
- from: mssql:Sales.Customer | ||
name: Sales.Customer2022 | ||
params: | ||
mssql_connection_string: ${ secrets:SPICE_MSSQL_CONNECTION_STRING2 } | ||
acceleration: | ||
enabled: true | ||
|
||
- from: mssql:Sales.SalesOrderHeader | ||
name: Sales.SalesOrderHeader | ||
params: | ||
mssql_connection_string: ${ secrets:SPICE_MSSQL_CONNECTION_STRING2 } | ||
acceleration: | ||
enabled: true |