Run queries in the Query UI
Write and run SQL on your Query Engine from your browser, next to a list of the catalogs, schemas, and tables you can access. You can also export the results and reuse recent and saved queries.
Prerequisites
- A Query Engine whose Status is Healthy. See Create a Query Engine service.
- A Username and Password that can connect to the Query Engine.
Connect to the Query UI
The Query UI opens from the Web UI URL of the service and asks you to sign in. It also asks you to sign in again when you have no session.
- Open the service details. See Open the service details.
- On the Essential Information tab, under Entry Information, open the Web UI URL.
- Sign in.
Write and run queries
The Query Editor is the main screen of the Query UI. It has a toolbar, the catalog drawer on the left, the SQL editor, and the result panel under the editor.

Run a query
- In the editor, enter a SQL statement.
- Optional: select Format SQL to format the statement.
- Select Run query.
- Check the progress of the query in the result panel.
When the query succeeds, its status is FINISHED. If the editor is empty, the query does not run and the Query UI shows a validation message.
Work with query tabs
Each query tab keeps its own query and results during your session.
- To open a new query tab, select Add tab, the + icon next to the tabs.
- To switch to another query, select its tab.
- To close the current tab, select Close tab, the X icon on the tab.
Before you close a tab, save any query in it that you want to keep. See Save a query.
Browse the catalog drawer
The catalog drawer lists the catalogs, schemas, tables, and columns that you have access to.
Browse catalogs, schemas, and tables
- Open the catalog drawer on the left of the screen.
- Select a catalog, for example
tpch. - Open a schema, for example
tiny. - Open a table to see its columns and their data types.
Search for an object
- In the Find objects box, enter a keyword, for example
nation. The tree shows the matching objects under their catalog and schema. - To go back to the full list, or to the state before your search, clear the keyword.
Refresh the metadata
To reload the metadata, select Refresh.
If the metadata does not load, the catalog drawer shows an error. Select Refresh to try again.
Use table actions
Each table in the catalog drawer has quick actions to preview its data, generate its DDL, view its schema and statistics, or generate a SELECT statement. To see them, point to or select the table in the catalog drawer.
Preview the first 100 rows
- In the catalog drawer, point to or select the table.
- Select Preview first 100 rows.
The Query UI runs SELECT * FROM <table> LIMIT 100 and shows the rows in the result panel.
Generate a CREATE TABLE script
- In the catalog drawer, point to or select the table.
- Select Generate CREATE TABLE script. The Query UI shows the
CREATE TABLEscript with the table name and its columns and data types.
View the schema and column statistics
- In the catalog drawer, point to or select the table.
- Select View schema and column statistics.
- Select the Schema tab to see the columns and their data types.
- Select the Details tab to see the estimated number of rows and the percentage of null values.
The Details tab shows the statistics only when the Query Engine provides them. Without statistics, it shows an empty state such as No statistics available.
Generate a SELECT query
- In the catalog drawer, point to or select the table.
- Select Generate SELECT query for this table. The Query UI adds a SELECT statement to the editor, with the table's columns when the metadata is available.
- Check the default
LIMITof the statement. It keeps the query from returning too many rows. - Select Run query.
View and export results
The result panel shows the status of the query, its query ID, duration, and row count, the result grid, and the buttons that copy and export the results.
View query results
- After the query runs, check that its status is FINISHED.
- Check the query ID, the duration, and the number of rows.
- Read the rows in the result grid. If the results have several pages, change Rows per page or move between the pages.
- Optional: select CLEAR to remove the results from the result panel.
Copy or export results
- To copy the results, select Copy.
- To download the results as a CSV file with a header row, select CSV.
- To download the results as a JSON array, select JSON.
- To export all the result data, select Export All → CSV when it is available.
Export All → CSV can be disabled on some platforms. Point to the button to see why.
If the browser blocks the clipboard or the download, the Query UI shows an error message.
Reuse queries
Query History on the toolbar opens a drawer with two tabs: Recent for the queries you ran recently, and Saved for the queries you saved.
Reuse a recent query
- On the toolbar, select Query History.
- Select the Recent tab.
- Select the query. Its SQL opens in the editor.
The row count of a query in the history can mean result rows, processed rows, or another count. Check the label next to it.
Save a query
- Enter the SQL in the editor.
- On the toolbar, select Save this query.
- In the Save Query dialog, enter a Name.
- Select Save. To close the dialog without saving, select Cancel.
Name is required. Without a name, the Query UI does not save the query. It shows a validation message or keeps Save disabled.
Open a saved query
- On the toolbar, select Query History.
- Select the Saved tab.
- Select the saved query. Its SQL opens in the editor, where you can run or edit it.
Rename a saved query
- On the toolbar, select Query History, then select the Saved tab.
- For the query you want to rename, select Rename.
- In the Rename Saved Query dialog, enter the new name.
- Select Rename. To keep the old name, select Cancel.
Delete a saved query
- On the toolbar, select Query History, then select the Saved tab.
- For the query you want to delete, select Delete.
The saved query is removed from the list.