diff --git a/providers/google/src/airflow/providers/google/cloud/hooks/dataflow.py b/providers/google/src/airflow/providers/google/cloud/hooks/dataflow.py index 46788acb3cda6..2fb217a1729d6 100644 --- a/providers/google/src/airflow/providers/google/cloud/hooks/dataflow.py +++ b/providers/google/src/airflow/providers/google/cloud/hooks/dataflow.py @@ -50,8 +50,20 @@ from googleapiclient.discovery import Resource, build from airflow.exceptions import AirflowProviderDeprecationWarning -from airflow.providers.apache.beam.hooks.beam import BeamHook, BeamRunnerType, beam_options_to_args -from airflow.providers.common.compat.sdk import AirflowException, timeout +from airflow.providers.common.compat.sdk import ( + AirflowException, + AirflowOptionalProviderFeatureException, + timeout, +) + +try: + from airflow.providers.apache.beam.hooks.beam import BeamHook, BeamRunnerType, beam_options_to_args +except ImportError as e: + raise AirflowOptionalProviderFeatureException( + "Failed to import apache-airflow-providers-apache-beam. " + "To use the Dataflow service with Apache Beam pipelines, please install the apache-beam provider: " + "pip install apache-airflow-providers-apache-beam" + ) from e from airflow.providers.google.common.hooks.base_google import ( PROVIDE_PROJECT_ID, GoogleBaseAsyncHook,