Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Hattemer committed May 19, 2022
1 parent 42f934e commit 90e7f9b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
40 changes: 36 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Materialize + Cube Integration Proof-of-Concept

![image](https://user-images.githubusercontent.com/11527560/168118268-7e5531aa-ce9c-4300-8aef-61ae6faa373e.png)
![image](https://user-images.githubusercontent.com/11527560/169356685-8c846ba5-90eb-4472-9e03-46e43bed6003.png)

This is a quick proof-of-concept of how [Cube](https://cube.dev/) integrates with [Materialize]()
This is a quick proof-of-concept of how [Cube](https://cube.dev/) integrates with [Materialize](https://materialize.com/)

- **Materialize** is a streaming database that maintains the results of queries incrementally, giving you views of your data that are always up to date.
- **Cube** is a "headless BI" service that connects to databases or data warehouses and handles Data Modeling, Access Control, Caching and APIs
Expand Down Expand Up @@ -38,10 +38,42 @@ You'll need to have [docker and docker-compose installed](https://materialize.co
psql -h localhost -p 6875 -U materialize -f materialize/create.sql
```

5. There is a basic cube schema already drafted for a "Vendors" aggregation in `cube/schema/Vendors.js`
5. There is a basic cube schema already drafted for a "Vendors" aggregation in [`cube/schema/Vendors.js`](https://github.com/ruf-io/materialize-cube-demo/blob/main/cube/schema/Vendors.js)
a. Test out building a query with it in the Cube.JS Dev Playground at `localhost:4000`

b. Test curling the query to see how the REST API works
b. Test curling the query to see how the REST API works, the REST API uses a JSON schema that is demonstrated in the UI (see JSON Query tab):
```json
{
"measures": [
"Vendors.totalRevenue",
"Vendors.totalOrders",
"Vendors.totalPageviews",
"Vendors.totalItemsSold"
],
"timeDimensions": [],
"order": {
"Vendors.totalRevenue": "desc"
},
"dimensions": [
"Vendors.name"
],
"filters": [
{
"member": "Vendors.id",
"operator": "equals",
"values": [
"24"
]
}
]
}
```

So you can test it via a curl command like:

```
curl localhost:4000/cubejs-api/v1/load -G -s --data-urlencode "query=$(cat example_query.json)" | jq '.data'
```

c. You can test the GraphQL API using the dev playground

Expand Down
3 changes: 0 additions & 3 deletions cube/cube.js

This file was deleted.

24 changes: 24 additions & 0 deletions example_query.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"measures": [
"Vendors.totalRevenue",
"Vendors.totalOrders",
"Vendors.totalPageviews",
"Vendors.totalItemsSold"
],
"timeDimensions": [],
"order": {
"Vendors.totalRevenue": "desc"
},
"dimensions": [
"Vendors.name"
],
"filters": [
{
"member": "Vendors.id",
"operator": "equals",
"values": [
"24"
]
}
]
}

0 comments on commit 90e7f9b

Please sign in to comment.