Solution for executing Bigquery DDL in the notebook cell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2025 09:38 PM
Hi all,
I would like to find a solution to execute a Bigquery DDL in a cell of databricks notebook directly.
Have any solution for my problem?
This is the example of DDL:
CREATE EXTERNAL TABLE `PROJECT_ID.DATASET.DELTALAKE_TABLE_NAME` WITH CONNECTION `PROJECT_ID.REGION.CONNECTION_ID` OPTIONS ( format ="DELTA_LAKE", uris=['DELTA_TABLE_GCS_BASE_PATH']);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 06:40 AM
Hi @Loinguyen318 ,
To execute BigQuery DDL from Databricks, you must use Python code in your notebook with the google-cloud-bigquery library.
from google.cloud import bigquery
client = bigquery.Client()
ddl = """
CREATE EXTERNAL TABLE `PROJECT_ID.DATASET.DELTALAKE_TABLE_NAME`
WITH CONNECTION `PROJECT_ID.REGION.CONNECTION_ID`
OPTIONS (
format ="DELTA_LAKE",
uris=['DELTA_TABLE_GCS_BASE_PATH']
);
"""
job = client.query(ddl)
job.result()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2025 02:24 AM
You can use the google.cloud.bigquery client within a Databricks notebook by installing the google-cloud-bigquery library and using Python to run the DDL. Example:
Make sure your service account is properly configured with access.