gaurav lalwani
gaurav lalwani

Reputation: 27

How to execute SQL scripts using azure databricks

I have one SQL scripts file In that file there is some sql query I want to upload it on dbfs and read it from azure databricks and execute querys from the script on azure databricks

Upvotes: 1

Views: 4801

Answers (1)

restlessmodem
restlessmodem

Reputation: 448

Databricks does not directly support the execution of .sql files. However you could just read them into a string and execute them.

with open("/dbfs/path/to/query.sql") as queryFile:
   queryText = queryFile.read()
results = spark.sql(queryText)

Upvotes: 3

Related Questions