|
1 | 1 | # Materialize + Cube Integration Proof-of-Concept
|
2 | 2 |
|
3 |
| - |
| 3 | + |
4 | 4 |
|
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/) |
6 | 6 |
|
7 | 7 | - **Materialize** is a streaming database that maintains the results of queries incrementally, giving you views of your data that are always up to date.
|
8 | 8 | - **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
|
38 | 38 | psql -h localhost -p 6875 -U materialize -f materialize/create.sql
|
39 | 39 | ```
|
40 | 40 |
|
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) |
42 | 42 | a. Test out building a query with it in the Cube.JS Dev Playground at `localhost:4000`
|
43 | 43 |
|
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 | + ``` |
45 | 77 |
|
46 | 78 | c. You can test the GraphQL API using the dev playground
|
47 | 79 |
|
|
0 commit comments