cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Generative AI
Explore discussions on generative artificial intelligence techniques and applications within the Databricks Community. Share ideas, challenges, and breakthroughs in this cutting-edge field.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Can I publish the query stored in the "Query History"?

mimsalar
New Contributor II

Iโ€™m using an agent within a Databricks app that converts plain English into SQL, executes the query against a warehouse table, and returns the results.

Iโ€™d like to know if thereโ€™s a way to also surface or publish the generated SQL query within the app. I can see the query in the Query History, but I havenโ€™t found a way to expose it directly in the app interface.

2 REPLIES 2

balajij8
Contributor
  • You can use the SQL string generated by agent handling the English - SQL conversion using code & display it along with results in the web app
  • Query the system query history table with statement ID for statement_text (system.query.history) & display the executed query in the web app if issues in finding the query generated by agent

More details here

MoJaMa
Databricks Employee
Databricks Employee

You may have to add a call to the Query History API with the necessary filter_by.

https://docs.databricks.com/api/workspace/queryhistory/list