При запуске инкрементальной модели dbt
dbt run -s first_100_cards --full-refresh
Появляется ошибка
11:06:11 Running with dbt=1.6.0
11:06:11 Registered adapter: postgres=1.6.0
11:06:11 Found 7 models, 4 tests, 4 sources, 0 exposures, 0 metrics, 463 macros, 0 groups, 0 semantic models
11:06:11
11:06:11 Concurrency: 3 threads (target='dev')
11:06:11
11:06:11 1 of 1 START sql incremental model dbt.first_100_cards ......................... [RUN]
11:06:12 1 of 1 ERROR creating sql incremental model dbt.first_100_cards ................ [ERROR in 0.35s]
11:06:12
11:06:12 Finished running 1 incremental model in 0 hours 0 minutes and 0.96 seconds (0.96s).
11:06:12
11:06:12 Completed with 1 error and 0 warnings:
11:06:12
11:06:12 Database Error in model first_100_cards (models\mydb_models\first_100_cards.sql)
11:06:12 relation "datetr" does not exist
11:06:12 LINE 25: "datetr",
11:06:12 ^
11:06:12 compiled Code at target\run\dbt_demo\models\mydb_models\first_100_cards.sql
11:06:12
11:06:12 Done. PASS=0 WARN=0 ERROR=1 SKIP=0 TOTAL=1
Модель выглядит так:
with source_cards as (
SELECT * from
{{ dbt_utils.star(from=source('mydb_tables','cards'), except=['vid'])}}
limit 100
)
select sc.*,
case when x.case_ump = 4 then 'r'
when x.case_ump = 3 then 'a'
when x.case_ump = 2 then 'd'
when x.case_ump = 1 then 's' end as vid
from source_cards as sc
left join
{{source("mydb_tables","visits")}} as x
on sc.id_service = x.id_service
WHERE TRUE
{% if is_incremental() %}
AND sc.id_service >= (select max(id_service) from {{ this }})
{% endif %}
Лог в базе данных выглядит так
2023-08-03 14:06:09.466 MSK [110291] postgres@mydb WARNING: there is already a transaction in progress
2023-08-03 14:06:09.641 MSK [110291] postgres@mydb ERROR: relation "datetr" does not exist at character 454
2023-08-03 14:06:09.641 MSK [110291] postgres@mydb STATEMENT: /* {"app": "dbt", "dbt_version": "1.6.0", "profile_name": "dbt_mydb_postgres", "target_name": "dev", "node_id": "model.dbt_demo.first_100_cards"} */
create unlogged table "mydb"."dbt"."first_100_cards"
as
(
-- Конфигурация модели:
-- Инкрементальное наполнение, уникальный ключ для обновления записей (unique_key)
-- Ключ сегментации (dist), ключ сортировки (sort)
with source_cards as (
SELECT * from
"datetr",
"numtr",
"reciever",
"id_service"
limit 100
)
select sc.*,
case when x.case_ump = 4 then 'r'
when x.case_ump = 3 then 'a'
when x.case_ump = 2 then 'd'
when x.case_ump = 1 then 's' end as vid
from source_cards as sc
left join
"mydb"."public"."cards_dop" as x
on sc.id_service = x.id_service
WHERE TRUE
);
2023-08-03 14:06:09.748 MSK [110292] postgres@mydb WARNING: there is already a transaction in progress
2023-08-03 14:07:18.162 MSK [107081] postgres@mydb LOG: could not receive data from client: Connection timed out
Конечно поле "datetr" в таблице есть, но если его убрать, то такая же ошибка будет
указывать на отсутствие следующего поля таблицы.
Что не так с моделью, как исправить ошибку?
SELECT VERSION();
PostgreSQL 14.8 (Ubuntu 14.8-0ubuntu0.22.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0, 64-bit