Closed ValBerthe closed 4 months ago
yup, I can reproduce this-- figuring out what's going on, thanks for the report!
So this does not seem to be something I can override easily-- the workaround I cooked up is to use a CTE instead of an alias here, so your model needs to turn into something like this:
WITH n AS (
SELECT DISTINCT
frame,
frame_type
FROM {{ ref('int_raw') }}
),
t AS (
SELECT TARGET_MONTH, DAY, HOUR
FROM {{ ref('my_downstream_model') }}
)
SELECT n.frame as FRAME_ID,
n.frame_type,
t.TARGET_MONTH,
t.DAY,
t.HOUR,
0 AS impressions
FROM n CROSS JOIN t
The issue here is that the --empty
flag renders the {{ ref(...) }}
and {{ source(...) }}
macros in a way that isn't aware of the alias for the ref that you are adding after the fact (t
in this case), which causes the compiled query to throw a syntax error b/c there are two aliases for the same relation right after each other (you can look in the target/compiled/
directory of your dbt project to see how that shakes out here.)
I'm going to file an issue upstream with the dbt-adapters folks to see how they want to handle this case going forward, but it's not something I can fix right now in the dbt-duckdb adapter itself AFAICT, so a workaround and a mental model of how this works is the best I can do for you at the moment. 🙇
Ah no it seems I'm wrong-- I think I can use the trick here https://github.com/dbt-labs/dbt-adapters/issues/124 to fix this, going to put a PR together
@jwills thanks a lot for the heads up! Will use the CTE workaround for now 😊
Hello,
dbt run --empty
seems to throw a syntax error whendbt run
works correctly.Without the flag:
The model :
This prevents me from running unit tests in the CI.
Not sure if the issue is caused by
dbt-duckdb
's implementation of the--empty
flag.Glad to help resolve this issue!