Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SQL statements, add claryfing comments in the Teradata quickstart #6364

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 171 additions & 8 deletions website/docs/guides/teradata-qs.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
email varchar (100)
)
USING (
LOCATION ('/gs/storage.googleapis.com/clearscape_analytics_demo_data/dbt/rawcustomers.csv')
LOCATION ('/gs/storage.googleapis.com/clearscape_analytics_demo_data/dbt/raw_customers.csv')
)
NO PRIMARY INDEX;

Expand Down Expand Up @@ -137,7 +137,43 @@

## Delete the example models

<Snippet path="quickstarts/delete-example-models" />
You can now delete the files that dbt created when you initialized the project:

1. Delete the `models/example/` directory.
2. Delete the `example:` key from your `dbt_project.yml` file, and any configurations that are listed under it.

<File name='dbt_project.yml'>

```yaml
# before
models:
my_new_project:
+materialized: table
example:
+materialized: view
```

</File>

<File name='dbt_project.yml'>

```yaml
# after
models:
my_new_project:
+materialized: table
```

</File>

3. Save your changes.

Check warning on line 169 in website/docs/guides/teradata-qs.md

View workflow job for this annotation

GitHub Actions / Vale linting

[vale] reported by reviewdog 🐶 [custom.UIElements] UI elements like 'Save' should be bold. Raw Output: {"message": "[custom.UIElements] UI elements like 'Save' should be bold.", "location": {"path": "website/docs/guides/teradata-qs.md", "range": {"start": {"line": 169, "column": 4}}}, "severity": "WARNING"}
4. Commit your changes and merge to the main branch.

#### FAQs

Check warning on line 172 in website/docs/guides/teradata-qs.md

View workflow job for this annotation

GitHub Actions / Vale linting

[vale] reported by reviewdog 🐶 [custom.SentenceCaseHeaders] 'FAQs' should use sentence-style capitalization. Try '' instead. Raw Output: {"message": "[custom.SentenceCaseHeaders] 'FAQs' should use sentence-style capitalization. Try '' instead.", "location": {"path": "website/docs/guides/teradata-qs.md", "range": {"start": {"line": 172, "column": 6}}}, "severity": "WARNING"}

<FAQ path="Models/removing-deleted-models" />
<FAQ path="Troubleshooting/unused-model-configurations" />


## Build your first model

Expand Down Expand Up @@ -239,8 +275,6 @@
models:
jaffle_shop:
+materialized: table
example:
+materialized: view
```

</File>
Expand Down Expand Up @@ -359,7 +393,7 @@

from customers

left join customer_orders using (customer_id)
left join customer_orders on customers.customer_id = customer_orders.customer_id

)

Expand Down Expand Up @@ -448,7 +482,136 @@

</div>

<Snippet path="quickstarts/test-and-document-your-project" />
## Add tests to your models

Adding [tests](/docs/build/data-tests) to a project helps validate that your models are working correctly.

To add tests to your project:

1. Create a new YAML file in the `models` directory, named `models/schema.yml`
2. Add the following contents to the file:

<File name='models/schema.yml'>

```yaml
version: 2

models:
- name: bi_customers
columns:
- name: customer_id
tests:
- unique
- not_null

- name: stg_customers
columns:
- name: customer_id
tests:
- unique
- not_null

- name: stg_orders
columns:
- name: order_id
tests:
- unique
- not_null
- name: status
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']
- name: customer_id
tests:
- not_null
- relationships:
to: ref('stg_customers')
field: customer_id

```

</File>

3. Run `dbt test`, and confirm that all your tests passed.

When you run `dbt test`, dbt iterates through your YAML files, and constructs a query for each test. Each query will return the number of records that fail the test. If this number is 0, then the test is successful.

#### FAQs

Check warning on line 539 in website/docs/guides/teradata-qs.md

View workflow job for this annotation

GitHub Actions / Vale linting

[vale] reported by reviewdog 🐶 [custom.SentenceCaseHeaders] 'FAQs' should use sentence-style capitalization. Try '' instead. Raw Output: {"message": "[custom.SentenceCaseHeaders] 'FAQs' should use sentence-style capitalization. Try '' instead.", "location": {"path": "website/docs/guides/teradata-qs.md", "range": {"start": {"line": 539, "column": 6}}}, "severity": "WARNING"}

<FAQ path="Tests/available-tests" alt_header="What tests are available for me to use in dbt? Can I add my own custom tests?" />
<FAQ path="Tests/test-one-model" />
<FAQ path="Runs/failed-tests" />
<FAQ path="Project/schema-yml-name" alt_header="Does my test file need to be named `schema.yml`?" />
<FAQ path="Project/why-version-2" />
<FAQ path="Tests/recommended-tests" />
<FAQ path="Tests/when-to-test" />


## Document your models

Adding [documentation](/docs/build/documentation) to your project allows you to describe your models in rich detail, and share that information with your team. Here, we're going to add some basic documentation to our project.

1. Update your `models/schema.yml` file to include some descriptions, such as those below.

<File name='models/schema.yml'>

```yaml
version: 2

models:
- name: bi_customers
description: One record per customer
columns:
- name: customer_id
description: Primary key
tests:
- unique
- not_null
- name: first_order_date
description: NULL when a customer has not yet placed an order.

- name: stg_customers
description: This model cleans up customer data
columns:
- name: customer_id
description: Primary key
tests:
- unique
- not_null

- name: stg_orders
description: This model cleans up order data
columns:
- name: order_id
description: Primary key
tests:
- unique
- not_null
- name: status
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']
- name: customer_id
tests:
- not_null
- relationships:
to: ref('stg_customers')
field: customer_id
```

</File>

2. Run `dbt docs generate` to generate the documentation for your project. dbt introspects your project and your warehouse to generate a <Term id="json" /> file with rich documentation about your project.


3. Click the book icon in the Develop interface to launch documentation in a new tab.

#### FAQs

Check warning on line 609 in website/docs/guides/teradata-qs.md

View workflow job for this annotation

GitHub Actions / Vale linting

[vale] reported by reviewdog 🐶 [custom.SentenceCaseHeaders] 'FAQs' should use sentence-style capitalization. Try '' instead. Raw Output: {"message": "[custom.SentenceCaseHeaders] 'FAQs' should use sentence-style capitalization. Try '' instead.", "location": {"path": "website/docs/guides/teradata-qs.md", "range": {"start": {"line": 609, "column": 6}}}, "severity": "WARNING"}

<FAQ path="Docs/long-descriptions" />
<FAQ path="Docs/sharing-documentation" />



## Commit your changes

Expand Down Expand Up @@ -478,7 +641,7 @@
2. Click **Create Environment**.
3. In the **Name** field, write the name of your deployment environment. For example, "Production."
4. In the **dbt Version** field, select the latest version from the dropdown.
5. Under **Deployment connection**, enter the name of the dataset you want to use as the target, such as "Analytics". This will allow dbt to build and work with that dataset. For some data warehouses, the target dataset may be referred to as a "schema".
5. Under **Deployment connection**, enter the name of the dataset you want to use as the target, such as `jaffle_shop_prod`. This will allow dbt to build and work with that dataset.
6. Click **Save**.

### Create and run a job
Expand All @@ -488,7 +651,7 @@
As the `jaffle_shop` business gains more customers, and those customers create more orders, you will see more records added to your source data. Because you materialized the `bi_customers` model as a table, you'll need to periodically rebuild your table to ensure that the data stays up-to-date. This update will happen when you run a job.

1. After creating your deployment environment, you should be directed to the page for a new environment. If not, select **Deploy** in the upper left, then click **Jobs**.
2. Click **Create one** and provide a name, for example, "Production run", and link to the Environment you just created.
2. Click **+ Create job** and then select **Deploy job**. Provide a name, for example, "Production run", and link it to the Environment you just created.
3. Scroll down to the **Execution Settings** section.
4. Under **Commands**, add this command as part of your job if you don't see it:
* `dbt build`
Expand Down
Loading