Mage数据管道报错:BigQuery数据集NotFound(404错误)
问题:GCS数据导入BigQuery时数据集不存在错误
我正在学习《Data Engineering Zoomcamp》课程,在第2模块使用mage.ai进行工作流编排(对应视频《ETL: GCS to BigQuery》)时,尝试将Google Cloud Storage中的数据加载至BigQuery,出现以下错误:NotFound: 404 Not found: Dataset mageai-425002:ny_taxi was not found in location US
以下是mage.ai中用于将GCS数据导出至BigQuery的三个脚本/配置:
数据加载器脚本
from mage_ai.settings.repo import get_repo_path from mage_ai.io.config import ConfigFileLoader from mage_ai.io.google_cloud_storage import GoogleCloudStorage from os import path if 'data_loader' not in globals(): from mage_ai.data_preparation.decorators import data_loader if 'test' not in globals(): from mage_ai.data_preparation.decorators import test @data_loader def load_from_google_cloud_storage(*args, **kwargs): """ Template for loading data from a Google Cloud Storage bucket. Specify your configuration settings in 'io_config.yaml'. """ config_path = path.join(get_repo_path(), 'io_config.yaml') config_profile = 'default' bucket_name = 'mage' object_key = 'ny_taxi_data.parquet' return GoogleCloudStorage.with_config(ConfigFileLoader(config_path, config_profile)).load( bucket_name, object_key,)
转换器脚本
if 'transformer' not in globals(): from mage_ai.data_preparation.decorators import transformer if 'test' not in globals(): from mage_ai.data_preparation.decorators import test @transformer def transform(data, *args, **kwargs): data.columns = (data.columns .str.replace(' ', '_') .str.lower()) return data @test def test_output(output, *args) -> None: """ Template code for testing the output of the block. """ assert output is not None, 'The output is undefined'
SQL数据导出器配置
- connection: Bigquery
- profile: default
- schema: ny_taxi
- Table: yellow_cab_data
解决步骤
- 检查GCP项目
mageai-425002下是否存在ny_taxi数据集,若不存在则手动创建,创建时需指定位置为US(与错误提示的位置一致) - 确认SQL数据导出器中的
schema字段值ny_taxi与BigQuery中实际数据集名称完全匹配,注意大小写和拼写 - 验证
io_config.yaml中的BigQuery配置是否正确关联到mageai-425002项目,且配置的服务账号拥有访问该项目BigQuery的权限
内容的提问来源于stack exchange,提问作者npkp
相关产品推荐
相关产品推荐

