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.

balajij8
Esteemed Contributor III
  • 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