The problem I’m having:
I want to use a model to create a table with a sequence of person ages (from 1 to 130) with some case statements to allocate them into specific bands. Doco lead me to try using the dbt_utils.generate_series macro but I’m struggling to find an example of the correct syntax to use.
I know the following is wrong and fails, but would appreciate any guidance on a solution:
{{
config(
index = 'HEAP',
dist = 'ROUND_ROBIN',
materialized = 'table',
)
}}
WITH ages AS (
SELECT Age_Number
FROM {{ dbt_utils.generate_series(upper_bound=130) }}
)
SELECT
Age_Number,
CASE
WHEN Age_Number < 18 THEN 'Minor'
WHEN Age_Number > 64 THEN 'Senior'
ELSE 'Adult'
END AS Age_Group
FROM ages;