Migrate code with the batch SQL translator
Note: For API-based translations, including new batch translations, we recommendthat you use theBigQuery Migration APIto translate your SQL scripts. The BigQuery Migration API works much like thebatch SQL translator, but without the need to install or use client code.This document describes how to use the batch SQL translator inBigQuery to translate scripts written in other SQL dialects intoGoogleSQLqueries. This document is intended for users who are familiar with theGoogle Cloud console.
Before you begin
Before you submit a translation job, complete the following steps:
- Ensure that you have all the required permissions.
- Enable the BigQuery Migration API.
- Collect the source files containing the SQL scripts and queries to betranslated.
- Optional. Create a metadata file to improve the accuracy of the translation.
- Optional. Decide if you need to map SQL object names in the source filesto new names in BigQuery. Determine what name mapping rules touse if this is necessary.
- Decide what method to use to submit the translation job.
- Upload the source files to Cloud Storage.
Required permissions
You must have the following permissions on the project to enable theBigQuery Migration Service:
resourcemanager.projects.getserviceusage.services.enableserviceusage.services.get
You need the following permissions on the project to access and use theBigQuery Migration Service:
bigquerymigration.workflows.createbigquerymigration.workflows.getbigquerymigration.workflows.listbigquerymigration.workflows.deletebigquerymigration.subtasks.getbigquerymigration.subtasks.listAlternatively, you can use the following roles to get the same permissions:
bigquerymigration.viewer- Read only access.bigquerymigration.editor- Read/write access.
To access the Cloud Storage buckets for input and output files:
storage.objects.geton the source Cloud Storage bucket.storage.objects.liston the source Cloud Storage bucket.storage.objects.createon the destination Cloud Storage bucket.
You can have all the above necessary Cloud Storage permissions fromthe following roles:
roles/storage.objectAdminroles/storage.admin
Enable the BigQuery Migration API
If your Google Cloud CLI project was created before February 15, 2022, enablethe BigQuery Migration API as follows:
In the Google Cloud console, go to theBigQuery Migration API page.
ClickEnable.
Collect source files
Source files must be text files that contain valid SQL for the source dialect.Source files can also include comments. Do your best to ensure the SQL is valid,using whatever methods are available to you.
Create metadata files
To help the service generate more accurate translation results, we recommendthat you provide metadata files. However, this isn't mandatory.
You can use thedwh-migration-dumper command-line extraction tool to generate the metadatainformation, or you can provide your own metadata files. Once metadata files are prepared, you can include them along with the source files in the translationsource folder. The translator automatically detects them and leverages themto translate source files, you don't need to configure any extra settings to enable this.
To generate metadata information by using thedwh-migration-dumper tool, seeGenerate metadata for translation.
To provide your own metadata, collect the data definition language (DDL)statements for the SQL objects in your source system into separate text files.
Decide how to submit the translation job
You have three options for submitting a batch translation job:
Batch translation client: Configure a job by changing settings ina configuration file, and submit the job using the command line. Thisapproach doesn't require you to manually upload source files toCloud Storage. The client still uses Cloud Storageto store files during translation job processing.
The legacy batch translation client is an open-source Pythonclient that lets you translate source files located on your localmachine and have the translated files output to a local directory.You configure the client for basic use by changing a few settings inits configuration file. If you choose to, you can also configure the client toaddress more complex tasks like macro replacement, and pre- andpostprocessing of translation inputs and outputs. For more information,see the batch translation clientreadme.
Google Cloud console: Configure and submit a job using a userinterface. This approach requires you to upload source files toCloud Storage.
Create configuration YAML files
You can optionally create and use configurationconfiguration YAML filesto customize your batch translations. These files can be used to transform yourtranslation output in various ways. For example,you cancreate a configuration YAML file to change the case of a SQL objectduring translation.
If you want to use the Google Cloud console or the BigQuery Migration API for abatch translation job, you canupload the configuration YAML file to theCloud Storage bucket containing the source files.
If you want to use the batch translation client, you can place the configuration YAMLfile in the local translation input folder.
Upload input files to Cloud Storage
If you want to use the Google Cloud console or the BigQuery Migration APIto perform a translation job, you must upload the source files containingthe queries and scripts you want to translate to Cloud Storage. Youcan also uploadany metadata files orconfiguration YAML filesto the same Cloud Storage bucket and directory containing the source files.For more information about creating buckets and uploading files toCloud Storage, seeCreate bucketsandUpload objects from a filesystem.
Supported SQL dialects
The batch SQL translator is part of the BigQuery Migration Service. Thebatch SQL translator can translate thefollowing SQL dialects into GoogleSQL:
- Amazon Redshift SQL
- Apache HiveQL and Beeline CLI
- IBM Netezza SQL and NZPLSQL
- Teradata and Teradata Vantage:
- SQL
- Basic Teradata Query (BTEQ)
- Teradata Parallel Transport (TPT)
Additionally, translation of the following SQL dialects is supported inpreview:
- Apache Impala SQL
- Apache Spark SQL
- Azure Synapse T-SQL
- GoogleSQL (BigQuery)
- Greenplum SQL
- IBM DB2 SQL
- MySQL SQL
- Oracle SQL, PL/SQL, Exadata
- PostgreSQL SQL
- Trino or PrestoSQL
- Snowflake SQL
- SQL Server T-SQL
- SQLite
- Vertica SQL
Handling unsupported SQL functions with helper UDFs
When translating SQL from a source dialect to BigQuery, some functions might not have a direct equivalent. To address this, the BigQuery Migration Service (and the broader BigQuery community) provide helper user-defined functions (UDFs) that replicate the behavior of these unsupported source dialect functions.
These UDFs are often found in thebqutil public dataset, allowing translated queries to initially reference them using the formatbqutil.<dataset>.<function>(). For example,bqutil.fn.cw_count().
Important considerations for production environments:
Whilebqutil offers convenient access to these helper UDFs for initial translation and testing, direct reliance onbqutil for production workloads is not recommended for several reasons:
- Version control: The
bqutilproject hosts the latest version of these UDFs, which means their definitions can change over time. Relying directly onbqutilcould lead to unexpected behavior or breaking changes in your production queries if a UDF's logic is updated. - Dependency isolation: Deploying UDFs to your own project isolates your production environment from external changes.
- Customization: You might need to modify or optimize these UDFs to better suit your specific business logic or performance requirements. This is only possible if they are within your own project.
- Security and governance: Your organization's security policies might restrict direct access to public datasets like
bqutilfor production data processing. Copying UDFs to your controlled environment aligns with such policies.
Deploying helper UDFs to your project:
For reliable and stable production use, you should deploy these helper UDFs into your own project and dataset. This gives you full control over their version, customization, and access.For detailed instructions on how to deploy these UDFs, refer to theUDFs deployment guide on GitHub. This guide provides the necessary scripts and steps to copy the UDFs into your environment.
Locations
The batch SQL translator is available in the followingprocessing locations:
| Region description | Region name | Details | |
|---|---|---|---|
| Asia Pacific | |||
| Delhi | asia-south2 | ||
| Hong Kong | asia-east2 | ||
| Jakarta | asia-southeast2 | ||
| Melbourne | australia-southeast2 | ||
| Mumbai | asia-south1 | ||
| Osaka | asia-northeast2 | ||
| Seoul | asia-northeast3 | ||
| Singapore | asia-southeast1 | ||
| Sydney | australia-southeast1 | ||
| Taiwan | asia-east1 | ||
| Tokyo | asia-northeast1 | ||
| Europe | |||
| Belgium | europe-west1 | ||
| Berlin | europe-west10 | ||
| EU multi-region | eu | ||
| Finland | europe-north1 | ||
| Frankfurt | europe-west3 | ||
| London | europe-west2 | ||
| Madrid | europe-southwest1 | ||
| Milan | europe-west8 | ||
| Netherlands | europe-west4 | ||
| Paris | europe-west9 | ||
| Stockholm | europe-north2 | ||
| Turin | europe-west12 | ||
| Warsaw | europe-central2 | ||
| Zürich | europe-west6 | ||
| Americas | |||
| Columbus, Ohio | us-east5 | ||
| Dallas | us-south1 | ||
| Iowa | us-central1 | ||
| Las Vegas | us-west4 | ||
| Los Angeles | us-west2 | ||
| Mexico | northamerica-south1 | ||
| Northern Virginia | us-east4 | ||
| Oregon | us-west1 | ||
| Québec | northamerica-northeast1 | ||
| São Paulo | southamerica-east1 | ||
| Salt Lake City | us-west3 | ||
| Santiago | southamerica-west1 | ||
| South Carolina | us-east1 | ||
| Toronto | northamerica-northeast2 | ||
| US multi-region | us | ||
| Africa | |||
| Johannesburg | africa-south1 | ||
| MiddleEast | |||
| Dammam | me-central2 | ||
| Doha | me-central1 | ||
| Israel | me-west1 | ||
Submit a translation job
Follow these steps to start a translation job, view its progress, and see theresults.
Console
These steps assume you have source files uploaded into a Cloud Storage bucket already.
In the Google Cloud console, go to theBigQuery page.
In the navigation menu, clickTools and guide.
In theTranslate SQL panel, clickTranslate>Batch translation.
The translation configuration page opens. Enter the following details:
- ForDisplay name, type a name for the translation job. The namecan contain letters, numbers or underscores.
- ForProcessing location, select the location where you want thetranslation job to run. For example, if you are in Europe and youdon't want your data to cross any location boundaries, select the
euregion. The translation job performs best when you choose the samelocation as your source file bucket. - ForSource dialect, select the SQL dialect that you want totranslate.
- ForTarget dialect, selectBigQuery.
ClickNext.
ForSource location, specify the path to the Cloud Storage foldercontaining the files to translate. You can type the path in the format
bucket_name/folder_name/or use theBrowse option.ClickNext.
ForTarget location, specify the path to the destination Cloud Storagefolder for the translated files. You can type the path in the format
bucket_name/folder_name/or use theBrowse option.If you're doing translations that don't need to have default object namesor source-to-target name mapping specified, skip to Step 11. Otherwise,clickNext.
Fill in the optional settings that you need.
Optional. ForDefault database, type adefault database nameto use with the source files. The translator uses this default database name to resolve SQL objects'fully qualified names where the database name is missing.
Optional. ForSchema search path, specify a schema to search whenthe translator needs to resolve SQL objects'fully qualified names in the source files where the schema name is missing. If the source files use a number of different schema names, clickAdd Schema Name and add a value for each schema name that might be referenced.
The translator searches through the metadata files you provided to validate tables with their schema names. If a definite option can't be determined from the metadata, the first schema name you enter is used as the default. For more information on how the default schema name is used, seedefault schema.
Optional. If you want to specifyname mapping rules to rename SQLobjects between the source system and BigQueryduring translation, you can either provide aJSON file withthe name mapping pair, or you can use theGoogle Cloud console to specify the values to map.
To use a JSON file:
- ClickUpload JSON file for name mapping.
Browse to the location of a name mapping file in theappropriate format,select it, and clickOpen.
Note that the file size must be less than 5 MB.
To use the Google Cloud console:
- ClickAdd name mapping pair.
- Add the appropriate parts of the source object name in theDatabase,Schema,Relationship, andAttributefields in theSource column.
- Add the parts of the target object name in BigQueryin the fields in theTarget column.
- ForType, select the object type that describes the objectyou are mapping.
- Repeat Steps 1 - 4 until you have specified all of the name mappingpairs that you need. Note that you can only specify up to 25 namemapping pairs when using the Google Cloud console.
Optional. To generate translation AI suggestions using the Gemini model,select theGemini AI suggestions checkbox. Suggestionsare based on the configuration YAML file ending in
.ai_config.yamlandlocated in the Cloud Storage directory. Each type of suggestion outputis saved in its own sub-directory within your output folder with the namingpatternREWRITETARGETSUGGESTION_TYPE_suggestion.For example, suggestions for the Gemini-enhanced target SQLcustomization is stored intarget_sql_query_customization_suggestionandthe translation explanation generated by Gemini is storedintranslation_explanation_suggestion.To learn how to write the configuration YAML file for AI suggestions,seeCreate a Gemini-based configuration YAML file.
ClickCreate to start the translation job.
Once the translation job is created, you can see its status in thetranslation jobs list.
Batch translation client
Note: We recommend that new translations use theBigQuery Migration APIinstead of the batch translation client.Install the batch translation client and the Google Cloud CLI.
In the batch translation client installation directory, use the texteditor of your choice to open the
config.yamlfile and modify the following settings:project_number: Type the project number of the project you want touse for the batch translation job. You can find this in theProject info pane on theGoogle Cloud console welcome page forthe project.gcs_bucket: Type the name of the Cloud Storage bucket that the batchtranslation client uses to store files during translation jobprocessing.input_directory: Type the absolute or relative path to the directorycontaining the source files and any metadata files.output_directory: Type the absolute or relative path to the targetdirectory for the translated files.
Save the changes and close the
config.yamlfile.Place your source and metadata files in the input directory.
Run the batch translation client using the following command:
bin/dwh-migration-clientOnce the translation job is created, you can see its status in thetranslation jobs list in the Google Cloud console.
Optional. Once the translation job is completed, delete the files thatthe job created in the Cloud Storage bucket you specified, in orderto avoid storage costs.
Explore the translation output
After running the translation job, you can see information about the jobin the Google Cloud console. If you used the Google Cloud console to run the job, you can see job results in the destinationCloud Storage bucket that you specified. If you used the batchtranslation client to run the job, you can see job results in the outputdirectory that you specified. The batch SQL translatoroutputs the following files to the specified destination:
- The translated files.
- The translation summary report in CSV format.
- The consumed output name mapping in JSON format.
- The AI suggestion files.
Google Cloud console output
To see translation job details, follow these steps:
In the Google Cloud console, go to theBigQuery page.
In the navigation menu, clickSQL translation.
In the list of translation jobs, locate the job for which you want to see thetranslation details. Then, click the translation job name.You can see a Sankey visualization that illustrates the overall quality ofthe job, the number of input lines of code (excluding blank lines and comments),and a list of issues that occurred during the translation process.You should prioritize fixes from left to right. Issues in an early stage cancause additional issues in subsequent stages.
Hold the pointer over the error or warning bars, and review the suggestionsto determine next steps to debug the translation job.
Select theLog Summary tab to see a summary of the translation issues,including issue categories, suggested actions, and how often each issueoccurred. You can click the Sankey visualization bars to filter issues. Youcan also select an issue category to see log messagesassociated with that issue category.
Select theLog Messages tab to see more details about each translationissue, including the issue category, the specific issue message, and a linkto the file in which the issue occurred. You can click the Sankeyvisualization bars to filter issues. You can select an issue in theLogMessage tab to open theCode tabthat displays the input and output file if applicable.
Click theJob details tab to see the translation jobconfiguration details.
Summary report
The summary report is a CSV file that contains a table of all of thewarning and error messages encountered during the translation job.
To see the summary file in the Google Cloud console, follow these steps:
In the Google Cloud console, go to theBigQuery page.
In the navigation menu, clickSQL translation.
In the list of translation jobs, locate the job that you are interested in,then click the job name or clickMore options> Show details.
In theJob details tab, in theTranslation report section, clicktranslation_report.csv.
On theObject details page, click the value in theAuthenticated URLrow to see the file in your browser.
The following table describes the summary file columns:
| Column | Description |
|---|---|
| Timestamp | The timestamp at which the issue occurred. |
| FilePath | The path to the source file that the issue is associated with. |
| FileName | The name of the source file that the issue is associated with. |
| ScriptLine | The line number where the issue occurred. |
| ScriptColumn | The column number where the issue occurred. |
| TranspilerComponent | The translation engine internal component where the warning or erroroccurred. This column might be empty. |
| Environment | The translation dialect environment associated with thewarning or error. This column might be empty. |
| ObjectName | The SQL object in the source file that is associated with the warning or error. This column might be empty. |
| Severity | The severity of the issue, either warning or error. |
| Category | The translation issue category. |
| SourceType | The source of this issue. The value in this column can either beSQL, indicating an issue in the input SQL files, orMETADATA, indicating an issue in the metadata package. |
| Message | The translation issue warning or error message. |
| ScriptContext | The SQL snippet in the source file that is associated with the issue. |
| Action | The action we recommend you take to resolve the issue. |
Code tab
The code tab lets you review further information about the inputand output files for a particular translation job. In the code tab, you canexamine the files used in a translation job, review aside-by-side comparison of an input file and its translation for anyinaccuracies, and view log summaries and messages for a specific file in a job.
To access the code tab, follow these steps:
In the Google Cloud console, go to theBigQuery page.
In the navigation menu, clickSQL translation.
In the list of translation jobs, locate the job that you are interested in,then click the job name or clickMore options> Show details.
SelectCode tab. The code tab consists of the following panels:

