Facing issue with google translator using dbt model / macros

Hey Team, I’m seeking a solution to translate non-English strings within a column in my dbt model. Here’s the scenario: I have an employee table with an address column containing non-English strings. My goal is to create another column, say address_en, which will hold the English translations using either a dbt model or macros. I’ve attempted various approaches but haven’t found a solution yet. Interestingly, I managed to achieve this using a Databricks notebook with the following function:

from deep_translator import GoogleTranslator
import pandas as pd

def translate_text(row):
  if pd.isnull(row):
    return ''
  if row == '':
    return ''
  else:
    try:
      translated = GoogleTranslator(source='auto', target='en').translate(row)
      return translated
    except:
      return row

translate_deep = udf(translate_text)

I’d appreciate any assistance with this, as it’s currently blocking my progress.

You would need a python model for this Python models | dbt Developer Hub

Have a good read on this page

dbt python models are only supported if you are using snowflake, databricks or bigquery (I assume you are using databricks, so it is fine)

Actually, maybe you are using Snowflake (because of the tags of the questions)

If so, these are the packages you can use for python models: Snowflake Snowpark for Python