apache/beam · error · ImportError
Bigquery dependencies are not installed.
Error message
Bigquery dependencies are not installed.
What it means
fetch_metric_data in load_test_perf_analysis.py imports google-cloud-bigquery lazily; if the import failed (bigquery is None), it raises ImportError when it needs a BigQuery client. This guards against executing the perf-analysis query without the required dependency installed.
Solutions
- Install with GCP extras: pip install 'apache-beam[gcp]'
- Install the missing package directly: pip install google-cloud-bigquery
- Run the analysis in an environment (container/VM) that includes Beam's gcp extra requirements
Example fix
// before pip install apache-beam // after pip install 'apache-beam[gcp]'
Defensive patterns
Strategy: validation
Validate before calling
try:
import google.cloud.bigquery # noqa
except ImportError:
raise SystemExit("Install GCP deps: pip install 'apache-beam[gcp]'") Type guard
def bigquery_available() -> bool:
import importlib.util
return importlib.util.find_spec('google.cloud.bigquery') is not None Try / catch
try:
metric_data = analyzer.fetch_metric_data(test_config=config)
except ImportError as e:
if 'Bigquery dependencies are not installed' in str(e):
logging.error("Run: pip install 'apache-beam[gcp]'")
else:
raise Prevention
- Install Beam with the [gcp] extra in analysis environments
- Check for the google.cloud.bigquery module early in scripts
- Use the official Beam load-test container image for analysis jobs
When it happens
Trigger: Running the analyzer in an environment where apache-beam was installed without gcp extras (pip install apache-beam without [gcp]), so google.cloud.bigquery is unavailable and the `bigquery` import resolved to None.
Common situations: CI or local environments lacking the gcp extra; slim Docker images for Beam workers used to run the analyzer; dependencies pruned to reduce image size.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Bigquery dependencies are not installed.
- test_name not provided in config.
- A BigQuery table or a query must be specified
- Azure dependencies are not installed. Unable to run.
- BigQuery source must be split before being read
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/f2ff3b9e4e9dddfc.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/testing/analyzers/load_test_perf_analysis.py:55
"""
def fetch_metric_data(
self, *, test_config: TestConfigContainer) -> MetricContainer:
if test_config.test_name:
test_name, pipeline_name = test_config.test_name.split(',')
else:
raise Exception("test_name not provided in config.")
query = f"""
SELECT timestamp, metric.value
FROM {test_config.project}.{test_config.metrics_dataset}.{test_config.metrics_table}
CROSS JOIN UNNEST(metrics) AS metric
WHERE test_name = "{test_name}" AND pipeline_name = "{pipeline_name}" AND metric.name = "{test_config.metric_name}"
ORDER BY timestamp DESC
LIMIT {constants._NUM_DATA_POINTS_TO_RUN_CHANGE_POINT_ANALYSIS}
"""
logging.debug("Running query: %s" % query)
if bigquery is None:
raise ImportError('Bigquery dependencies are not installed.')
client = bigquery.Client()
query_job = client.query(query=query)
metric_data = query_job.result().to_dataframe()
if metric_data.empty:
logging.error(
"No results returned from BigQuery. Please check the query.")
return MetricContainer(
values=metric_data['value'].tolist(),
timestamps=metric_data['timestamp'].tolist(),
)
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
load_test_metrics_fetcher = LoadTestMetricsFetcher()
parser = argparse.ArgumentParser()
parser.add_argument(View on GitHub (pinned to 12126d8942)