Skip to content

Commit

Permalink
Merge current branch into next (#1739)
Browse files Browse the repository at this point in the history
* Update gitignore.md

updated typo

* Update which-jinja-docs.md

* Update change-billing.md

removed image which was errroring out

* Update payment-accepted.md

updated formatting as it was formatted incorrectly in the live site

* Update managed-repo.md

updated spacing

* Update which-jinja-docs.md

updated broken links

* Update create-dependencies.md

updated broken link

* Update run-downtime.md

updated links

* Update example-projects.md

updated getting started guide link

* Update why-version-2.md

updated sidebar capitalization

* Update checking-logs.md

added capitalization

* Update failed-prod-run.md

added capitalization

* Update failed-tests.md

added capitalization

* Update run-downstream-of-seed.md

added capitalization

* Update run-one-model.md

added capitalization

* Update run-one-snapshot.md

added capitalization

* Update running-models-downstream-of-source.md

added capitalization

* Update snapshot-frequency.md

added capitalization

* Update leading-zeros-in-seed.md

added capitalization

* add content

* add content

* add content

* Update website/blog/2022-06-30-extract-sql-function.md

Co-authored-by: Kira Furuichi <[email protected]>

* add content

* add content

* Update dimensional-modeling.md

* Update website/docs/faqs/Git/managed-repo.md

committing Leona's suggestion

Co-authored-by: Leona B. Campbell <[email protected]>

* Update website/docs/faqs/Jinja/which-jinja-docs.md

committing Leona's suggestion

Co-authored-by: Leona B. Campbell <[email protected]>

* Update website/docs/faqs/Models/create-dependencies.md

committing Leona's suggestion

Co-authored-by: Leona B. Campbell <[email protected]>

* Update website/docs/faqs/Models/run-downtime.md

committing Leona's suggestion

Co-authored-by: Leona B. Campbell <[email protected]>

* Update website/docs/faqs/Project/example-projects.md

committing Leona's suggestion

Co-authored-by: Leona B. Campbell <[email protected]>

* Fix typo in dbt tests documentation page

* Update run-downtime.md

* Update slack.md

* Add content

* add content

* Update 2022-07-05-datediff-sql-love-letter.md

* add content

* small grammar fix

* changes to include expression metrics

* Fix all broken links in docs subfolder

* Fix blog post broken links

* fixes!

* Remove unused tag item from blog sidebar

* Update redirect

* Fix best practice link

* updating for link

* Update Oracle profile
- New python driver `python-oracledb` related changes which vastly simplifies dbt-oracle installation
- Wallet Configuration is explained in a better manner for 1-way TLS and m-TLS
- Content organization

* Update website/docs/docs/building-a-dbt-project/metrics.md

Co-authored-by: Jeremy Cohen <[email protected]>

* updating wording in metrics

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* reflecting changes in upgrade doc

* Add bold record to data change tables

* Update website/docs/terms/data-warehouse.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/docs/terms/data-warehouse.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/docs/terms/data-warehouse.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/docs/terms/data-warehouse.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-06-30-lower-sql-function.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-06-30-lower-sql-function.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-06-30-lower-sql-function.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-06-30-lower-sql-function.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-06-30-lower-sql-function.md

Co-authored-by: Kira Furuichi <[email protected]>

* Add links

* Update website/blog/2022-06-30-lower-sql-function.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update 2022-06-30-lower-sql-function.md

* Update website/blog/2022-06-30-extract-sql-function.md

Co-authored-by: Kira Furuichi <[email protected]>

* URL slug change

* Update website/blog/2022-06-30-coalesce-sql.md

Co-authored-by: Kira Furuichi <[email protected]>

* Apply suggestions from code review

Co-authored-by: Kira Furuichi <[email protected]>

* Add links

* Apply suggestions from code review

Co-authored-by: Kira Furuichi <[email protected]>

* Add strikethrough

* small syntax fixes

* Fix hyperlink

* Update website/docs/terms/data-warehouse.md

Co-authored-by: Kira Furuichi <[email protected]>

* Apply suggestions from code review

Co-authored-by: Kira Furuichi <[email protected]>

* updating docs

* fixing conflict

* Add updated redirects

* Fix jinja links

* Fix conflicts

* Update jinja reference redirect

* Add links

* Update website/blog/2022-06-30-extract-sql-function.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-06-30-extract-sql-function.md

Co-authored-by: Kira Furuichi <[email protected]>

* Add truncate

* Update website/blog/2022-06-30-coalesce-sql.md

Co-authored-by: Kira Furuichi <[email protected]>

* Shorten reading list

* Update website/blog/2022-07-05-datediff-sql-love-letter.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-07-05-datediff-sql-love-letter.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-07-05-datediff-sql-love-letter.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-07-05-datediff-sql-love-letter.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-07-05-date-trunc-sql-love-letter.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-07-05-date-trunc-sql-love-letter.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-07-05-date-trunc-sql-love-letter.md

Co-authored-by: Kira Furuichi <[email protected]>

* Set featured to true

* Apply suggestions from code review

Co-authored-by: Kira Furuichi <[email protected]>

* https://github.com/dbt-labs/dbt-core/discussions/5468

* Up[date redirects

* Replace two more migration redirects

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture-metrics.md

Co-authored-by: Grace Goheen <[email protected]>

* remove images

* Update revenue-meme.png

* Update revenue-meme.png

* Update revenue-meme.png

* Update redirect

* Update website/blog/2022-07-12-change-data-capture-metrics.md

* Changes in response to review comments
- Changed the phrase one-way TLS to simply TLS
- Included link to official ADB documentation for wallet less TLS connection
- Changed service names to example service names
- Changed the ordering of connection methods. The ordering is TNS Alias, Connect String and Database hostname

* Update website/docs/guides/migration/versions/06-upgrading-to-v1.2.md

Co-authored-by: Jeremy Cohen <[email protected]>

* update for correctness and simplicities sake

* Update release date

* remove next.docs redirect

* remove extra properties

* Update redirects

* Add redirects back

* Update website/blog/2022-07-05-datediff-sql-love-letter.md

Co-authored-by: Kira Furuichi <[email protected]>

* Update 2022-07-05-datediff-sql-love-letter.md

* add git action to merge current branch into next

* Add wildcard for migration guides

* Add back specific redirects

* v1.2 docs omnibus (#1698)

* Add itertools module #1368

* Manifest v6 #1667

* Add set + zip #1635

* File selector method #1627

* Selector inheritance #1628

* Global config for target-path, log-path #1687

* Update website/docs/reference/dbt-jinja-functions/zip.md

Co-authored-by: Anders <[email protected]>

* Update website/docs/reference/dbt-jinja-functions/set.md

Co-authored-by: Anders <[email protected]>

* PR feedback

Co-authored-by: Anders <[email protected]>

* Update to `grants` documentation (#1707)

* Update docs on hooks re grants

* Update BQ language, link to docs

* Configuring grants, inheritance, reorg

* PR feedback

* Apply correct redirects for older versions

* Update snowflake-configs.md

In researching the use of time travel with dbt, I found the documentation to be mis-leading and thought I needed to change my dbt configuration. The comment that transient tables do not participate in time travel is not correct. Per Snowflake's documentation, Transient tables persist until they are dropped and the time travel default is 1 day and transient tables do not participate in fail safe.

* add content

* add links

* Add links

* Fix note

* Fix notes

* language tweaks

* Update website/blog/2022-07-13-star-sql-love-letter.md

Co-authored-by: Kira Furuichi <[email protected]>

* Apply suggestions from code review

Co-authored-by: Kira Furuichi <[email protected]>

* Update website/blog/2022-07-12-change-data-capture.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture.md

Co-authored-by: Grace Goheen <[email protected]>

* Update website/blog/2022-07-12-change-data-capture.md

Co-authored-by: Grace Goheen <[email protected]>

* swap meme

* swap revenue for income

* Update website/docs/faqs/Accounts/change-billing.md

* Update website/docs/faqs/Accounts/change-billing.md

* Update git-revlist-error.md

* Update change-billing.md

* fix typo

`Coree` -> `Core`

* Update 06-upgrading-to-v1.2.md

* updates to SQL magic posts

minor updates to SQL magic posts

* stagger publish dates in past

- datediff + date_trunc must be after 7/13 (v1.2 updates)
- put all others in the past
- add a feature flag to one of them

* Remove out-of-date information from Azure AD docs (#1350)

Co-authored-by: Leona B. Campbell <[email protected]>

* Add redirects for /guides/legacy/ (#1643)

* Add redirects for guides

* Update _redirects

Co-authored-by: Leona B. Campbell <[email protected]>

Co-authored-by: mirnawong1 <[email protected]>
Co-authored-by: johnblust <[email protected]>
Co-authored-by: Kira Furuichi <[email protected]>
Co-authored-by: Leona B. Campbell <[email protected]>
Co-authored-by: 8vicat <[email protected]>
Co-authored-by: Callum McCann <[email protected]>
Co-authored-by: john-rock <[email protected]>
Co-authored-by: Anders <[email protected]>
Co-authored-by: Abhishek Singh <[email protected]>
Co-authored-by: Callum McCann <[email protected]>
Co-authored-by: Jeremy Cohen <[email protected]>
Co-authored-by: Grace Goheen <[email protected]>
Co-authored-by: Anders Swanson <[email protected]>
Co-authored-by: John Rock <[email protected]>
Co-authored-by: Jason Karlavige <[email protected]>
Co-authored-by: Beaulieuj <[email protected]>
Co-authored-by: Jason Ganz <[email protected]>
Co-authored-by: Jason Ganz <[email protected]>
Co-authored-by: Amy Chen <[email protected]>
Co-authored-by: Pat Kearns <[email protected]>
Co-authored-by: Brian Jan <[email protected]>
Co-authored-by: Ly Nguyen <[email protected]>
  • Loading branch information
23 people authored Jul 19, 2022
1 parent 914fec5 commit 30de147
Show file tree
Hide file tree
Showing 13 changed files with 213 additions and 44 deletions.
36 changes: 22 additions & 14 deletions _redirects
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
/docs/api-variable /docs/writing-code-in-dbt/api-variable 302
/docs/archival /docs/building-a-dbt-project/archival 302
/docs/artifacts /docs/dbt-cloud/using-dbt-cloud/artifacts 302
/docs/best-practices /guides/best-practices 302
/docs/guides/best-practices /guides/best-practices 302
/docs/bigquery-configs /reference/resource-configs/bigquery-configs 302
/docs/building-a-dbt-project/building-models/bigquery-configs /reference/resource-configs/bigquery-configs 302
/docs/building-a-dbt-project/building-models/configuring-models /reference/model-configs
Expand All @@ -39,7 +37,7 @@
/docs/building-a-dbt-project/using-operations /docs/building-a-dbt-project/hooks-operations 302
/docs/building-a-new-adapter /docs/contributing/building-a-new-adapter 302
/docs/building-models /docs/building-a-dbt-project/building-models 302
/docs/building-packages /docs/guides/building-packages 302
/docs/building-packages /guides/legacy/building-packages 302
/docs/centos /dbt-cli/installation 302
/docs/clean /reference/commands/clean 302
/docs/cloud-choosing-a-dbt-version /docs/dbt-cloud/cloud-configuring-dbt-cloud/cloud-choosing-a-dbt-version 302
Expand Down Expand Up @@ -70,8 +68,8 @@
/docs/connecting-your-database /docs/dbt-cloud/cloud-configuring-dbt-cloud/connecting-your-database 302
/docs/contributor-license-agreements /docs/contributing/contributor-license-agreements 302
/docs/creating-a-project /docs/building-a-dbt-project/dbt-projects/creating-a-project 302
/docs/creating-new-materializations /docs/guides/creating-new-materializations 302
/docs/custom-schema-tests /docs/guides/writing-custom-schema-tests 302
/docs/creating-new-materializations /guides/legacy/creating-new-materializations 302
/docs/custom-schema-tests /guides/legacy/writing-custom-generic-tests 302
/docs/dbt-api /docs/running-a-dbt-project/dbt-api 302
/docs/dbt-cloud-enterprise /docs/dbt-cloud/dbt-cloud-enterprise 302
/docs/dbt-cloud/cloud-configuring-repositories /docs/dbt-cloud/cloud-configuring-dbt-cloud/cloud-configuring-repositories 302
Expand All @@ -97,10 +95,21 @@
/docs/getting-started-with-jinja /docs/building-a-dbt-project/jinja-macros 302
/docs/global-cli-flags /reference/global-cli-flags 302
/docs/graph /docs/writing-code-in-dbt/jinja-context/graph 302
/docs/guides/writing-custom-schema-tests /docs/guides/writing-custom-generic-tests
/docs/guides/best-practices /guides/best-practices
/docs/guides/best-practices#choose-your-materializations-wisely /guides/best-practices 302
/docs/guides/best-practices#version-control-your-dbt-project /guides/legacy/best-practices#version-control-your-dbt-project 302
/docs/guides/building-packages /guides/legacy/building-packages 302
/docs/guides/creating-new-materializations /guides/legacy/creating-new-materializations 302
/docs/guides/debugging-errors /guides/legacy/debugging-errors 302
/docs/guides/debugging-schema-names /guides/legacy/debugging-schema-names 302
/docs/guides/getting-help /guides/legacy/getting-help 302
/docs/guides/managing-environments /guides/legacy/managing-environments 302
/docs/guides/navigating-the-docs /guides/legacy/navigating-the-docs 302
/docs/guides/understanding-state /guides/legacy/understanding-state 302
/docs/guides/videos /guides/legacy/videos 302
/docs/guides/writing-custom-generic-tests /guides/legacy/writing-custom-generic-tests 302
/docs/guides/writing-custom-schema-tests /guides/legacy/writing-custom-generic-tests 302
/docs/guides/best-practices#choose-your-materializations-wisely /guides/legacy/best-practices#choose-your-materializations-wisely 302
/docs/guides/best-practices#version-control-your-dbt-project /guides/legacy/best-practices#version-control-your-dbt-project 302
/docs/best-practices /guides/legacy/best-practices 302
/docs/guides/best-practices /guides/best-practices 302
/docs/hooks /docs/building-a-dbt-project/hooks-operations 302
/docs/init /reference/commands/init 302
/docs/install-from-source /dbt-cli/installation 302
Expand All @@ -112,7 +121,7 @@
/docs/log /docs/writing-code-in-dbt/jinja-context/log 302
/docs/macos /dbt-cli/installation 302
/docs/macros /docs/building-a-dbt-project/macros 302
/docs/managing-environments /docs/guides/managing-environments 302
/docs/managing-environments /guides/legacy/managing-environments 302
/docs/materializations /docs/building-a-dbt-project/building-models/materializations 302
/docs/model-selection-syntax /reference/node-selection/syntax 302
/docs/modules /docs/writing-code-in-dbt/jinja-context/modules 302
Expand Down Expand Up @@ -212,12 +221,12 @@
/docs/using-variables /docs/building-a-dbt-project/building-models/using-variables 302
/docs/var /docs/writing-code-in-dbt/jinja-context/var 302
/docs/version /reference/global-cli-flags#version 302
/docs/videos /docs/guides/videos 302
/docs/videos /guides/legacy/videos 302
/docs/viewpoint /docs/about/viewpoint 302
/docs/windows /dbt-cli/installation 302
/docs/writing-code-in-dbt/class-reference /reference/dbt-classes 302
/docs/writing-code-in-dbt/extending-dbts-programming-environment/creating-new-materializations /docs/guides/creating-new-materializations 302
/docs/writing-code-in-dbt/extending-dbts-programming-environment/custom-schema-tests /docs/guides/writing-custom-schema-tests 302
/docs/writing-code-in-dbt/extending-dbts-programming-environment/creating-new-materializations /guides/legacy/creating-new-materializations 302
/docs/writing-code-in-dbt/extending-dbts-programming-environment/custom-schema-tests /guides/legacy/writing-custom-schema-tests 302
/docs/writing-code-in-dbt/getting-started-with-jinja /docs/building-a-dbt-project/jinja-macros 302
/docs/writing-code-in-dbt/jinja-context/adapter /reference/dbt-jinja-functions/adapter 302
/docs/writing-code-in-dbt/jinja-context/as_text /reference/dbt-jinja-functions/as_text 302
Expand Down Expand Up @@ -322,5 +331,4 @@ https://tutorial.getdbt.com/* https://docs.getdbt.com/:splat 301!
/docs/guides/migration-guide/upgrading-to-v1.0 /guides/migration/versions/upgrading-to-v1.0 302
/docs/guides/getting-help /guides/legacy/getting-help 302
/docs/guides/migration-guide/* /guides/migration/versions/:splat 301!
/docs/guides/best-practices /guides/best-practices
/docs/guides/* /guides/legacy/:splat 301!
10 changes: 4 additions & 6 deletions website/blog/2022-06-30-coalesce-sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ authors: [kira_furuichi]

tags: [SQL Magic]
hide_table_of_contents: false

date: 2022-06-30
date: 2022-05-08
is_featured: false
---

Expand All @@ -19,7 +18,6 @@ COALESCE is an incredibly useful function that allows you to fill in unhelpful b
<!--truncate-->

> **What is a SQL Function?**
>
> At a high level, a function takes an input (or multiple inputs) and returns a manipulation of those inputs. Some common SQL functions are [EXTRACT](https://docs.getdbt.com/blog/extract-sql-love-letter/), [LOWER](https://docs.getdbt.com/blog/lower-sql-love-letter/), and [DATEDIFF](https://docs.getdbt.com/blog/datediff-sql-love-letter/). For example, the LOWER function takes a string value and returns an all lower-case version of that input string.
## How to use the COALESCE function
Expand All @@ -34,7 +32,7 @@ coalesce(<input_1>, <input_2>,...<input_n>)

You can have as many input values/columns to the COALESCE function as you like, but remember: order is important here since the first non-null value is the one that is returned. In practice, you’ll likely only ever use the COALESCE function with two inputs: a column and the value you want to fill null values of that column with.

> **Fun Fact**
> **See it in action:**
> The COALESCE function is used in the [surrogate_key](https://docs.getdbt.com/blog/sql-surrogate-keys) macro to replace null column values.
### Data warehouse support for the COALESCE function
Expand All @@ -60,7 +58,7 @@ select
order_id,
order_date,
coalesce(order_status, 'not_returned') as order_status
from orders
from {{ ref('orders') }}
```

Running this query would return the following:
Expand All @@ -73,7 +71,7 @@ Running this query would return the following:

Now, there are no null values in the `order_status` column since any null value was replaced by a `not_returned` string. Order 34553’s `order_status` remained unchanged because its original `order_status` was the first non-null value passed in the COALESCE function. By providing more context into what these null values mean, anyone who looks at this table can quickly understand the order status for a specific order.

> **Important:**
> **To replace or not to replace:**
> COALESCE has a straightforward use case—fill missing values with values you specify—but you also want to ensure you’re not changing non-empty values when using it. This is where the order of the input values to the COALESCE function are important: from left to right, the first non-null value is the one that’s returned.
## Why we love it
Expand Down
4 changes: 2 additions & 2 deletions website/blog/2022-06-30-extract-sql-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors: [kira_furuichi]
tags: [SQL Magic]
hide_table_of_contents: false

date: 2022-06-30
date: 2022-05-15
is_featured: false
---
There are so many different date functions in SQL—you have [DATEDIFF](https://docs.getdbt.com/blog/datediff-sql-love-letter/), [DATEADD](https://docs.getdbt.com/blog/sql-dateadd), DATE_PART, and [DATE_TRUNC](https://docs.getdbt.com/date-trunc-sql) to name a few. They all have their different use cases and understanding how and when they should be used is a SQL fundamental to get down. Are any of those as easy to use as the EXTRACT function? Well, that debate is for another time…
Expand All @@ -20,7 +20,7 @@ In this post, we’re going to give a deep dive into the EXTRACT function, how i
The EXTRACT function allows you to extract a specified date part from a date/time. For example, if you were to extract the month from the date February 14, 2022, it would return 2 since February is the second month in the year.

> **What is a SQL function?**
> At a high level, a function takes an input (or multiple inputs) and returns a manipulation of those inputs. Some common SQL functions are [COALESCE](https://docs.getdbt.com/blog/coalesce-sql-love-letter/), [LOWER],(https://docs.getdbt.com/blog/lower-sql-love-letter/) and [DATEDIFF](https://docs.getdbt.com/blog/datediff-sql-love-letter/). For example, the COALESCE function takes a group of values and returns the first non-null value from that group.
> At a high level, a function takes an input (or multiple inputs) and returns a manipulation of those inputs. Some common SQL functions are [COALESCE](https://docs.getdbt.com/blog/coalesce-sql-love-letter/), [LOWER](https://docs.getdbt.com/blog/lower-sql-love-letter/) and [DATEDIFF](https://docs.getdbt.com/blog/datediff-sql-love-letter/). For example, the COALESCE function takes a group of values and returns the first non-null value from that group.
## How to use the EXTRACT function

Expand Down
6 changes: 3 additions & 3 deletions website/blog/2022-06-30-lower-sql-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ authors: [kira_furuichi]
tags: [SQL Magic]
hide_table_of_contents: false

date: 2022-06-30
date: 2022-05-11
is_featured: false
---

We’ve all been there:

* In a user signup form, user A typed in their name as Kira Furuichi, user B typed it in as john blust, and user C wrote DAvid KrevitT (what’s up with that, David??)
* In a user signup form, user A typed in their name as `Kira Furuichi`, user B typed it in as `john blust`, and user C wrote `DAvid KrevitT` (what’s up with that, David??)
* Your backend application engineers are adamant customer emails are in all caps
* All of your event tracking names are lowercase

Expand Down Expand Up @@ -73,7 +73,7 @@ After running this query, the `customers` table will look a little something lik

Now, all characters in the `first_name` and `last_name` columns are lowercase.

> **Note:**
> **Where do you lower?**
> Changing all string columns to lowercase to create uniformity across data sources typically happens in our dbt project’s [staging models](https://docs.getdbt.com/guides/best-practices/how-we-structure/2-staging). There are a few reasons for that: data cleanup and standardization, such as aliasing, casting, and lowercasing, should ideally happen in staging models to create downstream uniformity. It’s also more performant in downstream models that join on string values to join on strings that are of all the same casing versus having to join and perform lowercasing at the same time.
## Why we love it
Expand Down
7 changes: 3 additions & 4 deletions website/blog/2022-07-05-date-trunc-sql-love-letter.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors: [kira_furuichi]
tags: [sql magic]
hide_table_of_contents: true

date: 2022-07-05
date: 2022-07-13
is_featured: false
---
In general, data people prefer the more granular over the less granular. [Timestamps > dates](https://docs.getdbt.com/blog/when-backend-devs-spark-joy#signs-the-data-is-sparking-joy), daily data > weekly data, etc.; having data at a more granular level always allows you to zoom in. However, you’re likely looking at your data at a somewhat zoomed-out level—weekly, monthly, or even yearly. To do that, you’re going to need a handy dandy function that helps you round out date or time fields.
Expand All @@ -20,10 +20,9 @@ Using the DATE_TRUNC function, you can truncate to the weeks, months, years, or
<!--truncate-->

> **What is a SQL function?**
>
> At a high level, a function takes an input (or multiple inputs) and returns a manipulation of those inputs. Some common SQL functions are [COALESCE](https://getdbt.com/sql-foundations/coalesce-sql-love-letter/), [LOWER](https://getdbt.com/sql-foundations/lower-sql-love-letter/), and [EXTRACT](https://getdbt.com/sql-foundations/extract-sql-love-letter/). For example, the COALESCE function takes a group of values and returns the first non-null value from that group.
Overall, it’s a great function to use to help you aggregate your data into specific date parts while keeping a date format. However, the DATE_TRUNC function isn’t your swiss army knife–it’s not able to do magic or solve all of your problems (we’re looking at you [star](https://getdbt.com/sql-foundations/star-sql-love-letter/). Instead, DATE_TRUNC is your standard kitchen knife—it’s simple and efficient, and you almost never start cooking (data modeling) without it.
Overall, it’s a great function to use to help you aggregate your data into specific date parts while keeping a date format. However, the DATE_TRUNC function isn’t your swiss army knife–it’s not able to do magic or solve all of your problems (we’re looking at you [star](https://getdbt.com/sql-foundations/star-sql-love-letter/)). Instead, DATE_TRUNC is your standard kitchen knife—it’s simple and efficient, and you almost never start cooking (data modeling) without it.

## How to use the DATE_TRUNC function

Expand Down Expand Up @@ -56,7 +55,7 @@ In [Google BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-s
date_trunc(<date/time field>, <date part>)
```

> **Note:**
> **A note on BigQuery:**
> BigQuery’s DATE_TRUNC function supports the truncation of date types, whereas Snowflake, Redshift, and Databricks’ <date/time field> can be a date or timestamp data type. BigQuery also supports DATETIME_TRUNC and TIMESTAMP_TRUNC functions to support truncation of more granular date/time types.
## A dbt macro to remember
Expand Down
Loading

0 comments on commit 30de147

Please sign in to comment.