Dbt Sf To Bq Translator logo

Dbt Sf To Bq Translator

OrganizationPopular
google
dbt-sf-to-bq-translator

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.

Overview

Publishergoogle
Repositoryskills
Skill namedbt-sf-to-bq-translator
Stars
20.5K
Forks
1.7K
Bundled files
3
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by google on GitHub. Read the source before you install it.

Installation

Install the Dbt Sf To Bq Translator AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/google/skills/tree/main/skills/cloud/dbt-sf-to-bq-translator
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/google/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/cloud/dbt-sf-to-bq-translator .claude/skills/dbt-sf-to-bq-translator
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Dbt Sf To Bq Translator in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Dbt Sf To Bq Translator on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Dbt Sf To Bq Translator is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

dbt Snowflake to BigQuery Translator

You are responsible for:

  1. Dialect Translation: Translating Snowflake dbt SQL models to Standardized Google BigQuery SQL.
  2. Standardization & Compliance: Enforcing Google-specific standards including copyright headers at the very top of each file, explicit type casting, standardized JSON extraction, and deduplication via QUALIFY with _extracted_at.
  3. Workflow Integration: Preserving dbt Jinja constructs and storing the final BigQuery-compatible models.

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.

Prerequisites & Environment Setup

Before starting the translation, ensure your Google Cloud environment is properly configured:

  1. Google Cloud SDK: Install the Google Cloud SDK if not already installed.
  2. Authentication: Authenticate your CLI session:
    bash
    gcloud auth login
    gcloud auth application-default login
  3. Project Configuration: Set your active GCP project:
    bash
    gcloud config set project {project_id}
  4. Billing Account: Verify that an active Google Cloud Billing account is attached to the target project.
  5. Enable Required APIs: Ensure BigQuery, Migration, and Storage services are enabled:
    bash
    gcloud services enable bigquerymigration.googleapis.com storage.googleapis.com bigquery.googleapis.com
  6. Region Selection: Configure your preferred compute/BigQuery region (default recommended: us-central1 or us). See Google Cloud Locations:
    bash
    gcloud config set compute/region us-central1

Steps

  • Initialization & 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:

    1. Migration Project Name (e.g. my_migration_project).
    2. Input directory containing Snowflake SQL files.
    3. Output directory where BigQuery SQL files should be saved.
    4. GCS Bucket name for staging translation assets.
    5. GCP Region (e.g. us or eu).
    6. (Optional) Local path to a directory or .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:

    bash
    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):

    1. Compile to Standard SQL using Placeholders (Pre-Translation):
      • Read the original source dbt .sql files. Extract and strip the {{ config(...) }} header block from the top of each file.
      • Replace dbt macro calls with standard-SQL-compliant placeholder identifiers to prevent BigQuery Translation Service from throwing syntax errors:
        • Replace {{ source('src_name', 'table_name') }} with _DBT_SOURCE_src_name_DBTSEP_table_name_
        • Replace {{ ref('model_name') }} with _DBT_REF_model_name_
      • Eliminate Jinja curly braces ({{ ... }}) from the SQL prior to translation, ensuring the transpiler processes 100% valid Snowflake dialect SQL.
    2. Isolate the SQL Files:
      • Save these pre-processed, Jinja-free files to a staging input directory ready for GCS upload.
    3. Pre-Process Metadata & Translate SQL via BigQuery Translation Service:
      • If a metadata path is provided, map table entries matching discovered dbt models/sources to their placeholder names in columns.csv and tables.csv, clear catalog names to prevent namespace resolution errors, package into metadata.zip, and upload to GCS.
      • Upload staging SQL files to GCS: gcloud storage cp <staging_input_dir>/*.sql gs://[YOUR_BUCKET]/migration_input/
      • Create migration_config.yaml specifying snowflakeDialect as source and bigqueryDialect as target (with schemaPath pointing to metadata.zip if provided).
      • Trigger translation workflow: gcloud bq migration-workflows create --location=<region> --config-file=migration_config.yaml --no-async
      • Download translated GoogleSQL files from GCS: gcloud storage cp gs://[YOUR_BUCKET]/migration_output/*.sql <translated_output_dir>/
    4. Restore Placeholders & Re-Embed dbt Logic:
      • Take the translated BigQuery SQL files and perform advanced post-processing:
        • AST-Based Config Transformation: Parse the original {{ 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.
        • Reference Resolver (Namespace Resolution): Scan the SQL for hardcoded Snowflake database/schema table paths in FROM and JOIN clauses, and map them back to native dbt {{ ref(...) }} or {{ source(...) }} macros by resolving against discovered project models and sources.
        • Macro & Syntax Audit: Scan all {{ ... }} 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.
        • Balanced SQL Edge-Cases Sanitization: Convert date cast suffixes (::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.
        • Copyright Header Placement: Prepend the mandatory Google copyright header at the very top of the file above the config block.
    5. Write to the New BigQuery dbt File & Copy YAML Configurations:
      • Save the newly assembled, BigQuery-compatible files preserving directory structure. Also, copy all .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.

Mandates & Behavioral Rules

1. Mandatory File Header

Every translated file MUST start with the following exact header at the very top:

sql
# 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.

2. Standardized JSON Extraction

Never use Snowflake colon notation or BigQuery JSON_VALUE. Always use the following pattern:

  • Rule: CAST(JSON_EXTRACT_SCALAR(json_column, '$.path') AS TYPE)
  • Mandatory Casting:
    • IDs (primary/foreign): AS INT64 for all system IDs (do not use NUMERIC for IDs).
    • Boolean Flags: AS BOOL
    • Strings: AS STRING (do not wrap in NULLIF unless explicitly required to handle empty/null strings in source).
    • Timestamps: AS TIMESTAMP

3. Explicit Type Safety

  • Comparisons: Always use CAST on both sides of a join or filter if types are not identical. Use AS STRING for universal comparison safety if necessary.
  • ID Fields: Prefer INT64 for all system IDs (e.g., ticket_id, user_id).
  • Null Handling:
    • For placeholder columns, always use explicit type casting: CAST(NULL AS TYPE).

4. Prescriptive String & Date Functions

  • Truncation: Use LEFT(col, length) or SUBSTR(col, 1, length).
  • Search: Use LOWER(col) LIKE '%pattern%' instead of REGEXP_CONTAINS.
  • Date Add: Use DATE_ADD(CAST(col AS DATETIME), INTERVAL num HOUR).

5. Mandatory Deduplication & Joins

  • Deduplication: If the source model requires deduplication on a primary key:
    • Rule: Use a 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.
  • Joins: Use LEFT JOIN when joining to custom field or attribute tables (e.g., exploded_array patterns) to prevent dropping records.

6. Preserve Jinja Constructs

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.

Outputs

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

Constraints

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.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Dbt Sf To Bq Translator AI skill do?

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.

Why use Dbt Sf To Bq Translator on TypingMind?

Because you install it once and use it with any model. Dbt Sf To Bq Translator is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Dbt Sf To Bq Translator in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/google/skills/tree/main/skills/cloud/dbt-sf-to-bq-translator. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Dbt Sf To Bq Translator?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Dbt Sf To Bq Translator?

As many as you like. As long as a model supports skills, you can use Dbt Sf To Bq Translator with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Dbt Sf To Bq Translator AI skill free?

Yes. It is published on GitHub by google under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