Skip to content

Commit

Permalink
docs: Update getting started guide (#6869)
Browse files Browse the repository at this point in the history
* docs: Update getting started guide

* Update docs/content/Getting-Started/Cloud/06-Query-from-React.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/01-Overview.mdx

Co-authored-by: Hassan Khan <[email protected]>

* docs: minor fixes

* Update docs/content/Getting-Started/Cloud/04-Create-data-model.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/02-Load data.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/05-Query-from-BI.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/05-Query-from-BI.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/06-Query-from-React.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/03-Connect-to-Snowflake.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/03-Connect-to-Snowflake.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/03-Connect-to-Snowflake.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/03-Connect-to-Snowflake.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/04-Create-data-model.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/04-Create-data-model.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/04-Create-data-model.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/04-Create-data-model.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/04-Create-data-model.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/04-Create-data-model.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/05-Query-from-BI.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/05-Query-from-BI.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/05-Query-from-BI.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/05-Query-from-BI.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/06-Query-from-React.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/06-Query-from-React.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/06-Query-from-React.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/06-Query-from-React.mdx

Co-authored-by: Hassan Khan <[email protected]>

* Update docs/content/Getting-Started/Cloud/06-Query-from-React.mdx

Co-authored-by: Hassan Khan <[email protected]>

* fix links

* Update docs/content/Getting-Started/Cloud/06-Query-from-React.mdx

Co-authored-by: Hassan Khan <[email protected]>

---------

Co-authored-by: Hassan Khan <[email protected]>
  • Loading branch information
keydunov and hassankhan committed Jul 12, 2023
1 parent 2cc97a1 commit eb9510b
Show file tree
Hide file tree
Showing 10 changed files with 538 additions and 325 deletions.
21 changes: 9 additions & 12 deletions docs/content/Getting-Started/Cloud/01-Overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ subCategory: Cube Cloud
menuOrder: 2
---

First, we'll create a new deployment, connect it to a database, and generate a
data model from it. Then, we'll run queries using the Developer Playground and
APIs. Finally, we'll add a pre-aggregation to optimize query latency down to
milliseconds.
This getting started guide will show you how to use Cube Cloud with Snowflake. You will learn how to:

This guide will walk you through the following tasks:
- Load sample data into your Snowflake account
- Connect Cube Cloud to Snowflake
- Create your first Cube data model
- Connect to a BI tool to explore this model
- Create React application with Cube REST API

- [Create a new deployment](/getting-started/cloud/create-a-deployment)
- [Generate a data model from a connected data source](/getting-started/cloud/generate-models)
- [Run queries using the Developer Playground and APIs](/getting-started/cloud/query-data)
- [Add a pre-aggregation to optimize query performance](/getting-started/cloud/add-a-pre-aggregation)
## Prerequisites

If you'd prefer to run Cube locally, then you can refer to [Getting Started
using Cube Core][ref-getting-started-core-overview] instead.

[ref-getting-started-core-overview]: /getting-started/core/overview
- [Cube Cloud account](https://cubecloud.dev/auth/signup)
- [Snowflake account](https://signup.snowflake.com/)
113 changes: 0 additions & 113 deletions docs/content/Getting-Started/Cloud/02-Create-a-deployment.mdx

This file was deleted.

108 changes: 108 additions & 0 deletions docs/content/Getting-Started/Cloud/02-Load data.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
title: Load data
permalink: /getting-started/cloud/load-data
category: Getting Started
subCategory: Cube Cloud
menuOrder: 2.1
---

The following steps will guide you through setting up a Snowflake account and uploading the demo dataset, which is stored as CSV files in a public S3 bucket.

First, let’s create a warehouse, database, and schema. Paste the following SQL into the Editor of the Snowflake worksheet and click Run.

```sql
CREATE WAREHOUSE cube_demo_wh;
CREATE DATABASE cube_demo;
CREATE SCHEMA cube_demo.ecom;
```

We’re going to create four tables in the `ecom` schema and seed them with data from S3.

First, let’s create `line_items` table. Delete the previous SQL in your Editor and then run the following command.

```sql
CREATE TABLE cube_demo.ecom.line_items
( id INTEGER,
order_id INTEGER,
product_id INTEGER,
price INTEGER,
created_at TIMESTAMP
);
```

Clear all the content in the Editor and run the following command to load data into the `line_items` table.

```
COPY INTO cube_demo.ecom.line_items (id, order_id, product_id, price, created_at)
FROM 's3://cube-tutorial/line_items.csv'
FILE_FORMAT = (TYPE = 'CSV' FIELD_DELIMITER = ',' SKIP_HEADER = 1);
```

Now, we’re going to repeat these steps for three other tables.

Run the following command to create the `orders` table.

```sql
CREATE TABLE cube_demo.ecom.orders
( id INTEGER,
user_id INTEGER,
status VARCHAR,
completed_at TIMESTAMP,
created_at TIMESTAMP
);
```

Run the following command to load data into the `orders` table from S3.

```sql
COPY INTO cube_demo.ecom.orders (id, user_id, status, completed_at, created_at)
FROM 's3://cube-tutorial/orders.csv'
FILE_FORMAT = (TYPE = 'CSV' FIELD_DELIMITER = ',' SKIP_HEADER = 1);

```

Run the following command to create the `users` table.

```sql
CREATE TABLE cube_demo.ecom.users
( id INTEGER,
user_id INTEGER,
city VARCHAR,
age INTEGER,
gender VARCHAR,
state VARCHAR,
first_name VARCHAR,
last_name VARCHAR,
created_at TIMESTAMP
);

```

Run the following command to load data into the `users` table.

```sql
COPY INTO cube_demo.ecom.users (id, city, age, gender, state, first_name, last_name, created_at)
FROM 's3://cube-tutorial/users.csv'
FILE_FORMAT = (TYPE = 'CSV' FIELD_DELIMITER = ',' SKIP_HEADER = 1);

```

Run the following command to create the `products` table.

```sql
CREATE TABLE cube_demo.ecom.products
( id INTEGER,
name VARCHAR,
product_category VARCHAR,
created_at TIMESTAMP
);

```

Run the following command to load data into the `products` table.

```sql
COPY INTO cube_demo.ecom.products (id, name, created_at, product_category)
FROM 's3://cube-tutorial/products.csv'
FILE_FORMAT = (TYPE = 'CSV' FIELD_DELIMITER = ',' SKIP_HEADER = 1);
```
77 changes: 77 additions & 0 deletions docs/content/Getting-Started/Cloud/03-Connect-to-Snowflake.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: Connect to Snowflake
permalink: /getting-started/cloud/connect-to-snowflake
category: Getting Started
subCategory: Cube Cloud
menuOrder: 3
---

In this section, we’ll create a Cube Cloud deployment and connect it to Snowflake.
A deployment represents a data model, configuration, and managed infrastructure.

To continue with this guide, you'll need to have a Cube Cloud account. If you
don't have one yet, [click here to sign up][cube-cloud-signup] for free.

First, [sign in to your Cube Cloud account][cube-cloud-signin]. Then,
click&nbsp;<Btn>Create Deployment</Btn>:

Give the deployment a name, select the cloud provider and region of your choice,
and click <Btn>Next</Btn>:

<Screenshot
alt="Cube Cloud Create Deployment Screen"
src="https://ucarecdn.com/2338323e-0db8-4224-8e7a-3b4daf9c60ec/"
/>

<SuccessBox>

Microsoft Azure is available in Cube Cloud on
[Premium](https://cube.dev/pricing) tier. [Contact us](https://cube.dev/contact)
for details.

</SuccessBox>

## Set up a Cube project

Next, click <Btn>Create</Btn> to create a new project from scratch:

<Screenshot
alt="Cube Cloud Upload Project Screen"
src="https://ucarecdn.com/46b72b61-b650-4271-808d-55203f1c8d8b/"
/>

## Connect to your Snowflake

The last step is to connect Cube Cloud to Snowflake. First, select it from the grid:

<Screenshot
alt="Cube Cloud Setup Database Screen"
src="https://ucarecdn.com/1d656ba9-dd83-4ff4-a59e-8b5f97a9ddcc/"
/>

Then enter your Snowflake credentials:

- **Username:** Your Snowflake username. Please note, it is usually **not** your email address.
- **Password:** Your Snowflake password.
- **Database:** `CUBE_DEMO`, that is the database we've created in the previous step.
- **Account:** Your snowflake account identifier. You can find it in your Snowflake URL as the `account_locator` part.
- **Region:** Your Snowflake account region. You can find it in your Snowflake URL. If your URL includes a `cloud` part, use both the `cloud_region_id` and `cloud` together e.g. `us-east-2.aws`, otherwise just use `cloud_region_id`
- **Warehouse:** `CUBE_DEMO_WH`, that is the warehouse we've created in the previous step.
- **Role:** You can leave it blank.

Click <Btn>Apply</Btn>, Cube Cloud will test the connection and proceed to the next step.

## Generate data model from your Snowflake schema

Cube can now generate a basic data model from your data warehouse schema, which helps getting started with data modeling faster.
Select all four tables in our `ECOM` schema and click through the data model generation wizard. We'll inspect these generated files in the next section and start making changes to them.

[aws-docs-sec-group]:
https://docs.aws.amazon.com/vpc/latest/userguide/security-groups.html
[aws-docs-sec-group-rule]:
https://docs.aws.amazon.com/vpc/latest/userguide/security-group-rules.html
[cube-cloud-signin]: https://cubecloud.dev/auth
[cube-cloud-signup]: https://cubecloud.dev/auth/signup
[ref-conf-db]: /config/databases
[ref-getting-started-cloud-generate-models]:
/getting-started/cloud/generate-models
Loading

0 comments on commit eb9510b

Please sign in to comment.