Skip to content

BigQueryInsertJobOperator doesn't include BigQuery region/location in deferrable mode #35833

Description

@manhld0206

Apache Airflow version

Other Airflow 2 version (please specify below)

What happened

I tested BigQueryInsertJobOperator with deferrable mode enabled.
I used Google Cloud Composer 2.4.0 with airflow version 2.4.3
The BigQuery's region is asia-northeast1 region. The operator ran fine before but I got Job not found error after enabling deferrable mode. At first I thought it was because I didn't specify location parameter in BigQueryInsertJobOperator. However, even after changing it, I still got the Job not found error.

After taking a quick look at the source code, I guess maybe the cause is BigQuery Trigger doesn't include location in it's parameters.
The code

job_status = await hook.get_job_status(job_id=self.job_id, project_id=self.project_id)

BigQuery get job API doc
Screenshot 2023-11-24 at 16 07 10

What you think should happen instead

No response

How to reproduce

Execute BigQueryInsertJobOperator using asia-northeast1 BigQuery region

Operating System

It's not OS. I used Google Cloud Composer 2.4.0 with airflow version 2.4.3

Versions of Apache Airflow Providers

No response

Deployment

Google Cloud Composer

Deployment details

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. boring-cyborg commented on Nov 24, 2023

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

  2. changed the title [-]BigQuery Operators don't include BigQuery region/location in deferrable mode[/-] [+]BigQuery BigQueryInsertJobOperator doesn't include BigQuery region/location in deferrable mode[/+] on Nov 24, 2023
  3. changed the title [-]BigQuery BigQueryInsertJobOperator doesn't include BigQuery region/location in deferrable mode[/-] [+]BigQueryInsertJobOperator doesn't include BigQuery region/location in deferrable mode[/+] on Nov 24, 2023
  4. eladkal commented on Nov 24, 2023

    @eladkal
    Contributor

    feel free to open PR to address the issue

  5. added and removed
    needs-triagelabel for new issues that we didn't triage yet
    on Nov 24, 2023
  6. kadai0308 commented on Nov 27, 2023

    @kadai0308
    Contributor

    Hi, after go through the code, i think i can fix this issue by pass the location as param at here.
    Can you please assgin the issue to me?

  7. manhld0206 commented on Nov 27, 2023

    @manhld0206
    Author

    I would like to add another note.
    Some other BigQuery operators (For example GCSToBigQueryOperator) might have the same problem as well. Because if the operator uses BigQueryInsertJobTrigger, it won't pass the location param.

  8. manhld0206 commented on Nov 27, 2023

    @manhld0206
    Author

    @kadai0308
    Is it ok for me to take this issue. It will be my first commit ever to airflow but I would like to challenge it!

  9. kadai0308 commented on Nov 27, 2023

    @kadai0308
    Contributor

    @kadai0308 Is it ok for me to take this issue. It will be my first commit ever to airflow but I would like to challenge it!

    Sure, please go ahead.

  10. manhld0206 commented on Nov 29, 2023

    @manhld0206
    Author

    I believe this issue is the same as #29307

    We can't fix it until talkiq/gcloud-aio#584 is resolved

  11. nathadfield commented on Jan 31, 2024

    @nathadfield
    Contributor

    Now that #36849 has been merged, there is no longer a requirement on the talkiq library (and the outstanding PR) to enable impersonation in deferrable mode. This should mean that this issue can now be addressed.

  12. moiseenkov commented on Jan 31, 2024

    @moiseenkov
    Contributor

    Now that #36849 has been merged, there is no longer a requirement on the talkiq library (and the outstanding PR) to enable impersonation in deferrable mode. This should mean that this issue can now be addressed.

    It is really great that aforementioned PR was merged and the impersonation is working well now. However, the described problem is still valid for regions other than US or EU, because the used async client simply doesn't support location when making API call (in contrast sync client supports it). This PR is intended to fix the problem, so after it is merged and gcloud-io-bigquery upgraded, we could fix the problem on our side by simply passing location from the operator to the trigger and than to the async hook.

    Please correct me if I'm wrong.

  13. nathadfield commented on Jan 31, 2024

    @nathadfield
    Contributor

    Ah, yeah, you're right. My misunderstanding.

  14. spencertollefson commented on Feb 16, 2024

    @spencertollefson
    Contributor

    That PR was merged in today and now the 7.1.0 release of gcloud-aio accepts a location param. Seems like with your recent PR @moiseenkov that we may not need to utilize this new param.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions