Hi @sathya08
I understood that you want to submit an SQL query from a notebook to a serverless cluster.
Maybe you can try the below approach to achieve this.
You need to install the below package:
%pip install databricks-sql-connector
import os
from databricks import sql
catalog = 'default'
schema_name = 'test'
table_name = "trips"
with sql.connect(server_hostname = "**************.azuredatabricks.net",
http_path = "/sql/1.0/warehouses/*********",
access_token = "*****************") as connection:
cursor = connection.cursor()
cursor.execute("show tables")
print(cursor.fetchall())
cursor.execute(f"SELECT * FROM {catalog}.{schema_name}.{table_name} LIMIT 2")
result = cursor.fetchall()
cursor.close()
connection.close()
Let me know if it's helping you.
Thanks
Amit Prajapati