- File explorer: Contains all SQL files used for translation. Click a file toview its translation input and output, and any translation issues from itstranslation.
- Gemini-enhanced input: The input SQL that was translated by thetranslation engine. If you have specified Geminicustomization rules for the source SQLin the Gemini configuration,then the translator transforms the original input firstand then translates the Gemini-enhanced input. To view theoriginal input, clickView original input.
- Translation output: The translation result. If you have specifiedGemini customization rules for the target SQL inthe Gemini configuration,then the transformation is applied to the translated result as aGemini-enhanced output. If a Gemini-enhancedoutput is available, then you can click theGemini suggestion buttonto review the Gemini-enhanced output.
Optional: To view an input file and its output file in theBigQuery interactive SQL translator, clickEdit.You can edit the files and save the output file back to Cloud Storage.
Configuration tab
You can add, rename, view, or edit your configuration YAML files in theConfiguration tab.TheSchema Explorer showsthe documentation for supported configuration types to help you write yourconfiguration YAML files. After you edit the configuration YAML files,you can rerun the job to use the new configuration.
To access the configuration tab, follow these steps:
In the Google Cloud console, go to theBigQuery page.
In the navigation menu, clickSQL translation.
In the list of translation jobs, locate the job that you are interested in,then click the job name or clickMore options> Show details.
In theTranslation details window, click theConfiguration tab.

