in cicd-deployers/bigquery_ddl_runner.py [0:0]
def replace_variables_in_query(file_content, project_id, dataset_id, data_bucket_name, connection_name):
"""Replaces variables in a BigQuery query string.
Args:
file_content (str): The content of the query file.
project_id (str): Google Cloud project ID.
dataset_id (str): BigQuery dataset ID.
data_bucket_name (str): Name of the GCS bucket.
connection_name (str): Name of the BigQuery connection.
Returns:
str: The updated query string with replaced variables.
"""
updated_query = file_content.replace("${PROJECT_ID}", project_id) \
.replace("${DATASET_ID}", dataset_id) \
.replace("${DATA_BUCKET_NAME}", data_bucket_name) \
.replace("${CONNECTION_NAME}", connection_name)
return updated_query