Can I create Databricks SQL object of type Query, save SQL statement in it and save it on workspace using python script? Or any alternative to execute .SQL file using workspace instead of git on workflow task type SQL and SQL task is of file, want to use SQL warehouse only.
I did research online but could not find any useful information regarding this.
If you having
.sqlfile the only possible way is, to integrate with git that also only one statement.You refer about this here Create a new job | Jobs API | REST API reference under task of type SQL with file type as source.
So, to achieve your goal need to create a query using this
.sqlfile with the help of REST API.Using below python code you can create Query and use it further in job.
Create a new query definition | Queries / Results API | REST API reference
Above is the Api used to create new query.
Here, if you see i have given data source id which is different from warehouse id, you can get that using below Api /api/2.0/preview/sql/data_sources for SQL path you can give dbfs path which you uploaded your SQL file to dbfs earlier.
After successfully creation it will appear in queries tab and you can use it in workflow job.