To add a new configuration file:
- Clickmore_vertMore options>Create configuration YAML file.
- A panel appears where you can choose the type, location, and name of the new configuration YAML file.
- ClickCreate.
To edit an existing configuration file:
- Click on the configuration YAML file.
- Edit the file, then clickSave.
- ClickRe-run to run a new translation job that uses the edited configuration YAML files.
You can rename an existing configuration file by clickingmore_vertMore options>Rename.
Consumed output name mapping file
This JSON file contains the output name mapping rules that were used by thetranslation job. The rules in this file might differ from theoutput name mapping rulesthat you specified for the translation job, due to either conflicts in thename mapping rules, or lack of name mapping rules for SQL objectsthat were identified during translation. Review this file todetermine whether the name mapping rulesneed correction. If they do, create new output name mapping rules that addressany issues you identify, and run a new translation job.
Translated files
For each source file, a corresponding output file is generated in thedestination path. The output file contains the translated query.
Important: Translation is done on a best effort basis. Whenever possible,validate the translated queries.Debug batch translated SQL queries with the interactive SQL translator
You can use the BigQuery interactive SQL translator toreview or debug a SQL query using the same metadata or object mappinginformation as your source database. After you complete a batch translation job,BigQuery generates a translation configuration ID that containsinformation about the job's metadata, the object mapping, or the schema searchpath, as applicable to the query.You use the batch translation configuration ID with the interactive SQL translatorto run SQL queries with the specified configuration.
To start an interactive SQL translation by using a batch translationconfiguration ID, follow these steps:
In the Google Cloud console, go to theBigQuery page.
In the navigation menu, clickSQL translation.
In the list of translation jobs, locate the job that you are interested in,and then clickMore Options> Open Interactive Translation.
The BigQuery interactive SQL translator now openswith the corresponding batch translation configuration ID. To view thetranslation configuration ID for the interactive translation, clickMore> Translation settings in theinteractive SQL translator.
To debug a batch translation file in the interactive SQL translator,follow these steps:
In the Google Cloud console, go to theBigQuery page.
In the navigation menu, clickSQL translation.
In the list of translation jobs, locate the job that you are interested in,and then click the job name or clickMore options> Show details.
In theTranslation details window, click theCode tab.
In the file explorer, click your filename to open the file.
Next to the output filename, clickEdit to open the files in theinteractive SQL translator (Preview).
You see the input and output files populated in theinteractive SQL translator that now uses the corresponding batchtranslation configuration ID.
To save the edited output file back to Cloud Storage, in theinteractive SQL translator clickSave> Save To GCS.
Limitations
The translator can't translate user-defined functions (UDFs) from languagesother than SQL, because it can't parse them to determinetheir input and output data types. This causes translation of SQL statementsthat reference these UDFs to be inaccurate. To make sure non-SQL UDFs areproperly referenced during translation, use valid SQL to create placeholderUDFs with the same signatures.
For example, say you have a UDF written in C that calculates the sum of twointegers. To make sure that SQL statements that reference this UDF are correctlytranslated, create a placeholder SQL UDF that shares the same signature as theC UDF, as shown in the following example:
CREATEFUNCTIONTest.MySum(aINT,bINT)RETURNSINTLANGUAGESQLRETURNa+b;Save this placeholder UDF in a text file, and include that file as one of thesource files for the translation job. This enables the translator to learn theUDF definition and identify the expected input and output data types.
Quota and limits
- BigQuery Migration API quotas apply.
- Each project can have at most 10 active translation tasks.
- While there is no hard limit on the total number of source and metadatafiles, we recommend keeping the number of files to under 1000 for betterperformance.
Troubleshoot translation errors
RelationNotFound orAttributeNotFound translation issues
Translation works best with metadata DDLs. When SQL object definitions cannot befound, the translation engine raisesRelationNotFound orAttributeNotFoundissues. We recommend using the metadata extractor to generate metadata packagesto make sure all object definitions are present. Adding metadata is therecommended first step to resolve most translation errors, as it often can fixmany other errors that are indirectly caused from a lack of metadata.
For more information, seeGenerate metadata for translation and assessment.
Pricing
There is no charge to use the batch SQL translator. However,storage used to store input and output files incurs the normal fees. For moreinformation, seeStorage pricing.
What's next
Learn more about the following steps in data warehouse migration:
- Migration overview
- Migration assessment
- Schema and data transfer overview
- Data pipelines
- Interactive SQL translation
- Data security and governance
- Data validation tool
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.