diff --git a/README.md b/README.md index aa3cdf3..c4ff25e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/cube/cube.js b/cube/cube.js deleted file mode 100644 index 9d41f48..0000000 --- a/cube/cube.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - -}; \ No newline at end of file diff --git a/example_query.json b/example_query.json new file mode 100644 index 0000000..add64d0 --- /dev/null +++ b/example_query.json @@ -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" + ] + } + ] +} \ No newline at end of file