Skip to content

apache-airflow-providers-common-sql==1.3.0 breaks BigQuery operators #27838

Description

@oliviervg1

Apache Airflow version

Other Airflow 2 version (please specify below)

What happened

Airflow version: 2.3.4 (Cloud Composer 2.0.32)

Issue: apache-airflow-providers-common-sql==1.3.0 breaks all BigQuery operators provided by the apache-airflow-providers-google==8.4.0 package. The error is as follows:

Broken DAG: [/home/airflow/gcs/dags/test-dag.py] Traceback (most recent call last):
  File "/home/airflow/gcs/dags/test-dag.py", line 6, in <module>
    from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator
  File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/google/cloud/operators/bigquery.py", line 35, in <module>
    from airflow.providers.common.sql.operators.sql import (
ImportError: cannot import name '_get_failed_checks' from 'airflow.providers.common.sql.operators.sql' (/opt/python3.8/lib/python3.8/site-packages/airflow/providers/common/sql/operators/sql.py)

Why this issue is tricky: other providers such as apache-airflow-providers-microsoft-mssql==3.3.0 and apache-airflow-providers-oracle==3.5.0 have a dependency on apache-airflow-providers-common-sql>=1.3.0 and will therefore install it when adding to the Composer environment

Current mitigation: Downgrade provider packages such that apache-airflow-providers-common-sql==1.2.0 is installed instead

What you think should happen instead

A minor version upgrade of apache-airflow-providers-common-sql (1.2.0 to 1.3.0) should not break other providers (e.g. apache-airflow-providers-google==8.4.0)

How to reproduce

  • Deploy fresh deployment of Composer composer-2.0.32-airflow-2.3.4
  • Install apache-airflow-providers-common-sql==1.3.0 via Pypi package install feature
  • Deploy a dag that uses one of the BigQuery operators, such as
import airflow

from airflow import DAG
from datetime import timedelta

from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator


default_args = {
    'start_date': airflow.utils.dates.days_ago(0),
    'retries': 1,
    'retry_delay': timedelta(minutes=5)
}

dag = DAG(
    'test-dag',
    default_args=default_args,
    schedule_interval=None,
    dagrun_timeout=timedelta(minutes=20))

t1 = BigQueryExecuteQueryOperator(
    ...
)

Operating System

Ubuntu 18.04.6 LTS

Versions of Apache Airflow Providers

  • apache-airflow-providers-apache-beam @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_apache_beam-4.0.0-py3-none-any.whl
  • apache-airflow-providers-cncf-kubernetes @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_cncf_kubernetes-4.4.0-py3-none-any.whl
  • apache-airflow-providers-common-sql @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_common_sql-1.3.0-py3-none-any.whl
  • apache-airflow-providers-dbt-cloud @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_dbt_cloud-2.2.0-py3-none-any.whl
  • apache-airflow-providers-ftp @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_ftp-3.1.0-py3-none-any.whl
  • apache-airflow-providers-google @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_google-8.4.0-py3-none-any.whl
  • apache-airflow-providers-hashicorp @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_hashicorp-3.1.0-py3-none-any.whl
  • apache-airflow-providers-http @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_http-4.0.0-py3-none-any.whl
  • apache-airflow-providers-imap @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_imap-3.0.0-py3-none-any.whl
  • apache-airflow-providers-mysql @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_mysql-3.2.1-py3-none-any.whl
  • apache-airflow-providers-postgres @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_postgres-5.2.2-py3-none-any.whl
  • apache-airflow-providers-sendgrid @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_sendgrid-3.0.0-py3-none-any.whl
  • apache-airflow-providers-sqlite @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_sqlite-3.2.1-py3-none-any.whl
  • apache-airflow-providers-ssh @ file:///usr/local/lib/airflow-pypi-dependencies-2.3.4/python3.8/apache_airflow_providers_ssh-3.2.0-py3-none-any.whl

Deployment

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 22, 2022

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template!

  2. oliviervg1 commented on Nov 22, 2022

    @oliviervg1
    ContributorAuthor

    Apologies - just noticed there's a separate template for bug reports related to providers. If someone could update the labels, that would be grand :)

  3. oliviervg1 commented on Nov 22, 2022

    @oliviervg1
    ContributorAuthor

    One option to fix this would be to backport this commit and create a hotfix version 8.4.1 of the Google provider package.

  4. Taragolis commented on Nov 22, 2022

    @Taragolis
    Contributor

    Did you tried apache-airflow-providers-google==8.5.0 ?

  5. oliviervg1 commented on Nov 22, 2022

    @oliviervg1
    ContributorAuthor

    @Taragolis that would be the ideal fix... as I can see that the issue is fixed on that release.

    Cloud Composer 2.0.32 doesn't seem to like that though. apache-airflow-providers-google==8.5.0 pulls in a new version of google-cloud-compute, which itself wants to pull in new version of other dependencies that aren't compatible with the other GCP SDK packages...

    Error message below:

    + python3 -m pip check
    google-cloud-compute 1.6.1 has requirement google-api-core[grpc]<3.0.0dev,>=2.10.2, but you have google-api-core 2.8.1.
    google-cloud-compute 1.6.1 has requirement proto-plus<2.0.0dev,>=1.22.0, but you have proto-plus 1.19.6.
    google-cloud-compute 1.6.1 has requirement protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5, but you have protobuf 3.20.0.
    The command '/bin/sh -c bash installer.sh $COMPOSER_PYTHON_VERSION  fail' returned a non-zero code: 1
    
  6. oliviervg1 commented on Nov 22, 2022

    @oliviervg1
    ContributorAuthor

    Here's the full log from the Cloud Build job that Composer triggers when explicitly installing apache-airflow-providers-google==8.5.0.

    log-147b69f4-e83c-4ac9-a109-8d20f14e2c02.txt

  7. eladkal commented on Nov 22, 2022

    @eladkal
    Contributor

    A minor version upgrade of apache-airflow-providers-common-sql (1.2.0 to 1.3.0) should not break other providers (e.g. apache-airflow-providers-google==8.4.0)

    The issue is not with sql provider. From the sql provider perspective only feature was added thus it's just a feature release.
    If this becomes a breaking change in other package (other provider) than this package needs to have a major release.

    In Airflow we support only latest releases so if there is no issue with latest release then there is no issue. If this causes problems due to Compose limitations then I think it's best to contact Composer support.

    That said, if one wants to fix previous version - it is possible. The procedure is documented on https://github.com/apache/airflow#release-process-for-providers and if someone is willing to backport a fix we can release 8.4.1

    If we made a mistake and we should have release google provider version 9.0.0 rather than 8.5.0 we can yank the wrong version and release a new one (but at least from the description at the moment I'm not sure this is the case?)

  8. oliviervg1 commented on Nov 22, 2022

    @oliviervg1
    ContributorAuthor

    @eladkal that's a fair assessment and I don't think you need to yank version 8.5.0 given that it's compatible with the sql provider.

    I guess that the real underlying problem is that it's currently not straight forward to get version 8.5.0 of the Google provider installed on the latest release of Cloud Composer as per #27838 (comment)

  9. eladkal commented on Nov 22, 2022

    @eladkal
    Contributor

    That is a question for Composer support then :)
    I would like also to point that hopefully someone from Google will take ownership over #15933 the dependencies of this provider are too coupled. It should be several independent packages (Like for example the Apache provider)

  10. potiuk commented on Nov 22, 2022

    @potiuk
    Member

    The issue is with how past bigquery providers mis-used protected method of the common-sql provider, indeed. Unfortunately, the only way to fix it, is to bring the method back in 1.3.1 and yank common.sql 1.3.0, because this mis-use made common.sql provider 1.3.0 backwards-incompatible.

    I am afraid it is on us rather than on Composer team, because the problem is with the google provider versions we release and maintain. We cannot break older released google provider versions by installing new version of common.sql provider which is not backwrds-compatible (and in this case unfortunately OUR google provider made use of something that OUR common.sql provider thought was an internal detail. In any case it is OUR problem to solve. I will release common.sql

    It is what it is, unfortunately, and one more learning that in case of common code like that we need to be extra careful and in the future we should use __ (double underscore) methods for internal commnds rather than _ because the _ methods are not sufficiently protected agains accidental mis-use.

  11. potiuk commented on Nov 22, 2022

    @potiuk
    Member

    Cool - I'll poke some people on the Google side to see what we can do :)

    I think not much. It will have to wait for 1.3.1 release of common.sql provider.

  12. oliviervg1 commented on Nov 22, 2022

    @oliviervg1
    ContributorAuthor

    Thanks @potiuk. Let me know if there's anything I can help with!

    That said, I appreciate where @eladkal is coming from. I'll poke some folks on the Google side to see if they can engage with #15933.

  13. potiuk commented on Nov 22, 2022

    @potiuk
    Member

    That said, I appreciate where @eladkal is coming from. I'll poke some folks on the Google side to see if they can engage with #15933.

    Just be aware tht this is something that at very least take months once seriously started. The experience with separating common.sql provider had shown something that I knew is difficult. I chose common.sql as the case of seeing where separating common code and reusing it across several providers leads to. This i think 4th or 5th issue with common.sql provider that we discovered as result of this experiment - the fact is that making common code into a separate packages leads to exactly this kind of problems - the code is closely coupled (implicitly), yet we want to make sure that the code should evolve, And it is extremely difficult to make sure that we will prevent and handle all such problems.

    And splitting the Google provider in similar fashion like common sql will lead to many, many, many more problems/couplings like that.

    There is far more common code in google provider between multiple entitiies, and there will be many more such implicit dependencies that we (or Google) will miss. This is quite a difficult tasks (And now I know it not by intuition but also by seing what happened with common.sql case). If anything, the common.sql experience have reinforced my believe splitting google provider might simply never happen because no-one will be brave enough to take on the task.

  14. 27 remaining items

  15. added a commit that references this issue on Jan 30, 2023
    09b9318
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions