cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow SQL Task Query Showing Empty

ggsmith
Contributor

I am trying to create a SQL task in Workflows. I have my query which executes successfully in the SQL editor, and it is saved in a repo.

ggsmith_0-1738014329449.png
However, when I try to execute the task, the below error shows.
Query text can not be empty: BAD_REQUEST: Query text can not be empty.

ggsmith_1-1738014420683.png

Hovering over the magnify option shows the query blank too. 

ggsmith_2-1738014505322.png

Some queries I didn't create do appear though, so I'm not sure what I'm missing. 

 

1 ACCEPTED SOLUTION

Accepted Solutions

ggsmith
Contributor

It ended up being that the query wasn't actually saved. Once I manually clicked save, the query preview showed and the task ran successfully. 


I'm really surprised that was the reason. I had moved the query around to different folders and closed and reopened it in the editor a few times after having logged out.

View solution in original post

8 REPLIES 8

Lakshay
Databricks Employee
Databricks Employee

Does it run outside of repo if you try to create a job from simple notebook?

Yes, I can run the task when the type selected is Notebook and the code is moved to a sql notebook. The issue only occurs when trying to run a task of type SQL.

Isi
Contributor

Hey @ggsmith 

I tried running it, and it worked without any issues on my end.

Just to double-check, can you see your query inside SQL > Query > My Queries? If it appears there, try clicking on it to view the query. It’s possible that you might have accidentally deleted the query from the SQL editor and saved it, which could explain why it’s empty.

🙂

 

Yea it's there in my queries. And after selecting the open icon next to the query, it opens in the editor. I thought it could be a bug with queries created in the New Editor, but I tested that too and still a blank query. It's odd.
ggsmith_0-1738096684423.png

Satyadeepak
Databricks Employee
Databricks Employee

I can able to reproduce the Issue. Can you please check the sql warehouse has permissions to run the query? below I have tested with a sql warehouse doesn't have permissions to run the query and sql warehouse has permissions to run the query.

Job Task Details:

Screenshot 2025-01-28 at 2.44.19 PM.png

Failed Run and Successful Run:

Screenshot 2025-01-28 at 2.43.51 PM.png

Failed Run:

Screenshot 2025-01-28 at 2.43.58 PM.png

Successful Run:

Screenshot 2025-01-28 at 2.44.11 PM.png

That would make sense. Can you tell me what the permissions look like between the two in your example? I'm not very familiar with permissions for the warehouses and want to be able to explain it correctly to my admin.

Isi
Contributor

Hey @ggsmith ,

Go to where the query is stored, access the Permissions settings, and ensure the user who runs the job (as defined in Run As inside the job details) has the necessary permissions. By default, the Run As user is set to the owner or the creator of the query.

Captura de pantalla 2025-01-28 a las 23.32.00.png


More info about QUERY Permissions: 

Captura de pantalla 2024-10-05 a las 15.58.44.png

🙂

ggsmith
Contributor

It ended up being that the query wasn't actually saved. Once I manually clicked save, the query preview showed and the task ran successfully. 


I'm really surprised that was the reason. I had moved the query around to different folders and closed and reopened it in the editor a few times after having logged out.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group