Skip to content

Commit

Permalink
docs: update readme by explaining that the ref should be in the from
Browse files Browse the repository at this point in the history
  • Loading branch information
cverhoef committed Apr 24, 2024
1 parent 770f4fa commit 567659a
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ 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`.
Expand All @@ -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
Expand Down

0 comments on commit 567659a

Please sign in to comment.