The problem I’m having
I’ve written something in Snowflake and it runs there fine. But, when I attempt to run it in dbt Cloud, I get a “Runtime Error cannot unpack non-iterable NoneType object” There’s a lot more in the log of course. I’ve read through it but am not seeing the issue.
The context of why I’m trying to do this
I’m just learning Snowflake and dbt, and this is just an exercise in testing what works and what doesn’t. I’m pretty sure I can what I need using dbt_utils/date_spine, but I’m learning, not DRYing. (I’m also a Python noob.)
What I’ve already tried
I’ve tried casting a lot of stuff, and just hacking at it in general. First in snowsight, to be sure it still works, then over in dbt Cloud.
Some example code or error messages
;WITH
FourRows AS (SELECT 1 AS X UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1)
,SixteenRows AS (SELECT FR.X FROM FourRows FR INNER JOIN LATERAL (SELECT X FROM FourRows FR2 WHERE FR2.X = FR.X) AS FR2)
,SeqNumber256 AS
(SELECT ROW_NUMBER() OVER (PARTITION BY SR.X ORDER BY (SELECT NULL)) AS SeqNumber
FROM SixteenRows SR INNER JOIN LATERAL (SELECT X FROM SixteenRows SR2 WHERE SR2.X = SR.X) AS SR2)
,MonthDates AS
(SELECT DATEADD(MONTH,-1*SN256.SeqNumber,'2024-11-01') AS MonthDate
FROM SeqNumber256 SN256
WHERE SN256.SeqNumber<=24
)
SELECT ROW_NUMBER() OVER (ORDER BY MonthDATE) AS PeriodNumber
,DATEFROMPARTS(YEAR(MonthDate),Month(MonthDate),1) As MonthBeginDate
,LAST_DAY(MonthDate) AS MonthEndDate
FROM MonthDates