Skip to content

Conversation

@obarisk
Copy link
Contributor

@obarisk obarisk commented Aug 31, 2025

related: #53634 #55073 #55092

In airflow 3, logcial_date is not available for asset triggered DAG runs.
However, it was previously used for job ID generation in Bigquery and workflow ID for Workflows.

This PR proposes using dag_run.run_after as a substitute for asset triggered DAG runs.

In this PR, I propose to use dagrun.run_after for asset triggered dag run.

Summary of the PR

  1. HiveOperator: raise error if logical_date is None (as is), and provide more information in the error message
  2. GoogleCloudComposer: raise an error if logical_date is None
  3. BigQueryHook.generate_job_id:
    • for airflow >= 3.0, add deprecated warning calls with logical_date is not None
    • add a new argument run_after with default value = None (for backwards compatibility)
  4. Operators that use BigqueryHook.generate_job_id: for AIRFLOW_V_3_0_PLUS, use dag_run.run_after.

What Wasn't Fixed

The usage of context["logical_date"] in providers/google/cloud/sensors/cloud_composer.py remains unchangeed.

cc: @kaxil. this is related to #55073 but cover move on

  • workflow
  • gcs_to_bigquery
  • bigquery_to_gcs

@boring-cyborg boring-cyborg bot added area:providers provider:apache-hive provider:google Google (including GCP) related issues labels Aug 31, 2025
Copy link
Contributor

@MaksYermak MaksYermak left a comment

Choose a reason for hiding this comment

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

@obarisk you have changed logical_date for workflow and bigquery operators. Is it all operators which use logical_date or do we have more?

@obarisk
Copy link
Contributor Author

obarisk commented Sep 1, 2025

@MaksYermak as far as I know, in airflow codebase, despite the tests,

after this PR, there's no context["logical_date"] for all of the providers.

@Lee-W Lee-W self-requested a review September 1, 2025 14:45
* fix: logical_date or run_after for google bigquery and workflow. use deprecation
* update variable naming, warning and error messages
@obarisk
Copy link
Contributor Author

obarisk commented Sep 9, 2025

PR updated. I've update the description of the PR.

@jroachgolf84
Copy link
Collaborator

@obarisk - do you need any help getting this over the finish line? Seems like there is another issue that would benefit from this being merged.

@obarisk
Copy link
Contributor Author

obarisk commented Oct 9, 2025

The tests did pass. It's waiting for review now. cc: @jroachgolf84.

Need the maintainers to review and merge.

@obarisk
Copy link
Contributor Author

obarisk commented Oct 9, 2025

by the way, before it got merged I'm currently using workaround like the following.
patch that in the dag file which use the operators.

from dowhen import when

def patch_logical_date(_frame):
  import pendulum # noqa
  context = _frame.f_locals.get("context", {})
  if not context:
    print("no context found")
  if context.get("logical_date") is None:
    context["logical_date"] = pendulum.now("UTC")
    _frame.f_locals["context"] = context

when(
  GCSToBigQueryOperator.execute,
  """logical_date=context["logical_date"]"""
).do(patch_logical_date)

@obarisk
Copy link
Contributor Author

obarisk commented Oct 11, 2025

@Lee-W beside changing the signature of generate_job_id, all updated

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

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

a few nits. but I'm good with merging it. I'll keep it open for a few days in case others want to take a deeper look

@shahar1
Copy link
Contributor

shahar1 commented Oct 14, 2025

Tests fail :(

obarisk and others added 3 commits October 15, 2025 11:46
@Lee-W Lee-W merged commit 65fec59 into apache:main Oct 15, 2025
80 checks passed
@obarisk obarisk deleted the fix/context_logical_date branch October 15, 2025 23:46
snreddygopu pushed a commit to Teradata/airflow that referenced this pull request Oct 16, 2025
… google workflow operator (apache#55110)

Co-authored-by: Wei Lee <weilee.rx@gmail.com>
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 17, 2025
… google workflow operator (apache#55110)

Co-authored-by: Wei Lee <weilee.rx@gmail.com>
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 19, 2025
… google workflow operator (apache#55110)

Co-authored-by: Wei Lee <weilee.rx@gmail.com>
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
TyrellHaywood pushed a commit to TyrellHaywood/airflow that referenced this pull request Oct 22, 2025
… google workflow operator (apache#55110)

Co-authored-by: Wei Lee <weilee.rx@gmail.com>
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants