From 873c224934259d3e6dfa9e05ae0efb2919066f35 Mon Sep 17 00:00:00 2001 From: Celine Verhoef Date: Thu, 25 Apr 2024 10:24:37 +0200 Subject: [PATCH] docs: update readme by explaining that the ref should be in the from --- README.md | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1488654..7fe2246 100644 --- a/README.md +++ b/README.md @@ -141,13 +141,15 @@ You can choose to exclude fields from the select statement, for example: - When you apply logic to a field and don't want to keep the original. - When you join tables and a field with the same name is available on multiple tables. +Make sure to put the relation also in the from clause. Otherwise, the table from which you select can't be found. + Usage: Select all fields from model `Table_A`. ``` select {{ pm_utils.star(ref('Table_A')) }} -from ref('Table_A') +from {{ ref('Table_A') }} ``` Select all fields from source `Table_A`. @@ -157,23 +159,12 @@ select from source('sources', 'Table_A') ``` -Select all fields from `Table_A`, which is first created as CTE. You can write `from Table_A`, but the argument of the star macro requires the `ref()`. -``` -with Table_A as ( - select * from {{ ref('Table_A') }} -) - -select - {{ pm_utils.star(ref('Table_A')) }} -from Table_A -``` - Select all fields from `Table_A`, except for the field `Creation_date`. More fields can be added to the except list. Additional select statements can be written before and after the `star()` macro by separating the statements with a comma. ``` select {{ pm_utils.star(ref('Table_A'), except=['Creation_date']) }}, {{ pm_utils.to_date('"Creation_date"') }} as "Creation_date" -from Table_A +from {{ ref('Table_A') }} ``` ### Data type cast functions