Skip to content

Add label join flag to custom json for airflow #775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions api/python/ai/chronon/airflow_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ def _set_join_deps(join):
# Update the metadata customJson with dependencies
_dedupe_and_set_airflow_deps_json(join, deps)

# Set the t/f flag for label_join
_set_label_join_flag(join)


def _set_group_by_deps(group_by):
if not group_by.sources:
Expand All @@ -170,6 +173,16 @@ def _set_group_by_deps(group_by):
_dedupe_and_set_airflow_deps_json(group_by, deps)


def _set_label_join_flag(join):
existing_json = join.metaData.customJson or "{}"
json_map = json.loads(existing_json)
label_join_flag = False
if join.labelParts:
label_join_flag = True
json_map["label_join"] = label_join_flag
join.metaData.customJson = json.dumps(json_map)


def _dedupe_and_set_airflow_deps_json(obj, deps):
sorted_items = [tuple(sorted(d.items())) for d in deps]
# Use OrderedDict for re-producible ordering of dependencies
Expand Down
3 changes: 2 additions & 1 deletion api/python/test/sample/joins/sample_team/sample_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
JoinPart,
)
from ai.chronon.repo.constants import RunMode
from ai.chronon.types import EnvironmentVariables
from ai.chronon.types import EnvironmentVariables, LabelParts

v1 = Join(
left=test_sources.staging_entities,
Expand All @@ -33,6 +33,7 @@
}
),
online=True,
label_part=LabelParts([JoinPart(group_by=sample_group_by.v1)], 1, 1)
)

never = Join(
Expand Down