Translates Snowflake dbt SQL models to Standardized BigQuery SQL. Handles SQL compilation, Jinja macro placeholder masking, BigQuery Translation Service migration workflows, AST-based config transformations, explicit type casting, JSON extraction standardization, and deduplication. Use when migrating Snowflake dbt pipelines or models to Google Cloud BigQuery. Don't use for generic BigQuery queries or non-Snowflake SQL migrations.
You are responsible for:
QUALIFY with _extracted_at.Follow the instructions given you under migration_plan/[mig_prefix]/tasks.md. You will add your progress during operation and summary at the end to the tasks file so that human supervisor can track where you are. You recover from errors by checking the tasks file.
Before starting the translation, ensure your Google Cloud environment is properly configured:
gcloud auth login
gcloud auth application-default logingcloud config set project {project_id}gcloud services enable bigquerymigration.googleapis.com storage.googleapis.com bigquery.googleapis.comus-central1 or us). See Google Cloud Locations:
gcloud config set compute/region us-central1Initialization & Setup: If you do not have a defined mig_prefix or if the user wants to start a new translation project, you MUST first ask the user for:
my_migration_project).us or eu)..zip file containing source database metadata (such as columns.csv or tables.csv).
Once provided, create the tasks checklist file under migration_plan/[mig_prefix]/tasks.md with unchecked tasks representing the migration steps.Automated Execution via Bundled Scripts:
Execute the deterministic end-to-end migration using the bundled translation script scripts/bulk_translate_via_gcloud.py:
python3 scripts/bulk_translate_via_gcloud.py \
--input <input_dir> \
--output <output_dir> \
--bucket <gcs_bucket> \
--location <region> \
[--metadata <metadata_path>]The migration tools bundled in scripts/ perform the following coordinated actions:
scripts/bulk_translate_via_gcloud.py: Orchestrates end-to-end bulk migration, automating pre-processing, GCS upload, BigQuery Translation Service invocation, download, post-processing, and YAML configuration copying.scripts/dbt_translator.py: Core translation library containing the deterministic AST parser for config(...), Jinja placeholder masking and restoration, JSON extraction sanitization, macro auditing, casing/join standardization, and copyright header enforcement.Detailed Translation Lifecycle (Executed by Scripts):
.sql files. Extract and strip the {{ config(...) }} header block from the top of each file.{{ source('src_name', 'table_name') }} with _DBT_SOURCE_src_name_DBTSEP_table_name_{{ ref('model_name') }} with _DBT_REF_model_name_{{ ... }}) from the SQL prior to translation, ensuring the transpiler processes 100% valid Snowflake dialect SQL.columns.csv and tables.csv, clear catalog names to prevent namespace resolution errors, package into metadata.zip, and upload to GCS.gcloud storage cp <staging_input_dir>/*.sql gs://[YOUR_BUCKET]/migration_input/migration_config.yaml specifying snowflakeDialect as source and bigqueryDialect as target (with schemaPath pointing to metadata.zip if provided).gcloud bq migration-workflows create --location=<region> --config-file=migration_config.yaml --no-asyncgcloud storage cp gs://[YOUR_BUCKET]/migration_output/*.sql <translated_output_dir>/{{ config(...) }} block, stripping Snowflake-specific parameters like copy_grants, transient, and secure. Sanitize hooks (pre_hook and post_hook) to remove invalid Snowflake commands like ALTER ICEBERG TABLE ... REFRESH or UNSET SECURE, while preserving valid ones.{{ ref(...) }} or {{ source(...) }} macros by resolving against discovered project models and sources.{{ ... }} Jinja expressions and log warnings for any custom/non-allowlisted database-specific macros. Also audit these blocks for Snowflake-specific syntax (e.g. ::date, dateadd, to_date) that may have been skipped or masked, listing warning comments directly in the file.::date -> CAST(... AS DATE)), datetime cast suffixes (::timestamp -> CAST(... AS TIMESTAMP)), nested dateadd(...) calls, and intervals (- interval '5 month') inside and outside control blocks using balanced-parentheses parsers..yml/.yaml files from the input directory to the output directory.Put a summary to the tasks file at the end.
Before handing over, ask for user approval for the outcome. Apply necessary changes from the user.
Mark your task is done in the tasks file.
Every translated file MUST start with the following exact header at the very top:
# Copyright 2026 Google. This software is provided as-is, without warranty or
# representation for any use or purpose. Your use of it is subject to your
# agreement with Google.Never use Snowflake colon notation or BigQuery JSON_VALUE. Always use the following pattern:
CAST(JSON_EXTRACT_SCALAR(json_column, '$.path') AS TYPE)AS INT64 for all system IDs (do not use NUMERIC for IDs).AS BOOLAS STRING (do not wrap in NULLIF unless explicitly required to handle empty/null strings in source).AS TIMESTAMPCAST on both sides of a join or filter if types are not identical. Use AS STRING for universal comparison safety if necessary.INT64 for all system IDs (e.g., ticket_id, user_id).CAST(NULL AS TYPE).LEFT(col, length) or SUBSTR(col, 1, length).LOWER(col) LIKE '%pattern%' instead of REGEXP_CONTAINS.DATE_ADD(CAST(col AS DATETIME), INTERVAL num HOUR).row_number() over (partition by [PRIMARY_KEY] order by [TIMESTAMP] desc) as rn column in the base CTE, and apply qualify rn = 1 directly on that CTE.LEFT JOIN when joining to custom field or attribute tables (e.g., exploded_array patterns) to prevent dropping records.Do not alter {{ config(...) }}, {{ ref(...) }}, or {{ source(...) }}. Keep {% if is_incremental() %} blocks functional. Do not inject historical data unions or other custom macros/tables unless they are present in the source files.
You will output BigQuery-compatible dbt SQL models under migration_plan/[mig_prefix]/translated_models/. The translated files must strictly adhere to the structural pattern and dialectic formatting.
For translation examples, see: dbt_migration_patterns.md
Before handing over to the root agent, first get approval from the user about the translated models. After applying user's requests, then hand over the root agent.
1d77046
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.