bigquery-migration-data-loader
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBigQuery Migration Data Loader
BigQuery 迁移数据加载器
This skill coordinates the automated provisioning of BigQuery datasets, direct
ingestion of staged Parquet files into native BigQuery tables by using the
command, and automated view deployment directly from BigQuery
Migration Service (BQMS) translation output directories (local or Cloud
Storage).
bq load本 skill 编排 BigQuery 数据集的自动预配、通过 直接导入暂存的 Parquet 文件,以及从 BigQuery Migration Service (BQMS) 翻译输出目录(本地或 Cloud Storage)自动部署视图。
bq loadUsage attribution
使用归属说明
MUST READ: Before executing any , REST API, or MCP command, you
MUST read and follow the instructions in
Usage Attribution.
gcloud必须阅读:在执行任何 、REST API 或 MCP 命令前,你必须阅读并遵循 使用归属说明 中的说明。
gcloudBefore you begin
开始之前
-
Google Cloud CLI, project, and location setup: Install the Google Cloud CLI (including theand
gcloudcommand-line tools), confirm that your Google Cloud project has an active Cloud Billing account attached, and configure the target project and default Compute Engine region:bqbashgcloud config set project PROJECT_ID gcloud config set compute/region REGIONsets the default Compute Engine region; thegcloud config set compute/regionCLI does not readbqand defaults tocompute/regionunlessUSis passed on--locationcommands or set inbq(or configured through a project or organization~/.bigqueryrc). BigQuery is retiring the multi-region designation—includingdefault_locationandUSin the single-regions list colocated withEUandus-central1, with no change to existing data residency (see BigQuery locations)—so always pass an expliciteurope-west4on--locationcommands that matches your staged Cloud Storage bucket, as described in step 5 (check regional service availability at Google Cloud locations).bq -
Enable the APIs: Ask the user before enabling APIs, then enable the BigQuery and Cloud Storage APIs (and
bigquery.googleapis.com):storage.googleapis.combashgcloud services enable bigquery.googleapis.com storage.googleapis.com -
Authentication and required IAM roles: Authenticate withand
gcloud auth login(or setgcloud auth application-default loginfor service account authentication). Verify that your identity or service account has the required IAM roles on each resource:GOOGLE_APPLICATION_CREDENTIALS- Grant BigQuery Job User () on the target Google Cloud project.
roles/bigquery.jobUser - Grant BigQuery Data Editor () on the target Google Cloud project (to create new datasets with
roles/bigquery.dataEditor) or on an existing target dataset (to create or overwrite tables and views).bq mk - Grant Storage Object Viewer () on the Cloud Storage bucket holding staged Parquet files and translation metadata.
roles/storage.objectViewer
- Grant BigQuery Job User (
-
Python environment: Ask the user for confirmation before installing Python packages, then install PyYAML in a virtual environment:bash
pip install pyyaml==6.0.2 -
Location, cost, and cleanup: Use the location of your staged Cloud Storage bucket for the dataset and everycommand: the bucket's region for a regional bucket, or
bqorUSfor aEUorUSmulti-region bucket. Default toEUonly when you also choose the bucket location. Loading from a bucket in a different location incurs data transfer charges (see BigQuery locations). Review Google Cloud pricing before loading large datasets or running audit queries. Ask the user for confirmation before deleting temporary staged Parquet files (us-central1) or test datasets (gcloud storage rm -r gs://BUCKET/EXPORT_PREFIX) when no longer needed.bq rm -r -f PROJECT_ID:DATASET_ID
-
Google Cloud CLI、项目和位置设置:安装 Google Cloud CLI(包括和
gcloud命令行工具),确认你的 Google Cloud 项目已绑定有效的 Cloud Billing 账户,并配置目标项目和默认 Compute Engine 区域:bqbashgcloud config set project PROJECT_ID gcloud config set compute/region REGION会设置默认 Compute Engine 区域;gcloud config set compute/regionCLI 不读取bq,除非在compute/region命令中传入bq,或在--location中设置(也可通过项目或组织的~/.bigqueryrc配置),否则默认使用default_location。BigQuery 正在弃用 multi-region 标识——其中包括把US和US与EU和us-central1并列在单一区域列表中的做法——但不会改变现有的数据驻留(请参阅 BigQuery 位置)——因此,始终在europe-west4命令中传入与暂存 Cloud Storage 存储桶匹配的显式bq,如步骤 5 所述(请在 Google Cloud 位置 检查区域服务可用性)。--location -
启用 API:启用前先征得用户同意,然后启用 BigQuery 和 Cloud Storage API(和
bigquery.googleapis.com):storage.googleapis.combashgcloud services enable bigquery.googleapis.com storage.googleapis.com -
身份验证和必需的 IAM 角色:使用和
gcloud auth login进行身份验证(或设置gcloud auth application-default login以使用服务账号认证)。确认你的身份或服务账号在各资源上拥有必需的 IAM 角色:GOOGLE_APPLICATION_CREDENTIALS- 在目标 Google Cloud 项目上授予 BigQuery Job User()。
roles/bigquery.jobUser - 在目标 Google Cloud 项目上授予 BigQuery Data Editor(),以通过
roles/bigquery.dataEditor创建新数据集;或在现有目标数据集上授予该角色,以创建或覆盖表和视图。bq mk - 在保存暂存 Parquet 文件和翻译元数据的 Cloud Storage 存储桶上授予 Storage Object Viewer()。
roles/storage.objectViewer
- 在目标 Google Cloud 项目上授予 BigQuery Job User(
-
Python 环境:安装 Python 包前先请求用户确认,然后在虚拟环境中安装 PyYAML:bash
pip install pyyaml==6.0.2 -
位置、成本和清理:为数据集及每条命令使用暂存 Cloud Storage 存储桶所在的位置:区域存储桶使用存储桶所在区域,
bq或USmulti-region 存储桶则分别使用EU或US。只有在同时选择存储桶位置为EU时,才将其作为默认值。从不同位置的存储桶加载数据会产生数据传输费用(请参阅 BigQuery 位置)。加载大型数据集或运行审计查询前,请查看 Google Cloud 定价。不再需要时,删除临时暂存的 Parquet 文件(us-central1)或测试数据集(gcloud storage rm -r gs://BUCKET/EXPORT_PREFIX)前,请先请求用户确认。bq rm -r -f PROJECT_ID:DATASET_ID
1. Loader workflow overview
1. 加载器工作流概览
The following diagram illustrates the four-stage ingestion and view deployment
pipeline:
mermaid
flowchart TD
subgraph 1. Inputs
A1["Translation Output Directory / Cloud Storage URI<br>gs://bucket/translation_output/metadata/"]
A2["Staged Parquet Files<br>gs://bucket/data_unload/TABLE/*.parquet"]
end
subgraph 2. Ingestion Pipeline
B1["1. Ensure Dataset Exists<br>bq mk --dataset --location=LOCATION DATASET"]
B2["2. Concurrent Parquet Ingestion<br>bq load --source_format=PARQUET --replace=true<br>Auto-creates native tables"]
B3["3. Row Count Audit<br>Print BigQuery Row Counts for Comparison"]
B4["4. Deploy Consumption Views<br>Deploys views directly from consolidated views.sql or relations/"]
end
A1 & A2 --> B1 --> B2 --> B3 --> B4下图展示了四阶段导入与视图部署流水线:
mermaid
flowchart TD
subgraph 1. 输入
A1["翻译输出目录 / Cloud Storage URI<br>gs://bucket/translation_output/metadata/"]
A2["暂存的 Parquet 文件<br>gs://bucket/data_unload/TABLE/*.parquet"]
end
subgraph 2. 导入流水线
B1["1. 确保数据集存在<br>bq mk --dataset --location=LOCATION DATASET"]
B2["2. 并发 Parquet 导入<br>bq load --source_format=PARQUET --replace=true<br>自动创建原生表"]
B3["3. 行数审计<br>输出 BigQuery 行数供比较"]
B4["4. 部署消费视图<br>直接从合并后的 views.sql 或 relations/ 部署视图"]
end
A1 & A2 --> B1 --> B2 --> B3 --> B42. Direct translation output ingestion
2. 直接导入翻译输出
[!TIP] Migration workflow context: Before running the loader, translate source schemas and views into GoogleSQL by using theskill and stage exported source table Parquet files in Cloud Storage. After loading tables and deploying views, compare row counts and data aggregates against the source database.bigquery-migration-sql-translator
The data loader directly consumes BQMS translation output directories (the
flag):
--translation-metadata-dir- Zero-DDL native ingestion: Table schemas are inferred and created
automatically from staged Parquet files during . Inferred types follow the Parquet types, not the translated DDL: naive source timestamps (no time zone) load as
bq loadinstead ofTIMESTAMP, andDATETIMEandSTRING(n)parameters are dropped (see Step 2 in Section 3).NUMERIC(p, s) - Automated object discovery: Base tables and views are auto-discovered
directly from the translation output metadata. Pass the BQMS directory (or its parent), which contains
metadata/files whoseconfig/DATABASE/SCHEMA/*.yamlnames each object (table configs also setsourceNameorexternalTableName; the others are views) and view DDL inexternalTableDdlPath(or a singlerelations/db_DATABASE/schema_SCHEMA/VIEW.sql).views.sql - Automated view deployment: Translated views are deployed directly into
the target dataset with source references rewritten to the target BigQuery
project and dataset. Plain statements are deployed as
CREATE VIEWso that reruns don't fail on existing views.CREATE OR REPLACE VIEW - Flexible Parquet path resolution: Under the (
--parquet-base-uri) flag, the loader automatically checks schema-scoped subfolders (BASE_URI) first if present and falls back to flat table paths (BASE_URI/SCHEMA/TABLE/*.parquet). For example,BASE_URI/TABLE/*.parquetstages a local schema folder of table subfolders undergcloud storage cp -r LOCAL_DIR/SCHEMA gs://BUCKET/data_unload/.data_unload/SCHEMA/ - Single target dataset: All discovered schemas load into one
by table or view name. If tables or views from different source databases or schemas share a name, the loader stops before creating the dataset and lists the conflicting objects; load each schema into its own dataset instead.
--dataset
[!TIP] 迁移工作流上下文:在运行加载器之前,使用skill 将源 schema 和视图转换为 GoogleSQL,并在 Cloud Storage 中暂存导出的源表 Parquet 文件。加载表并部署视图后,将行数和数据聚合结果与源数据库进行比较。bigquery-migration-sql-translator
数据加载器直接使用 BQMS 翻译输出目录( 标志):
--translation-metadata-dir- 零 DDL 原生导入:在 期间,从暂存的 Parquet 文件推断并自动创建表 schema。推断出的类型遵循 Parquet 类型,而不是转换后的 DDL:无时区的源时间戳会加载为
bq load而不是TIMESTAMP,并且会丢弃DATETIME和STRING(n)参数(请参阅第 3 节中的步骤 2)。NUMERIC(p, s) - 自动发现对象:直接从翻译输出元数据中自动发现基础表和视图。传入 BQMS 的 目录(或其父目录),其中包含
metadata/文件,config/DATABASE/SCHEMA/*.yaml用于命名每个对象(表配置还会设置sourceName或externalTableName,其余对象为视图),视图 DDL 位于externalTableDdlPath(或单个relations/db_DATABASE/schema_SCHEMA/VIEW.sql)中。views.sql - 自动部署视图:将转换后的视图直接部署到目标数据集,并将源引用重写为目标 BigQuery 项目和数据集。普通的 语句会部署为
CREATE VIEW,因此重新运行时不会因视图已存在而失败。CREATE OR REPLACE VIEW - 灵活的 Parquet 路径解析:在 (
--parquet-base-uri)标志下,加载器会优先检查按 schema 划分的子文件夹(BASE_URI),如果存在则使用该路径,否则回退到扁平表路径(BASE_URI/SCHEMA/TABLE/*.parquet)。例如,BASE_URI/TABLE/*.parquet会将包含表子文件夹的本地 schema 文件夹暂存到gcloud storage cp -r LOCAL_DIR/SCHEMA gs://BUCKET/data_unload/下。data_unload/SCHEMA/ - 单一目标数据集:所有发现的 schema 都按表名或视图名加载到同一个 中。如果来自不同源数据库或 schema 的表或视图同名,加载器会在创建数据集前停止并列出冲突对象;此时应改为将每个 schema 加载到各自独立的数据集。
--dataset
3. CLI execution interface (bq load
)
bq load3. CLI 执行接口(bq load
)
bq loadStep 1: Provision the target dataset
步骤 1:预配目标数据集
Set the shell variables for your environment, and then create the target
dataset if it doesn't already exist:
bash
PROJECT_ID="PROJECT_ID"
DATASET_ID="DATASET_ID"
LOCATION="LOCATION"
TABLE_NAME="TABLE_NAME"
BUCKET="BUCKET"
PREFIX="data_unload"
bq show --dataset --project_id=${PROJECT_ID} ${DATASET_ID} >/dev/null 2>&1 || \
bq mk --dataset --project_id=${PROJECT_ID} --location=${LOCATION} ${DATASET_ID}Replace the following:
- : the target Google Cloud project ID.
PROJECT_ID - : the target BigQuery dataset ID.
DATASET_ID - : the BigQuery location for the dataset and load jobs (for example,
LOCATION).us-central1 - : the name of the table to load.
TABLE_NAME - : the name of the Cloud Storage bucket that holds the staged Parquet files.
BUCKET
为环境设置 shell 变量,然后在目标数据集尚不存在时创建该数据集:
bash
PROJECT_ID="PROJECT_ID"
DATASET_ID="DATASET_ID"
LOCATION="LOCATION"
TABLE_NAME="TABLE_NAME"
BUCKET="BUCKET"
PREFIX="data_unload"
bq show --dataset --project_id=${PROJECT_ID} ${DATASET_ID} >/dev/null 2>&1 || \
bq mk --dataset --project_id=${PROJECT_ID} --location=${LOCATION} ${DATASET_ID}替换以下变量:
- :目标 Google Cloud 项目 ID。
PROJECT_ID - :目标 BigQuery 数据集 ID。
DATASET_ID - :数据集和加载作业所在的 BigQuery 位置(例如
LOCATION)。us-central1 - :要加载的表名。
TABLE_NAME - :保存暂存 Parquet 文件的 Cloud Storage 存储桶名称。
BUCKET
Step 2: Ingest Parquet tables (auto-creates native table schema)
步骤 2:导入 Parquet 表(自动创建原生表 schema)
Pass so BigQuery selects the smallest compatible type
( → → ) based on each Parquet
column's precision and scale: columns with map to
, columns with (such as ) widen
to , and larger precisions or scales fall back to
:
--decimal_target_types=NUMERIC --decimal_target_types=BIGNUMERIC --decimal_target_types=STRINGNUMERICBIGNUMERICSTRINGDECIMAL(p, s)p - s <= 29, s <= 9NUMERICp - s <= 38, s <= 38DECIMAL(38, 10)BIGNUMERICDECIMAL256STRINGbash
bq load \
--project_id=${PROJECT_ID} \
--location=${LOCATION} \
--source_format=PARQUET \
--replace=true \
--decimal_target_types=NUMERIC \
--decimal_target_types=BIGNUMERIC \
--decimal_target_types=STRING \
${DATASET_ID}.${TABLE_NAME} \
"gs://${BUCKET}/${PREFIX}/${TABLE_NAME}/*.parquet"The flag overwrites the destination table, including its
schema, with the schema inferred from the Parquet files. If you pre-created
tables from translated BQMS DDL statements to preserve target types such as
, , or , either run and then load with
(so that reruns stay idempotent and don't duplicate rows), or
keep and pass an explicit . If you use the loader
template with native columns, also set
in the copied script: by default it
wraps calls in for source columns that
Parquet loads as , which fails on native columns.
--replace=trueJSONINTERVALRANGETRUNCATE TABLE--replace=false--replace=true--schemaJSON_WRAP_JSON_QUERY_WITH_PARSE_JSON = FalseJSON_QUERY()SAFE.PARSE_JSON()JSONSTRINGJSONParquet columns always load as BigQuery , including
naive timestamps (, such as source columns) that the translated DDL maps to ; the wall-clock
values are kept and read as UTC. To restore after loading, rewrite
those columns with , which converts at UTC by default:
TIMESTAMPTIMESTAMPisAdjustedToUTC=falseTIMESTAMP WITHOUT TIME ZONEDATETIMEDATETIMEDATETIME(column)sql
CREATE OR REPLACE TABLE `PROJECT_ID.DATASET_ID.TABLE_NAME` AS
SELECT * REPLACE (DATETIME(created_at) AS created_at)
FROM `PROJECT_ID.DATASET_ID.TABLE_NAME`;传入 ,使 BigQuery 根据每个 Parquet 列的精度和小数位选择兼容的最小类型( → → ):满足 的列映射为 ,满足 的列(例如 )扩展为 ,更大的 精度或小数位则回退为 :
--decimal_target_types=NUMERIC --decimal_target_types=BIGNUMERIC --decimal_target_types=STRINGDECIMAL(p, s)NUMERICBIGNUMERICSTRINGp - s <= 29, s <= 9NUMERICp - s <= 38, s <= 38DECIMAL(38, 10)BIGNUMERICDECIMAL256STRINGbash
bq load \
--project_id=${PROJECT_ID} \
--location=${LOCATION} \
--source_format=PARQUET \
--replace=true \
--decimal_target_types=NUMERIC \
--decimal_target_types=BIGNUMERIC \
--decimal_target_types=STRING \
${DATASET_ID}.${TABLE_NAME} \
"gs://${BUCKET}/${PREFIX}/${TABLE_NAME}/*.parquet"--replace=trueJSONINTERVALRANGETRUNCATE TABLE--replace=false--replace=true--schemaJSON_WRAP_JSON_QUERY_WITH_PARSE_JSON = FalseSTRINGJSONJSON_QUERY()SAFE.PARSE_JSON()JSONParquet 列始终会加载为 BigQuery ,包括无时区时间戳(,例如源 列),即使转换后的 DDL 将其映射为 。原始时钟值会被保留,并按 UTC 读取。要在加载后恢复为 ,请使用 重写这些列;该函数默认按 UTC 转换:
TIMESTAMPTIMESTAMPisAdjustedToUTC=falseTIMESTAMP WITHOUT TIME ZONEDATETIMEDATETIMEDATETIME(column)sql
CREATE OR REPLACE TABLE `PROJECT_ID.DATASET_ID.TABLE_NAME` AS
SELECT * REPLACE (DATETIME(created_at) AS created_at)
FROM `PROJECT_ID.DATASET_ID.TABLE_NAME`;Step 3: Run a row-count audit
步骤 3:运行行数审计
Count the rows in the loaded table so that you can compare the result with the
source table:
bash
bq query \
--project_id=${PROJECT_ID} \
--location=${LOCATION} \
--use_legacy_sql=false \
"SELECT '${TABLE_NAME}' AS table_name, count(*) AS row_count FROM \`${PROJECT_ID}\`.\`${DATASET_ID}\`.\`${TABLE_NAME}\`;"统计已加载表中的行数,以便将结果与源表进行比较:
bash
bq query \
--project_id=${PROJECT_ID} \
--location=${LOCATION} \
--use_legacy_sql=false \
"SELECT '${TABLE_NAME}' AS table_name, count(*) AS row_count FROM \`${PROJECT_ID}\`.\`${DATASET_ID}\`.\`${TABLE_NAME}\`;"4. Automated loader asset template (assets/bq_loader_template.py
)
assets/bq_loader_template.py4. 自动化加载器资产模板(assets/bq_loader_template.py
)
assets/bq_loader_template.pyThis skill provides an [automated BigQuery loader template][loader_template]
() for dataset creation, concurrent Parquet
loading, direct view deployment, and table row-count auditing.
assets/bq_loader_template.py此 skill 提供了一个[自动化 BigQuery 加载器模板][loader_template](),用于创建数据集、并发加载 Parquet、直接部署视图和审计表行数。
assets/bq_loader_template.pyAgent workflow: Copy, conditionally customize, and execute
Agent 工作流:复制、按需定制并执行
-
Copy the asset template: Always instruct the user to copy the [automated BigQuery loader template][loader_template] () from this skill's directory (
assets/bq_loader_template.py) into their working directory (SKILL_DIR) by using the./bq_loader.pycommand—never write, synthesize, or inline a custom Python loader script from scratch, and never paste or re-type the template contents into the response. The template already handles quote-aware SQL splitting, destination name collision checks, chunked row-count audits, and multi-pass view retries, which a rewritten script would likely miss.cpis the directory containing thisSKILL_DIR:SKILL.mdbashcp SKILL_DIR/assets/bq_loader_template.py ./bq_loader.py -
Conditionally customize extension points: Run the copy as-is. Modify it only if one of the following applies (prefer editing the markedsections;
# CUSTOMIZE:sections can be kept unchanged unless deeper orchestration adjustments are needed):# DEFAULT SCAFFOLDING- Schema overrides and partitioning (): Add custom
# CUSTOMIZE: Schema Overrides & Partitioningflags (such asbq load,--time_partitioning_field, or explicit schema JSON files) inside--clustering_fields.load_parquet_table() - Custom view rewriting (): Adjust view SQL regular expressions, cross-project dataset mapping rules, or retry bounds in
# CUSTOMIZE: Custom View Rewriting & Deploymentand_rewrite_view_sql(). Setdeploy_views()if you pre-created tables with native_WRAP_JSON_QUERY_WITH_PARSE_JSON = Falsecolumns.JSON - Connection and CLI wrapper (): Pass custom
# CUSTOMIZE: Connection & CLI WrapperCLI flags (for example,bqin--default_kms_key, orensure_dataset()and--destination_kms_keyin--reservation_idandload_parquet_table()).execute_sql() - Post-load auditing (): Extend
# CUSTOMIZE: Post-Load Auditingwith custom data integrity or column-level checksum queries.audit_row_counts()
- Schema overrides and partitioning (
-
Execute the script in your working directory: Run the copied script against a Cloud Storage URI or a local translation output folder:bash
# Direct from a Cloud Storage translation_output URI with concurrency: python3 ./bq_loader.py \ --project "PROJECT_ID" \ --dataset "DATASET_ID" \ --location "LOCATION" \ --translation-metadata-dir "gs://BUCKET/translation_output/metadata/" \ --parquet-base-uri "gs://BUCKET/data_unload/" \ --concurrency 8 # Using local translation output folder: python3 ./bq_loader.py \ --project "PROJECT_ID" \ --dataset "DATASET_ID" \ --location "LOCATION" \ --translation-metadata-dir "TRANSLATION_OUTPUT/metadata" \ --parquet-base-uri "gs://BUCKET/data_unload/" \ --concurrency 4When a view depends on another view, the first batch and first pass printerrors such asbqfor the dependent view. These errors are expected if the run ends withNot found: Table ...All N views successfully deployed across M passes.
-
复制资产模板:始终指导用户使用命令,将此 skill 目录(
cp)中的[自动化 BigQuery 加载器模板][loader_template](SKILL_DIR)复制到其工作目录(assets/bq_loader_template.py)——绝不从头编写、合成或内联自定义 Python 加载器脚本,也绝不将模板内容粘贴或重新键入回复中。模板已经处理了可识别引号的 SQL 拆分、目标名称冲突检查、分块行数审计和多轮视图重试,重写脚本很可能会遗漏这些处理。./bq_loader.py是包含此SKILL_DIR的目录:SKILL.mdbashcp SKILL_DIR/assets/bq_loader_template.py ./bq_loader.py -
按需定制扩展点:先按原样运行复制后的脚本。仅在以下情况之一适用时修改;优先编辑标记为的部分,除非需要更深层的编排调整,否则
# CUSTOMIZE:部分可以保持不变:# DEFAULT SCAFFOLDING- Schema 覆盖和分区():在
# CUSTOMIZE: Schema Overrides & Partitioning中添加自定义load_parquet_table()标志,例如bq load、--time_partitioning_field或显式 schema JSON 文件。--clustering_fields - 自定义视图重写和部署():在
# CUSTOMIZE: Custom View Rewriting & Deployment和_rewrite_view_sql()中调整视图 SQL 正则表达式、跨项目数据集映射规则或重试次数上限。如果已预先创建包含原生deploy_views()列的表,请将JSON设为_WRAP_JSON_QUERY_WITH_PARSE_JSON。False - 连接与 CLI 包装器():传入自定义
# CUSTOMIZE: Connection & CLI WrapperCLI 标志,例如在bq中使用ensure_dataset(),或在--default_kms_key和load_parquet_table()中使用execute_sql()和--destination_kms_key。--reservation_id - 加载后审计():使用自定义数据完整性或列级校验和查询扩展
# CUSTOMIZE: Post-Load Auditing。audit_row_counts()
- Schema 覆盖和分区(
-
在工作目录中执行脚本:针对 Cloud Storage URI 或本地翻译输出文件夹运行复制后的脚本:bash
# Directly from a Cloud Storage translation_output URI with concurrency: python3 ./bq_loader.py \ --project "PROJECT_ID" \ --dataset "DATASET_ID" \ --location "LOCATION" \ --translation-metadata-dir "gs://BUCKET/translation_output/metadata/" \ --parquet-base-uri "gs://BUCKET/data_unload/" \ --concurrency 8 # Using local translation output folder: python3 ./bq_loader.py \ --project "PROJECT_ID" \ --dataset "DATASET_ID" \ --location "LOCATION" \ --translation-metadata-dir "TRANSLATION_OUTPUT/metadata" \ --parquet-base-uri "gs://BUCKET/data_unload/" \ --concurrency 4当一个视图依赖另一个视图时,第一批和第一轮会输出错误,例如bq。如果运行最终显示Not found: Table ...,则这些错误属于预期情况。All N views successfully deployed across M passes.
Arguments
参数
- (Required): Google Cloud project ID.
--project - (Required): Target BigQuery dataset name.
--dataset - (Required): Base Cloud Storage URI containing table Parquet subfolders (
--parquet-base-uri).gs://BUCKET/path/ - (Required): Local folder or Cloud Storage URI to translation output metadata directory. Auto-discovers tables and views.
--translation-metadata-dir - (Optional, Default:
--location): Target BigQuery location.us-central1 - (Optional, Default:
--concurrency): Number of parallel workers for concurrent4operations.bq load
- (必需):Google Cloud 项目 ID。
--project - (必需):目标 BigQuery 数据集名称。
--dataset - (必需):包含表 Parquet 子文件夹的基础 Cloud Storage URI(
--parquet-base-uri)。gs://BUCKET/path/ - (必需):翻译输出元数据目录的本地文件夹或 Cloud Storage URI。自动发现表和视图。
--translation-metadata-dir - (可选,默认值:
--location):目标 BigQuery 位置。us-central1 - (可选,默认值:
--concurrency):并发执行4操作的并行工作进程数。bq load