Код: Выделить всё
# version: '3'
services:
source_postgres:
image: postgres:latest
ports:
- "5433:5432"
networks:
- elt_network
environment:
POSTGRES_DB: source_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: secret
volumes:
- ./source_db_init/init.sql:/docker-entrypoint-initdb.d/init.sql
destination_postgres:
image: postgres:latest
ports:
- "5434:5432"
networks:
- elt_network
environment:
POSTGRES_DB: destination_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: secret
elt_script:
build:
context: ./elt
dockerfile: Dockerfile
command: ["python3", "elt_script.py"]
networks:
- elt_network
depends_on:
- source_postgres
- destination_postgres
dbt:
image: ghcr.io/dbt-labs/dbt-postgres:1.8.1
command:
[
"run",
"--profiles-dir",
"/root",
"--project-dir",
"/dbt"
]
networks:
- elt_network
volumes:
- ./custom_postgres:/dbt
- ~/.dbt:/root
depends_on:
- elt_script
environment:
DBT_PROFILE: custom_postgres
DBT_TARGET: dev
networks:
elt_network:
driver: bridge
Код: Выделить всё
2024-06-03 18:40:32 16:40:32 Running with dbt=1.8.1
2024-06-03 18:40:32 16:40:32 Registered adapter: postgres=1.8.1
2024-06-03 18:40:32 16:40:32 Found 4 models, 20 data tests, 3 sources, 413 macros
2024-06-03 18:40:32 16:40:32
2024-06-03 18:40:33 16:40:33 Concurrency: 1 threads (target='dev')
2024-06-03 18:40:33 16:40:33
2024-06-03 18:40:33 16:40:33 1 of 4 START sql table model public.actors ..................................... [RUN]
2024-06-03 18:40:33 16:40:33 1 of 4 ERROR creating sql table model public.actors ............................ [ERROR in 0.10s]
2024-06-03 18:40:33 16:40:33 2 of 4 START sql table model public.film_actors ................................ [RUN]
2024-06-03 18:40:33 16:40:33 2 of 4 ERROR creating sql table model public.film_actors ....................... [ERROR in 0.06s]
2024-06-03 18:40:33 16:40:33 3 of 4 START sql table model public.films ...................................... [RUN]
2024-06-03 18:40:33 16:40:33 3 of 4 ERROR creating sql table model public.films ............................. [ERROR in 0.06s]
2024-06-03 18:40:33 16:40:33 4 of 4 SKIP relation public.film_ratings ....................................... [SKIP]
2024-06-03 18:40:33 16:40:33
2024-06-03 18:40:33 16:40:33 Finished running 4 table models in 0 hours 0 minutes and 0.46 seconds (0.46s).
2024-06-03 18:40:33 16:40:33
2024-06-03 18:40:33 16:40:33 Completed with 3 errors and 0 warnings:
2024-06-03 18:40:33 16:40:33
2024-06-03 18:40:33 16:40:33 Database Error in model actors (models/example/actors.sql)
2024-06-03 18:40:33 relation "public.actors" does not exist
2024-06-03 18:40:33 LINE 12: SELECT * FROM "destination_db"."public"."actors"
2024-06-03 18:40:33 ^
2024-06-03 18:40:33 compiled Code at target/run/custom_postgres/models/example/actors.sql
2024-06-03 18:40:33 16:40:33
2024-06-03 18:40:33 16:40:33 Database Error in model film_actors (models/example/film_actors.sql)
2024-06-03 18:40:33 relation "public.film_actors" does not exist
2024-06-03 18:40:33 LINE 12: SELECT * FROM "destination_db"."public"."film_actors"
2024-06-03 18:40:33 ^
2024-06-03 18:40:33 compiled Code at target/run/custom_postgres/models/example/film_actors.sql
2024-06-03 18:40:33 16:40:33
2024-06-03 18:40:33 16:40:33 Database Error in model films (models/example/films.sql)
2024-06-03 18:40:33 relation "public.films" does not exist
2024-06-03 18:40:33 LINE 12: SELECT * FROM "destination_db"."public"."films"
2024-06-03 18:40:33 ^
2024-06-03 18:40:33 compiled Code at target/run/custom_postgres/models/example/films.sql
2024-06-03 18:40:33 16:40:33
2024-06-03 18:40:33 16:40:33 Done. PASS=0 WARN=0 ERROR=3 SKIP=1 TOTAL=4
< /code>
Указывает, что некоторых отношений не существует, но я исследовал в контейнере Docker docker destination_db.docker exec -it bash< /code> < /p>
Переключить пользователя Postgres в моем контейнере:
su - postgres< /code> < /p>
Включить командную строку PostgreSQL:
psql< /code> < /p>
Соединение с destination_db:
\c destination_db< /code> < /p>
Список таблиц внутри destination_db:
\dt
Все таблицы, перечисленные в журналах ошибок, были здесь.
Я не понимаю, что идет не так.
Подробнее здесь: https://stackoverflow.com/questions/785 ... -using-dbt