Skip to content

fix: update outlets and schedule datasets trigger to ODS_USERDATA - #349

Merged
petrCher merged 3 commits into
mainfrom
schepa-branch
Apr 25, 2026
Merged

fix: update outlets and schedule datasets trigger to ODS_USERDATA#349
petrCher merged 3 commits into
mainfrom
schepa-branch

Conversation

@sanycool

Copy link
Copy Markdown
Contributor

Проблема:
DAG union_member_to_backend не запускался по Dataset-триггеру, так как producer (DAG ODS_USER_INFO.info) и consumer использовали разные имена Dataset:

  • producer публиковал ODS_USERDATA
  • consumer ожидал ODS_USERDATA.student_id

Из-за этого Airflow не создавал событие для ожидаемого Dataset, и DAG не триггерился.

Решение:

  • привёл Dataset к одному имени
  • producer теперь публикует ODS_USERDATA
  • consumer ожидает ODS_USERDATA

Copilot AI review requested due to automatic review settings April 24, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an Airflow Dataset-trigger mismatch so the union_member_to_backend DAG is triggered by the dataset event produced by the ODS_USER_INFO.info DAG.

Changes:

  • Updated union_member_to_backend to listen to Dataset("ODS_USERDATA") instead of Dataset("ODS_USERDATA.student_id").
  • Updated ODS_USER_INFO.info producer task to publish Dataset("ODS_USERDATA") as an outlet.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
dags/ods/user/user_to_back.py Aligns the consumer DAG’s Dataset schedule with the producer’s published Dataset name.
dags/ods/user/info.py Changes the producer task’s outlet Dataset to the unified name used by the consumer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dags/ods/user/info.py
# см. info.sql и https://airflow.apache.org/docs/apache-airflow/stable/templates-ref.html#variables
inlets=[Dataset("STG_USERDATA.info"), Dataset("STG_USERDATA.param"), Dataset("STG_UNION_MEMBER.union_member")],
outlets=[Dataset("ODS_USER_INFO.info")],
outlets=[Dataset("ODS_USERDATA")],

Copilot AI Apr 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dataset naming in this repo appears to consistently follow the SCHEMA.table pattern (e.g. ODS_AUTH.user, ODS_RATING.comment, etc.). Introducing a schema-level dataset name without a dot (ODS_USERDATA) is inconsistent and can make lineage/triggering harder to reason about. Consider publishing a table-scoped dataset (e.g. ODS_USERDATA.student_id) or publishing multiple outlets for the tables written in info.sql, and update downstream schedules accordingly.

Suggested change
outlets=[Dataset("ODS_USERDATA")],
outlets=[Dataset("ODS_USERDATA.info")],

Copilot uses AI. Check for mistakes.
Comment thread dags/ods/user/info.py
# см. info.sql и https://airflow.apache.org/docs/apache-airflow/stable/templates-ref.html#variables
inlets=[Dataset("STG_USERDATA.info"), Dataset("STG_USERDATA.param"), Dataset("STG_UNION_MEMBER.union_member")],
outlets=[Dataset("ODS_USER_INFO.info")],
outlets=[Dataset("ODS_USERDATA")],

Copilot AI Apr 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says the producer (DAG ODS_USER_INFO.info) was already publishing ODS_USERDATA, but in this diff the producer outlet is being changed from ODS_USER_INFO.info to ODS_USERDATA. Please update the PR description to reflect the actual before/after state (or clarify why Airflow showed a different produced dataset than what the code had).

Copilot uses AI. Check for mistakes.
with DAG(
dag_id="union_member_to_backend",
schedule=[Dataset("ODS_USERDATA.student_id")],
schedule=[Dataset("ODS_USERDATA")],

Copilot AI Apr 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This DAG’s dataset schedule is now ODS_USERDATA (schema-level). Elsewhere in the repo, dataset-triggering is consistently done at table granularity (SCHEMA.table). To stay consistent and avoid introducing a one-off dataset naming scheme, consider switching back to a table-scoped dataset (e.g. ODS_USERDATA.student_id) and ensuring the producer publishes that same dataset.

Suggested change
schedule=[Dataset("ODS_USERDATA")],
schedule=[Dataset("ODS_USERDATA.student_id")],

Copilot uses AI. Check for mistakes.
@RedstoneEnjoyer

Copy link
Copy Markdown
Collaborator
  • producer публиковал ODS_USERDATA

Уточню: он публиковал ODS_USER_INFO.info т.е. вообще несуществующую в бд схему. А должен был как раз юзердату

@@ -334,7 +334,7 @@ def remove_non_union_members_from_union_group(union_members_ids: list):

with DAG(
dag_id="union_member_to_backend",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хорошо бы в этом даге еще добавить inlets в явном виде, чтобы видеть зависимость на графе

Comment thread dags/ods/user/info.py Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возможно стоит поменять название дага в соответствии с целевой схемой - вопрос на подумать на самом деле

Comment thread dags/ods/user/info.py
# см. info.sql и https://airflow.apache.org/docs/apache-airflow/stable/templates-ref.html#variables
inlets=[Dataset("STG_USERDATA.info"), Dataset("STG_USERDATA.param"), Dataset("STG_UNION_MEMBER.union_member")],
outlets=[Dataset("ODS_USER_INFO.info")],
outlets=[Dataset("ODS_USERDATA")],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image почему кстати тогда этот даг не падал, если у нас в dwh нет ODS_USER_INFO.info?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RedstoneEnjoyer подскажи если знаешь

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inlets и outlets параметры по сути это просто наша договоренность. Airflow не проверяет какие реально схемы заполняются и т.п. поэтому это в наших интересах их писать так чтобы они соответствовали тому как действует даг, но если так не происходит то ничего не случается. Эирфлоу просто будет думать что такой датасет существет

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ок, понял, спасибо

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тогда ждем добавления inlets от @sanycool

@github-actions

Copy link
Copy Markdown

💩 Code linting failed, use black and isort to fix it.

@petrCher
petrCher merged commit 3b346ae into main Apr 25, 2026
2 checks passed
@petrCher
petrCher deleted the schepa-branch branch April 25, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants