I’m trying to run a dbt python model and the run fails because it takes the compiled python code for my model and wrapps create or replace table ... AS (
… )
around it.
I am calling my python model with
dbt run --select my_python_model
dbt does not realise that the compiled model is a python file and thinks it is a sql file, so it wraps sql code around it. That, of course, leads to an error.
How can I tell dbt that it should treat my python model as a python model and not a (normal) sql model?
I’m on dbt 1.7 and the directory where my model resides contains the following files:
- models.yml
- my_python_model.py
- sources.yml
According to dbt’s documentation (https://docs.getdbt.com/docs/build/python-models#defining-a-python-model):
When you
dbt run --select python_model
, dbt will prepare and pass in
both arguments (dbt and session). …