AI_TRANSLATE

functiondeferredAI & ML

docs.snowflake.com ↗

String & binary functions

Translates the given input text from one supported language to another.

Syntax

supportedpartialnot supportednot scored

AI_TRANSLATE(
    <text>, <source_language>, <target_language> [, <return_error_details> ] )

Parameters

NameRequiredDescription
textrequiredA string containing the text to be translated.
source_languagerequiredA string specifying the language code for the language the text is currently in. See Usage notes for a list of supported language codes. If the source language code is an empty string, '', the source language is automatically detected.
target_languagerequiredA string specifying the language code into which the text should be translated. See Usage notes for a list of supported language codes.
return_error_detailsoptionalA BOOLEAN flag that indicates whether to return error details in case of error. When set to TRUE, the function returns an OBJECT that contains the value and the error message, one of which is NULL depending on whether the function succeeded or failed. See Error behavior for details.

Returns

A string containing a translation of the original text into the target language.

Usage notes

Error behavior

By default, if AI_TRANSLATE can’t process the input, the function returns NULL. If the query processes multiple rows, rows with errors return NULL and don’t prevent the query from completing. The return value on error depends on the return_error_details argument. The following table shows the return value based on the return_error_details argument: return_error_details | Return value | Description FALSE Not passed | NULL | TRUE | OBJECT with value and error fields | value: A VARCHAR value that contains the translated text, or NULL if an error occurred. error: A VARCHAR value that contains the error message if an error occurred, or NULL if the function succeeded. For more information about error handling for AI functions, see Snowflake Cortex AI Function: Multirow error handling improvements.

Access control requirements

Users must use a role that has been granted the SNOWFLAKE.CORTEX_USER database role. See Cortex LLM privileges for more information on this privilege.

Legal notices

Refer to Snowflake AI and ML.

Known gaps

Parts not fully supported, and recorded divergences from Snowflake.