Skip to content

Commit 90e7f9b

Browse files
author
Andy Hattemer
committed
update
1 parent 42f934e commit 90e7f9b

File tree

3 files changed

+60
-7
lines changed

3 files changed

+60
-7
lines changed

README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Materialize + Cube Integration Proof-of-Concept
22

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

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

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

41-
5. There is a basic cube schema already drafted for a "Vendors" aggregation in `cube/schema/Vendors.js`
41+
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)
4242
a. Test out building a query with it in the Cube.JS Dev Playground at `localhost:4000`
4343

44-
b. Test curling the query to see how the REST API works
44+
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):
45+
```json
46+
{
47+
"measures": [
48+
"Vendors.totalRevenue",
49+
"Vendors.totalOrders",
50+
"Vendors.totalPageviews",
51+
"Vendors.totalItemsSold"
52+
],
53+
"timeDimensions": [],
54+
"order": {
55+
"Vendors.totalRevenue": "desc"
56+
},
57+
"dimensions": [
58+
"Vendors.name"
59+
],
60+
"filters": [
61+
{
62+
"member": "Vendors.id",
63+
"operator": "equals",
64+
"values": [
65+
"24"
66+
]
67+
}
68+
]
69+
}
70+
```
71+
72+
So you can test it via a curl command like:
73+
74+
```
75+
curl localhost:4000/cubejs-api/v1/load -G -s --data-urlencode "query=$(cat example_query.json)" | jq '.data'
76+
```
4577

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

cube/cube.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

example_query.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"measures": [
3+
"Vendors.totalRevenue",
4+
"Vendors.totalOrders",
5+
"Vendors.totalPageviews",
6+
"Vendors.totalItemsSold"
7+
],
8+
"timeDimensions": [],
9+
"order": {
10+
"Vendors.totalRevenue": "desc"
11+
},
12+
"dimensions": [
13+
"Vendors.name"
14+
],
15+
"filters": [
16+
{
17+
"member": "Vendors.id",
18+
"operator": "equals",
19+
"values": [
20+
"24"
21+
]
22+
}
23+
]
24+
}

0 commit comments

Comments
 (0)