{"id":334179,"date":"2022-06-07T15:01:07","date_gmt":"2022-06-07T15:01:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=334179"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=334179","title":{"rendered":"<span>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 dbt \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0a3\/c0a\/1a2\/0a3c0a1a236ed5e17ce98ec2f586e107.png\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0a3\/c0a\/1a2\/0a3c0a1a236ed5e17ce98ec2f586e107.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041c\u0430\u0440\u043a \u041f\u043e\u0440\u043e\u0448\u0438\u043d, \u0432 DV Group \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c Data Science. \u041c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u0435\u043c\u0441\u044f \u043a 10\u0442\u0431 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 Greenplum. \u0422\u0430\u043a \u043a\u0430\u043a \u0431\u0438\u0437\u043d\u0435\u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043e\u043b\u043e\u0434\u043e\u0439, \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u043e\u0432, \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0432 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f, \u0434\u0430 \u0438 \u0441\u0430\u043c\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f Data Warehouse \u2014 DataVault. \u0414\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u043d\u044b \u0441\u0432\u043e\u0435\u0439 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c\u044e, \u043e\u0434\u043d\u0430\u043a\u043e \u0446\u0435\u043d\u043e\u0439 \u0437\u0430 \u044d\u0442\u0443 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0430\u0431\u043b\u0438\u0446. \u042d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u0441\u0440\u0430\u0437\u0443 \u043a \u0434\u0432\u0443\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c:<\/p>\n<ul>\n<li>\n<p>\u041d\u0443\u0436\u043d\u0430 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c join-\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0421\u043f\u043e\u0441\u043e\u0431 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0440\u0443\u043a\u0430\u043c\u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0447\u0435\u043d\u044c \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u043e, \u0430 \u0435\u0449\u0435 \u044d\u0442\u043e \u0447\u0440\u0435\u0432\u0430\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 DV Group \u2014\u00a0<a href=\"https:\/\/docs.getdbt.com\" rel=\"noopener noreferrer nofollow\">dbt<\/a>(data build tool), \u043e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u0435\u0431\u044f \u0437\u0430\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>\u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 dbt \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c postgres, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u043d\u0430 \u0441\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u044f \u0431\u0443\u0434\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 PyCharm, \u044d\u0442\u043e \u0432\u043e\u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0442\u0443\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0430\u043c. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 python3 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"bash\">pip install dbt-core==1.1.0 dbt-postgres==1.1.0<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c dbt \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<pre><code class=\"bash\">(venv) \u279c  PostgresDBTIntro dbt init 11:32:18  Running with dbt=1.1.0 Enter a name for your project (letters, digits, underscore): dbt_postgres_intro    Which database would you like to use? [1] postgres  (Don\\'t see the one you want? https:\/\/docs.getdbt.com\/docs\/available-adapters)  Enter a number: 1 11:33:04   Your new dbt project \"dbt_postgres_intro\" was created!<\/code><\/pre>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443 \u0432\u0430\u0441 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0430\u043f\u043a\u0430 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0432\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<h2>\u041f\u0435\u0440\u0432\u044b\u0435 \u0448\u0430\u0433\u0438 \u0432 dbt<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u0444\u0430\u0439\u043b\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/fa7\/3fb\/200\/fa73fb2000c9e8f7056092344d040458.jpeg\" alt=\"\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 dbt\" title=\"\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 dbt\" width=\"1034\" height=\"895\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fa7\/3fb\/200\/fa73fb2000c9e8f7056092344d040458.jpeg\" data-blurred=\"true\"\/><figcaption>\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 dbt<\/figcaption><\/figure>\n<p>\u041f\u043e\u0434 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u043e\u0434\u0438\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u00a0<strong>dbt_project.ym<\/strong>l, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435(vars), \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u0422\u0430\u043a\u0436\u0435 \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0445\u0443\u043a\u0438<strong>\u00a0on-run-start<\/strong>,<strong>\u00a0on-run-end<\/strong>. \u041a \u044d\u0442\u0438\u043c \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044f\u043c \u043c\u044b \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043f\u043e\u0437\u0436\u0435, \u0430 \u0441\u0435\u0439\u0447\u0430\u0441\u00a0\u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0430\u0439\u043b \u043f\u043e\u0434 \u043d\u043e\u043c\u0435\u0440\u043e\u043c 2\u00a0<strong>my_first_dbt_model.sql<\/strong><\/p>\n<pre><code class=\"sql\">\/*     Welcome to your first dbt model!     Did you know that you can also configure models directly within SQL files?     This will override configurations stated in dbt_project.yml      Try changing \"table\" to \"view\" below *\/  {{     config(materialized='table') }}  with source_data as (      select 1 as id     union all     select null as id  )  select * from source_data  \/*     Uncomment the line below to remove records with null `id` values *\/  -- where id is not null<\/code><\/pre>\n<p>\u041f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0431\u043b\u043e\u043a \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432, \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<code>\/* ... *\/<\/code>\u00a0\u0438 \u0432\u0438\u0434\u0438\u043c:<\/p>\n<pre><code class=\"sql\">{{     config(materialized='table') }}<\/code><\/pre>\n<p>DBT \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Jinja, \u043f\u043e\u044d\u0442\u043e\u043c\u0443\u00a0<code>{{ ... }}<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430. \u0412 \u043d\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u00a0macro(\u0447\u0438\u0442\u0430\u0439 \u201c\u0444\u0443\u043d\u043a\u0446\u0438\u044e\u201d) &#8212;\u00a0config, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u00a0<code>materialized<\/code>\u00a0\u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c\u00a0<code>'table'.<\/code> \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u00a0\u043c\u043e\u0434\u0435\u043b\u0438\u00a0\u201cmy_first_dbt_model\u201d, \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0430 (\u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u043d\u0430) \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c, \u043a\u0430\u043a \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430.\u00a0<\/p>\n<p>\u0421\u043b\u0435\u0434\u043e\u043c \u0438\u0434\u0435\u0442 sql \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"sql\">select * from source_data<\/code><\/pre>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0435\u0449\u0435 \u043e\u0434\u043d\u0438\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c.\u041f\u043e\u043a\u0430 \u043c\u044b \u0435\u0449\u0435 \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u043a\u0440\u0435\u0434\u0435\u043d\u0448\u0435\u043d\u044b \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0443 \u043d\u0430\u0448\u0435\u0433\u043e Postgres\u2019a. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0430\u0439\u043b\u0430\u00a0<code>profiles.yml<\/code>. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"yaml\">config:   send_anonymous_usage_stats: False   use_colors: True   partial_parse: True   dbt_postgres_intro:   outputs:     dev:       type: postgres       threads: 3       host: localhost       port: 5432       user: markporoshin       pass: \"&lt;password>\"       dbname: dbt_intro_db       schema: public   target: dev<\/code><\/pre>\n<p>\u042f \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c\u00a0<code>dbt_project.yml<\/code>, \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u044d\u0442\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0434\u0435\u043f\u043b\u043e\u044f. DBT \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438 (<code>\/Users\/&lt;user>\/.dbt\/profiles.yml<\/code>\u00a0\u043d\u0430 mac os). \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0432\u0430\u0448\u0435 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u0438 \u0432 \u043b\u043e\u0433\u0430\u0445 dbt \u043d\u0430\u043f\u0438\u0448\u0435\u0442, \u0433\u0434\u0435 \u043e\u043d \u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u0438\u0449\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u043c\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\">dbt run --project-dir .\/ -m my_first_dbt_model<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u00a0<code>profiles.yml<\/code>\u00a0\u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u044f, \u0432\u044b\u0437\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"bash\">dbt run --project-dir .\/ --profiles-dir .\/ --profile dbt_postgres_intro -m my_first_dbt_model<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c dbt \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u00a0<code>--project-dir .\/<\/code>; \u043f\u0443\u0442\u044c \u043a \u043f\u0430\u043f\u043a\u0435 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c\u00a0profiles.yml\u00a0&#8212;\u00a0<code>--profiles-dir .\/<\/code>; \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u044f\u00a0<code>--profile dbt_postgres_intro<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u0432\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435\u00a0profiles.yml\u00a0\u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438\u043b\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 DEV, PROD)<\/p>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 Postgres dbt \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442 \u0435\u0433\u043e\u00a0<code>create table ... as ...<\/code>\u00a0\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 sql \u043a\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"sql\">create  table \"dbt_intro_db\".\"public\".\"my_first_dbt_model__dbt_tmp\" as ( with source_data as (     select 1 as id     union all     select null as id ) select * from source_data );<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u0437\u0434\u0435\u0441\u044c \u0447\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435. DBT \u0441\u043e\u0437\u0434\u0430\u043b \u043d\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0443, \u043d\u043e \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0441\u0442\u0444\u0438\u043a\u0441\u00a0<code>__dbt_tmp<\/code>. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e dbt \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0430\u043f\u043e\u0432:<\/p>\n<pre><code class=\"sql\"> -- \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b create  table \"dbt_intro_db\".\"public\".\"my_first_dbt_model__dbt_tmp\" as ( with source_data as (     select 1 as id     union all     select null as id ) select * from source_data );   -- \u0435\u0441\u043b\u0438 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0435\u0435 \u0432 backup alter table \"dbt_intro_db\".\"public\".\"my_first_dbt_model\" rename to \"my_first_dbt_model__dbt_backup\";   -- \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0446\u0435\u043b\u0435\u0432\u0443\u044e alter table \"dbt_intro_db\".\"public\".\"my_first_dbt_model__dbt_tmp\" rename to \"my_first_dbt_model\"  -- \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u044d\u0442\u0430\u043f\u044b \u043f\u0440\u043e\u0448\u043b\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043c\u043e\u0436\u0435\u043c \u0443\u0434\u0430\u043b\u044f\u0442\u044c backup drop table if exists \"dbt_intro_db\".\"public\".\"my_first_dbt_model__dbt_backup\" cascade<\/code><\/pre>\n<p>dbt \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0430 \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u043a \u201c\u0441\u0442\u0430\u0442\u0443\u0441\u0443 \u043a\u0432\u043e\u201d.<\/p>\n<p>\u041f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442 dbt, \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0444\u043b\u0430\u0433\u0430\u00a0<code>-d<\/code>:<\/p>\n<pre><code class=\"bash\">dbt -d run --profiles-dir .\/ --profile dbt_postgres_intro -m my_first_dbt_model<\/code><\/pre>\n<h2>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 dbt<\/h2>\n<p>\u0427\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u044c. \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438\u00a0<code>dbt run<\/code>\u00a0dbt \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<ol>\n<li>\n<p>\u041f\u0430\u0440\u0441\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u0438, \u043c\u0430\u043a\u0440\u043e\u0441\u044b, \u0442\u0435\u0441\u0442\u044b \u0438\u0442\u0434. \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u0435 sql \u0437\u0430\u043f\u0440\u043e\u0441\u044b;<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u044b \u0443\u0436\u0435 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 Jinja \u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a. \u041f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c\u00a0<a href=\"https:\/\/docs.getdbt.com\/reference\/dbt-jinja-functions\/execute\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a>\u00a0\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u043a\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0432 \u0434\u0435\u0431\u0430\u0433\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u0430\u043f\u043a\u0435\u00a0<code>target\/compiled<\/code>(\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438), \u0430 \u0435\u0441\u043b\u0438 \u0431\u044b\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430 \u0441\u0442\u0430\u0434\u0438\u044f run \u0432 \u043f\u0430\u043f\u043a\u0435\u00a0<code>target\/run<\/code>\u00a0\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 sql \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d.<\/p>\n<h2>\u041c\u0430\u0433\u0438\u044f jinja<\/h2>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u201c\u0432\u043a\u0443\u0441\u043d\u043e\u043c\u0443\u201d \u0432 dbt, \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f boilerplate \u043a\u043e\u0434\u0430 \u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c data engineer =).<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e dbt \u043c\u043e\u0434\u0435\u043b\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u043c\u0438:<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='table',     ) }}   select 1 as id, 'Nikita' as name, 'Analytics' as type union select 2 as id, 'Stanislav' as name, 'Analytics' as type union select 3 as id, 'Alex' as name, 'CTO' as type union select 4 as id, 'Artem' as name, 'DevOps' as type union select 5 as id, 'Artem' as name, 'DataScience' as type union select 6 as id, 'Victor' as name, 'Backend' as type union select 7 as id, 'Mark' as name, 'DataEngineer' as type<\/code><\/pre>\n<h3>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/h3>\n<p>\u0412 dbt \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 dbt_projects.yml:<\/p>\n<pre><code class=\"yaml\">vars:   developer_name: \"Nikita\"<\/code><\/pre>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='view',     ) }}   select     id,     type from {{ ref('developers') }} d where d.name = '{{ var('developer_name') }}'<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0442\u0438\u043f\u00a0<code>'view'<\/code>, \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0430 view. \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0431\u0435\u0440\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445\u00a0<code>{{ ref('developers') }}<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b dbt \u043d\u0430\u0448\u0435\u043b \u043c\u043e\u0434\u0435\u043b\u044c\u00a0developers\u00a0\u0438 \u0441\u0430\u043c \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u043f\u0443\u0442\u044c \u043a \u043d\u0435\u0439 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u043b\u0435\u0436\u0438\u0442 \u043d\u0435 \u0432 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u0438\u043b\u0438 \u0434\u043b\u044f \u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d <code>alias<\/code>, \u044d\u0442\u043e \u0432\u0441\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 macro\u00a0config). \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 <code>where<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u00a0<code>var<\/code>\u00a0\u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c dbt \u0438 \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439\u00a0<code>developer_name<\/code>.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='view',     ) }}  {% set type = 'DevOps' %}   select     id,     name from {{ ref('developers') }} d where type = '{{ type }}'<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430\u00a0<code>set<\/code>\u00a0\u0438 \u044d\u043a\u0440\u0430\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u043e \u0432\u0441\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<code>{% \u2026 %}<\/code>.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e \u0432 dbt \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442\u00a0<a href=\"https:\/\/docs.getdbt.com\/docs\/building-a-dbt-project\/jinja-macros\" rel=\"noopener noreferrer nofollow\">\u0442\u0440\u0438 \u0442\u0438\u043f\u0430 \u201c\u044d\u043a\u0440\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438\u201d<\/a>:<\/p>\n<ol>\n<li>\n<p><code>{{ ... }}<\/code>\u00a0\u2014 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b;<\/p>\n<\/li>\n<li>\n<p><code>{% ... %}<\/code>\u00a0\u2014 \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0446\u0438\u043a\u043b\u043e\u0432, \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u0442.\u0434.;<\/p>\n<\/li>\n<li>\n<p><code>{# ... #}<\/code>\u00a0\u2014 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u042f \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u00a0<code>{%- ... -%}<\/code>, \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u0441 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<h3>\u0426\u0438\u043a\u043b\u044b<\/h3>\n<p>\u042f \u0434\u0443\u043c\u0430\u044e \u0443\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Jinja \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0439 \u0432 dbt. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0434\u0435\u043b\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u0446\u0438\u043a\u043b:<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='table',     ) }}   {%- set types = ['Analytics', 'DataScience'] -%}   select     id,     name from     {{ ref('developers') }} where type in (     {%- for type in types -%}         '{{ type }}'         {%- if not loop.last %},{% endif -%}     {%- endfor -%} )<\/code><\/pre>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/h3>\n<p>\u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0430\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043d\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 \u0431\u0443\u043a\u0432\u044b \u2018\u0430\u2019, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0430 \u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0446\u0435\u043b\u0435\u0432\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435. \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0441\u0430\u043c\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0433\u0434\u0430 \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c, \u043b\u0438\u0431\u043e \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u0438 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='table'     ) }}  {% set names_start_with_a_query %}     select         name     from         {{ ref('developers') }}     where lower(name) like 'a%' {% endset %} {% set names_start_with_a = [] %}  {% if execute %}     {% set names_start_with_a = run_query(names_start_with_a_query).columns[0].values() %} {% endif %} {{ log(names_start_with_a, info=True) }}  select     id,     name,     type from     {{ ref('developers') }} {% if names_start_with_a != () %}     where name in (         {%- for name in names_start_with_a %}             '{{ name }}'             {%- if not loop.last %},{% endif -%}         {%- endfor -%}     ) {% endif %}<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0431\u043b\u043e\u043a\u0430 \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435,\u00a0<code>names_start_with_a_query<\/code>,\u00a0<code>names_start_with_a<\/code>\u00a0\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<p>\u0421\u043b\u0435\u0434\u043e\u043c \u0438\u0434\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u0433\u0434\u0435 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439\u00a0<code>names_start_with_a_query<\/code>\u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e\u00a0<code>names_start_with_a<\/code>. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0447\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u043e\u043c, \u0437\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440. \u0412\u0441\u0435 \u0434\u0435\u043b\u043e \u0432 \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u043c \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438.\u00a0<code>execute<\/code>\u00a0\u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 True, \u0435\u0441\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438(\u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0438 \u0442\u0434) \u0432 \u201cexecute\u201d \u043c\u043e\u0434\u0435, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443\u0436\u0435 \u043f\u0440\u043e\u0448\u043b\u0430 \u0441\u0442\u0430\u0434\u0438\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c sql \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<h3>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 macro<\/h3>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 macro \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c\u0438: \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u0434\u0435\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0438 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0442\u0435\u043c\u0438 \u0436\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.\u00a0<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0435\u00a0macros\u00a0\u0444\u0430\u0439\u043b\u00a0<code>so_important_macro.sql<\/code>:<\/p>\n<pre><code class=\"sql\">{% macro so_important_macro(number) %}     {% set so_important_query %}         select 1 as info         union         select 2 as info     {% endset %}     {%- set info = run_query(so_important_query).columns[0].values() -%}     {{ log('number ' + number|string, info=True) }}     {{ return(info) }} {% endmacro %}<\/code><\/pre>\n<p>\u0418 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='table'     ) }}  {% if execute %}     {% set info =  so_important_macro(4) %}     {{ log(' info: ' + info|string, info=True) }} {% endif %}  select 1 as id<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432 \u043b\u043e\u0433\u0430\u0445 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"bash\">Running with dbt=1.1.0 Found 8 models, 4 tests, 0 snapshots, 0 analyses, 168 macros, 0 operations, 0 seed files, 0 sources, 0 exposures, 0 metrics    Concurrency: 3 threads (target='dev')  1 of 1 START table model public.test_macro ..................................... [RUN] number 4 info: (Decimal('1'), Decimal('2')) 1 of 1 OK created table model public.test_macro ................................ [SELECT 1 in 0.15s]    Finished running 1 table model in 0.24s.    Completed successfully    Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1<\/code><\/pre>\n<h3>\u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u043c\u044b \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443=)<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u043d\u0430 \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043d\u0435\u0435\u00a0<em>\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 +1<\/em>, \u0435\u0441\u043b\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e\u0433\u0434\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c 1.<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='incremental'     ) }}  {% set data_to_insert = 1 %}  {% if is_incremental() %}     {% set max_number_query %}         select max(num) from {{ this }}     {% endset %}     {% set data_to_insert = run_query(max_number_query).columns[0].values()[0]|int + 1 %} {% endif %}  {{ log('number to insert: ' + data_to_insert|string, info=True)}}  select {{ data_to_insert }} as num<\/code><\/pre>\n<p>\u041c\u0430\u043a\u0440\u043e\u00a0<code>is_incremental<\/code>\u00a0\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441 \u0442\u0438\u043f\u043e\u043c\u00a0<code>incremental<\/code>\u00a0\u0438 \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 True, \u0435\u0441\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u0434\u0435\u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437. \u041c\u0430\u043a\u0440\u043e\u00a0<code>is_incremental()<\/code>\u00a0\u0432\u0435\u0440\u043d\u0435\u0442 False \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c\u00a0<code>1<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0435\u0449\u0435 \u0440\u0430\u0437, \u0442\u043e\u0433\u0434\u0430\u00a0<code>is_incremental()<\/code>\u00a0\u0432\u0435\u0440\u043d\u0435\u0442 True. \u0412\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c sql \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b(<code>this<\/code>\u00a0\u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f dbt, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u00a0<code>Relation<\/code>\u00a0\u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443). \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u0438 \u0432\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u00a0<code>2<\/code>, \u0432 \u0442\u0440\u0435\u0442\u0438\u0439 \u0440\u0430\u0437\u00a0<code>3<\/code>\u00a0\u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u0434\u0435\u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0430-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u00a0<code>raw_source<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u043e \u0442\u0430\u043c \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c\u0441\u044f \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b \u0441\u0442\u0440\u043e\u0447\u0435\u043a. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u043b\u0435\u00a0<code>id<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u0442.\u0435 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u044e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u0434\u0443\u0431\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041c\u044b \u0436\u0435 \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0435\u00a0<code>models<\/code>\u00a0\u0444\u0430\u0439\u043b\u00a0<code>source.yml<\/code>\u00a0\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043e\u043f\u0438\u0448\u0435\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 dbt):<\/p>\n<pre><code class=\"yaml\">version: 2  sources:   - name: raw     schema: public     tables:       - name: raw_source<\/code><\/pre>\n<p>\u0418 \u043e\u043f\u0438\u0448\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c\u00a0<code>stage_source.sql<\/code>:<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='incremental'     ) }}   select distinct on (src.id)     src.* from     {{ source('raw', 'raw_source') }} src {% if is_incremental() %}     left join     {{ this }} dst     on src.id = dst.id where dst.id is null {% endif %}<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 <code>select<\/code> \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"sql\">select distinct on (src.id)     src.* from     \"dbt_intro_db\".\"public\".\"raw_source\" src<\/code><\/pre>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u00a0<code>raw_source<\/code>\u00a0\u0438 \u0434\u0435\u0434\u0443\u0431\u043b\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u043f\u043e\u00a0<code>src.id<\/code><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437:<\/p>\n<pre><code class=\"sql\">select distinct on (src.id)     src.* from     \"dbt_intro_db\".\"public\".\"raw_source\" src     left join     \"dbt_intro_db\".\"public\".\"stage_source\" dst     on src.id = dst.id where dst.id is null<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0436\u0435 \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0449\u0435 \u043d\u0435\u0442 \u0432\u00a0<code>stage_source<\/code>\u00a0\u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u0434\u0443\u0431\u043b\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u043f\u043e \u043a\u043b\u044e\u0447\u0443\u00a0<code>src.id<\/code><\/p>\n<h2>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0432 dbt \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u00a0<code>ref<\/code>,\u00a0<code>source<\/code>\u00a0dbt \u043c\u043e\u0436\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c DAG \u0441\u0432\u044f\u0437\u0435\u0439. \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 ui \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"bash\">dbt docs generate --profiles-dir .\/ --profile dbt_postgres_intro dbt docs serve --profiles-dir .\/ --profile dbt_postgres_intro<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4de\/fca\/704\/4defca704551649d8fe0ec6d88432659.png\" alt=\"\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f DAG\u2019a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0435\u0439\" title=\"\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f DAG\u2019a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0435\u0439\" width=\"3578\" height=\"2078\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4de\/fca\/704\/4defca704551649d8fe0ec6d88432659.png\"\/><figcaption>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f DAG\u2019a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/figcaption><\/figure>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u0444\u0430\u0439\u043b\u0435\u00a0<code>schema.yml<\/code>\u00a0\u043b\u0435\u0436\u0430\u0449\u0438\u043c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0442\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u043e \u0432 ui:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/084\/3bf\/40e\/0843bf40e1549f00c86a02a8dc23abca.png\" alt=\"ui \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\" title=\"ui \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\" width=\"3580\" height=\"2074\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/084\/3bf\/40e\/0843bf40e1549f00c86a02a8dc23abca.png\"\/><figcaption>ui \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/figcaption><\/figure>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0432\u0430\u0441 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439 dbt, \u0435\u0441\u043b\u0438 \u0432\u044b \u043e \u043d\u0435\u0439 \u0435\u0449\u0435 \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u0438\u043b\u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0443\u0436\u0435 \u043f\u0440\u0438\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0441\u044f \u043a \u043d\u0435\u0439.<\/p>\n<p>\u0412 dbt \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u044b, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b. \u041f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0432\u0430\u0448\u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412 \u043c\u044b\u0441\u043b\u044f\u0445 \u0435\u0441\u0442\u044c \u043f\u043b\u0430\u043d\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dbt \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c datavault \u043d\u0430 \u0431\u0430\u0437\u0435 greenplum \u0438 \u043d\u0435 \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c =) \u041d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c\u00a0<a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/588582\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044f<\/a>\u00a0\u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443, \u043d\u043e \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u0435\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0443\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u044f\u043c, \u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u043e\u0440\u043a\u0435\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0432\u0441\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Dagster \u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u043b\u0438:<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438:\u00a0<a href=\"https:\/\/github.com\/markporoshin\/DBTPostgresIntro\" rel=\"noopener noreferrer nofollow\"><u>\u0441\u0441\u044b\u043b\u043a\u0430<\/u><\/a>. <\/p>\n<h2>P.S.<\/h2>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u043e\u043d\u0443\u0441\u0430, \u043c\u044b \u0432 DV Group \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u00a0<code>dbt-postgres<\/code>\u00a0\u0434\u043b\u044f greenplum, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e\u043b\u0435 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u044c\u044e\u0446\u0438\u0438, \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u043f\u0430\u0442\u0440\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435: <a href=\"https:\/\/github.com\/markporoshin\/dbt-greenplum\" rel=\"noopener noreferrer nofollow\"><u>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 GitHub<\/u><\/a>.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/670062\/\"> https:\/\/habr.com\/ru\/post\/670062\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041c\u0430\u0440\u043a \u041f\u043e\u0440\u043e\u0448\u0438\u043d, \u0432 DV Group \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c Data Science. \u041c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u0435\u043c\u0441\u044f \u043a 10\u0442\u0431 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 Greenplum. \u0422\u0430\u043a \u043a\u0430\u043a \u0431\u0438\u0437\u043d\u0435\u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043e\u043b\u043e\u0434\u043e\u0439, \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u043e\u0432, \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0432 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f, \u0434\u0430 \u0438 \u0441\u0430\u043c\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f Data Warehouse \u2014 DataVault. \u0414\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u043d\u044b \u0441\u0432\u043e\u0435\u0439 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c\u044e, \u043e\u0434\u043d\u0430\u043a\u043e \u0446\u0435\u043d\u043e\u0439 \u0437\u0430 \u044d\u0442\u0443 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0430\u0431\u043b\u0438\u0446. \u042d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u0441\u0440\u0430\u0437\u0443 \u043a \u0434\u0432\u0443\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c:<\/p>\n<ul>\n<li>\n<p>\u041d\u0443\u0436\u043d\u0430 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c join-\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0421\u043f\u043e\u0441\u043e\u0431 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0440\u0443\u043a\u0430\u043c\u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0447\u0435\u043d\u044c \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u043e, \u0430 \u0435\u0449\u0435 \u044d\u0442\u043e \u0447\u0440\u0435\u0432\u0430\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 DV Group \u2014\u00a0<a href=\"https:\/\/docs.getdbt.com\" rel=\"noopener noreferrer nofollow\">dbt<\/a>(data build tool), \u043e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u0435\u0431\u044f \u0437\u0430\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>\u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 dbt \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c postgres, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u043d\u0430 \u0441\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u044f \u0431\u0443\u0434\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 PyCharm, \u044d\u0442\u043e \u0432\u043e\u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0442\u0443\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0430\u043c. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 python3 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"bash\">pip install dbt-core==1.1.0 dbt-postgres==1.1.0<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c dbt \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<pre><code class=\"bash\">(venv) \u279c  PostgresDBTIntro dbt init 11:32:18  Running with dbt=1.1.0 Enter a name for your project (letters, digits, underscore): dbt_postgres_intro    Which database would you like to use? [1] postgres  (Don\\'t see the one you want? https:\/\/docs.getdbt.com\/docs\/available-adapters)  Enter a number: 1 11:33:04   Your new dbt project \"dbt_postgres_intro\" was created!<\/code><\/pre>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443 \u0432\u0430\u0441 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0430\u043f\u043a\u0430 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0432\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<h2>\u041f\u0435\u0440\u0432\u044b\u0435 \u0448\u0430\u0433\u0438 \u0432 dbt<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u0444\u0430\u0439\u043b\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<figure class=\"full-width\"><figcaption>\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 dbt<\/figcaption><\/figure>\n<p>\u041f\u043e\u0434 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u043e\u0434\u0438\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u00a0<strong>dbt_project.ym<\/strong>l, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435(vars), \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u0422\u0430\u043a\u0436\u0435 \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0445\u0443\u043a\u0438<strong>\u00a0on-run-start<\/strong>,<strong>\u00a0on-run-end<\/strong>. \u041a \u044d\u0442\u0438\u043c \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044f\u043c \u043c\u044b \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043f\u043e\u0437\u0436\u0435, \u0430 \u0441\u0435\u0439\u0447\u0430\u0441\u00a0\u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0430\u0439\u043b \u043f\u043e\u0434 \u043d\u043e\u043c\u0435\u0440\u043e\u043c 2\u00a0<strong>my_first_dbt_model.sql<\/strong><\/p>\n<pre><code class=\"sql\">\/*     Welcome to your first dbt model!     Did you know that you can also configure models directly within SQL files?     This will override configurations stated in dbt_project.yml      Try changing \"table\" to \"view\" below *\/  {{     config(materialized='table') }}  with source_data as (      select 1 as id     union all     select null as id  )  select * from source_data  \/*     Uncomment the line below to remove records with null `id` values *\/  -- where id is not null<\/code><\/pre>\n<p>\u041f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0431\u043b\u043e\u043a \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432, \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<code>\/* ... *\/<\/code>\u00a0\u0438 \u0432\u0438\u0434\u0438\u043c:<\/p>\n<pre><code class=\"sql\">{{     config(materialized='table') }}<\/code><\/pre>\n<p>DBT \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Jinja, \u043f\u043e\u044d\u0442\u043e\u043c\u0443\u00a0<code>{{ ... }}<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430. \u0412 \u043d\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u00a0macro(\u0447\u0438\u0442\u0430\u0439 \u201c\u0444\u0443\u043d\u043a\u0446\u0438\u044e\u201d) &#8212;\u00a0config, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u00a0<code>materialized<\/code>\u00a0\u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c\u00a0<code>'table'.<\/code> \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u00a0\u043c\u043e\u0434\u0435\u043b\u0438\u00a0\u201cmy_first_dbt_model\u201d, \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0430 (\u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u043d\u0430) \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c, \u043a\u0430\u043a \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430.\u00a0<\/p>\n<p>\u0421\u043b\u0435\u0434\u043e\u043c \u0438\u0434\u0435\u0442 sql \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"sql\">select * from source_data<\/code><\/pre>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0435\u0449\u0435 \u043e\u0434\u043d\u0438\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c.\u041f\u043e\u043a\u0430 \u043c\u044b \u0435\u0449\u0435 \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u043a\u0440\u0435\u0434\u0435\u043d\u0448\u0435\u043d\u044b \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0443 \u043d\u0430\u0448\u0435\u0433\u043e Postgres\u2019a. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0430\u0439\u043b\u0430\u00a0<code>profiles.yml<\/code>. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"yaml\">config:   send_anonymous_usage_stats: False   use_colors: True   partial_parse: True   dbt_postgres_intro:   outputs:     dev:       type: postgres       threads: 3       host: localhost       port: 5432       user: markporoshin       pass: \"&lt;password>\"       dbname: dbt_intro_db       schema: public   target: dev<\/code><\/pre>\n<p>\u042f \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c\u00a0<code>dbt_project.yml<\/code>, \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u044d\u0442\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0434\u0435\u043f\u043b\u043e\u044f. DBT \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438 (<code>\/Users\/&lt;user>\/.dbt\/profiles.yml<\/code>\u00a0\u043d\u0430 mac os). \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0432\u0430\u0448\u0435 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u0438 \u0432 \u043b\u043e\u0433\u0430\u0445 dbt \u043d\u0430\u043f\u0438\u0448\u0435\u0442, \u0433\u0434\u0435 \u043e\u043d \u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u0438\u0449\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u043c\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\">dbt run --project-dir .\/ -m my_first_dbt_model<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u00a0<code>profiles.yml<\/code>\u00a0\u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u044f, \u0432\u044b\u0437\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"bash\">dbt run --project-dir .\/ --profiles-dir .\/ --profile dbt_postgres_intro -m my_first_dbt_model<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c dbt \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u00a0<code>--project-dir .\/<\/code>; \u043f\u0443\u0442\u044c \u043a \u043f\u0430\u043f\u043a\u0435 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c\u00a0profiles.yml\u00a0&#8212;\u00a0<code>--profiles-dir .\/<\/code>; \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u044f\u00a0<code>--profile dbt_postgres_intro<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u0432\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435\u00a0profiles.yml\u00a0\u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438\u043b\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 DEV, PROD)<\/p>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 Postgres dbt \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442 \u0435\u0433\u043e\u00a0<code>create table ... as ...<\/code>\u00a0\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 sql \u043a\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code class=\"sql\">create  table \"dbt_intro_db\".\"public\".\"my_first_dbt_model__dbt_tmp\" as ( with source_data as (     select 1 as id     union all     select null as id ) select * from source_data );<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u0437\u0434\u0435\u0441\u044c \u0447\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435. DBT \u0441\u043e\u0437\u0434\u0430\u043b \u043d\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0443, \u043d\u043e \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0441\u0442\u0444\u0438\u043a\u0441\u00a0<code>__dbt_tmp<\/code>. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e dbt \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0430\u043f\u043e\u0432:<\/p>\n<pre><code class=\"sql\"> -- \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b create  table \"dbt_intro_db\".\"public\".\"my_first_dbt_model__dbt_tmp\" as ( with source_data as (     select 1 as id     union all     select null as id ) select * from source_data );   -- \u0435\u0441\u043b\u0438 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0435\u0435 \u0432 backup alter table \"dbt_intro_db\".\"public\".\"my_first_dbt_model\" rename to \"my_first_dbt_model__dbt_backup\";   -- \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0446\u0435\u043b\u0435\u0432\u0443\u044e alter table \"dbt_intro_db\".\"public\".\"my_first_dbt_model__dbt_tmp\" rename to \"my_first_dbt_model\"  -- \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u044d\u0442\u0430\u043f\u044b \u043f\u0440\u043e\u0448\u043b\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043c\u043e\u0436\u0435\u043c \u0443\u0434\u0430\u043b\u044f\u0442\u044c backup drop table if exists \"dbt_intro_db\".\"public\".\"my_first_dbt_model__dbt_backup\" cascade<\/code><\/pre>\n<p>dbt \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0430 \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u043a \u201c\u0441\u0442\u0430\u0442\u0443\u0441\u0443 \u043a\u0432\u043e\u201d.<\/p>\n<p>\u041f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442 dbt, \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0444\u043b\u0430\u0433\u0430\u00a0<code>-d<\/code>:<\/p>\n<pre><code class=\"bash\">dbt -d run --profiles-dir .\/ --profile dbt_postgres_intro -m my_first_dbt_model<\/code><\/pre>\n<h2>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 dbt<\/h2>\n<p>\u0427\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u044c. \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438\u00a0<code>dbt run<\/code>\u00a0dbt \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<ol>\n<li>\n<p>\u041f\u0430\u0440\u0441\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u0438, \u043c\u0430\u043a\u0440\u043e\u0441\u044b, \u0442\u0435\u0441\u0442\u044b \u0438\u0442\u0434. \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u0435 sql \u0437\u0430\u043f\u0440\u043e\u0441\u044b;<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u044b \u0443\u0436\u0435 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 Jinja \u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a. \u041f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c\u00a0<a href=\"https:\/\/docs.getdbt.com\/reference\/dbt-jinja-functions\/execute\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a>\u00a0\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u043a\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0432 \u0434\u0435\u0431\u0430\u0433\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u0430\u043f\u043a\u0435\u00a0<code>target\/compiled<\/code>(\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438), \u0430 \u0435\u0441\u043b\u0438 \u0431\u044b\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430 \u0441\u0442\u0430\u0434\u0438\u044f run \u0432 \u043f\u0430\u043f\u043a\u0435\u00a0<code>target\/run<\/code>\u00a0\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 sql \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d.<\/p>\n<h2>\u041c\u0430\u0433\u0438\u044f jinja<\/h2>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u201c\u0432\u043a\u0443\u0441\u043d\u043e\u043c\u0443\u201d \u0432 dbt, \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f boilerplate \u043a\u043e\u0434\u0430 \u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c data engineer =).<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e dbt \u043c\u043e\u0434\u0435\u043b\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u043c\u0438:<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='table',     ) }}   select 1 as id, 'Nikita' as name, 'Analytics' as type union select 2 as id, 'Stanislav' as name, 'Analytics' as type union select 3 as id, 'Alex' as name, 'CTO' as type union select 4 as id, 'Artem' as name, 'DevOps' as type union select 5 as id, 'Artem' as name, 'DataScience' as type union select 6 as id, 'Victor' as name, 'Backend' as type union select 7 as id, 'Mark' as name, 'DataEngineer' as type<\/code><\/pre>\n<h3>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/h3>\n<p>\u0412 dbt \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 dbt_projects.yml:<\/p>\n<pre><code class=\"yaml\">vars:   developer_name: \"Nikita\"<\/code><\/pre>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='view',     ) }}   select     id,     type from {{ ref('developers') }} d where d.name = '{{ var('developer_name') }}'<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0442\u0438\u043f\u00a0<code>'view'<\/code>, \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0430 view. \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0431\u0435\u0440\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445\u00a0<code>{{ ref('developers') }}<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b dbt \u043d\u0430\u0448\u0435\u043b \u043c\u043e\u0434\u0435\u043b\u044c\u00a0developers\u00a0\u0438 \u0441\u0430\u043c \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u043f\u0443\u0442\u044c \u043a \u043d\u0435\u0439 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u043b\u0435\u0436\u0438\u0442 \u043d\u0435 \u0432 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u0438\u043b\u0438 \u0434\u043b\u044f \u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d <code>alias<\/code>, \u044d\u0442\u043e \u0432\u0441\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 macro\u00a0config). \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 <code>where<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u00a0<code>var<\/code>\u00a0\u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c dbt \u0438 \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439\u00a0<code>developer_name<\/code>.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='view',     ) }}  {% set type = 'DevOps' %}   select     id,     name from {{ ref('developers') }} d where type = '{{ type }}'<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430\u00a0<code>set<\/code>\u00a0\u0438 \u044d\u043a\u0440\u0430\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u043e \u0432\u0441\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<code>{% \u2026 %}<\/code>.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e \u0432 dbt \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442\u00a0<a href=\"https:\/\/docs.getdbt.com\/docs\/building-a-dbt-project\/jinja-macros\" rel=\"noopener noreferrer nofollow\">\u0442\u0440\u0438 \u0442\u0438\u043f\u0430 \u201c\u044d\u043a\u0440\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438\u201d<\/a>:<\/p>\n<ol>\n<li>\n<p><code>{{ ... }}<\/code>\u00a0\u2014 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b;<\/p>\n<\/li>\n<li>\n<p><code>{% ... %}<\/code>\u00a0\u2014 \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0446\u0438\u043a\u043b\u043e\u0432, \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u0442.\u0434.;<\/p>\n<\/li>\n<li>\n<p><code>{# ... #}<\/code>\u00a0\u2014 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u042f \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u00a0<code>{%- ... -%}<\/code>, \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u0441 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<h3>\u0426\u0438\u043a\u043b\u044b<\/h3>\n<p>\u042f \u0434\u0443\u043c\u0430\u044e \u0443\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Jinja \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0439 \u0432 dbt. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0434\u0435\u043b\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u0446\u0438\u043a\u043b:<\/p>\n<pre><code class=\"sql\">{{     config(         materialized='table',     ) }}   {%- set types = ['Analytics', 'DataScience'] -%}   select     id,     name from     {{ ref('developers') }} where type in (     {%- for type in types -%}         '{{ type }}'         {%- if not loop.last %},{% endif -%}     {%- endfor -%} )<\/code><\/pre>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/h3>\n<p>\u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0430\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043d\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u044b \u0445\u043e\u0442\u0438\u043c <\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-334179","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=334179"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334179\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=334179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=334179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=334179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}