This section describes the workflow for running SQL scripts in Studio, from selecting compute resources and setting the default Catalog to viewing results, logs, and run history, as well as exporting results.
Overview
The running model of SQL scripts is as follows:
To run the script, select a compute resource of the interactive cluster type.
The run results are displayed in three tabs below the editor: Results, Logs, and Code Information.
Run history for the last 30 days can be viewed in Run Records.
Prerequisites
The current workspace is bound to compute resources of the interactive cluster type. For more information, see Compute Resource Overview. You have Run, Edit, or Manage permission on the current SQL file.
You have access to the relevant tables in the target Catalog.
Operation Steps
Step 1: Selecting Compute Resources
1. Open the SQL file.
2. In the upper-right corner of the editor, click the Compute Resource dropdown and select a compute resource of the interactive cluster type in the current workspace.
Step 2: Setting the Default Catalog and Schema (Optional)
1. In the upper-right corner of the editor, set the default Catalog and default Schema.
2. After that, you can directly write table_name in SQL, and the system resolves it based on the default Catalog / Schema.
3. You can also specify the query object information by using the three-part notation catalog_name.schema_name.table_name.
Step 3: Running SQL
You can run it in three ways:
Method | Entries | Action |
Run all | Operation bar Run All | Execute all SQL statements in the file sequentially, separated by ;. |
Run selection | After selecting a snippet, click Run Selection or press ⌘ + Enter. | Execute only the selected code. |
Run statement at cursor | Place the cursor in the statement and press ⌘ + Enter (without selecting any text). | Automatically identify and execute the statement between the current ;. |
Step 4: Filling in Parameters (If Any)
If the SQL contains dynamic parameters (such as ${param_key}), a dialog box prompts you to enter parameter values at runtime. For more information, see Parameterization. Step 5: Viewing Run Results
After execution, the editor displays three types of information below:
5.1 Results Tab
Displays the query result table of the current SQL and supports:
Operation | Description |
Sort | Click a column name to sort in ascending / descending order. |
Display Fields | Select to show / hide columns, freeze columns, and adjust column order. |
Data Search | Search for text in the result area, highlight matches, and support switching between previous and next matches. |
Result Filtering | Add filter conditions (connect multiple conditions with AND / OR). |
Copying | Select the cell range, right-click to copy, or use ⌘ + A / ⌘ + C to select all and copy. |
Download | Click Download. CSV / Excel / TXT formats are supported. |
Visualization | Click Create Chart to generate bar charts, line charts, pie charts, and more by column. |
5.2 Logs Tab
Displays the logs of SQL execution, including Spark Session output, Spark execution logs, and error stacks.
5.3 Code Information Tab
Displays the code snippet information of the current SQL execution.
Step 6: Viewing Run History
1. Click Run History below the editor to view all run records of the current script from the last 30 days and all run results from the last 3 days.
2. Supported operations:
View Details: Go to the results, logs, and code information of a single run.
View Task Insights: View the task insights and Spark UI information of a single run.
Tip
Run history is filtered by file ACLs, so you can only see run records for files that you have permission to access.
Step 7: Exporting Results
Format | Description |
CSV | Uses UTF-8 encoding by default and includes a header row. |
Excel(.xlsx) | Preserves column types and display formats. |
TXT | Tab-separated. |
Parameter Description
Run Configuration
Parameter | Description | Required | Default Value |
Computing Resource | Interactive cluster resources. | Yes | None |
Default Catalog | Resolve references without the Catalog prefix. | No | None |
Default Schema | Resolve references without the Schema prefix. | No | None |
Result Area Quota
Item | Limit |
Default data volume displayed for a single query | No more than 20,000 rows and 10 MB in size. |
Default data volume for downloaded results | No limit on the number of rows, and the size does not exceed 500 MB. |
Query log retention period | 30 days. |
Query result retention period | 3 days. |
Number of query records | No more than 1024 entries. |
Number of sub-result tabs | No more than 100. |
FAQs
Q1: Why does the error "Resource group not connected" occur?
The workspace is not bound to interactive cluster compute resources, or the selected resource group is unavailable. Go to Create Compute Resource to create and bind one, or select another available resource group. Q2: Why is the query slow and how do I troubleshoot it?
Switch to the Code Information Tab to view Spark execution insights, including the number of scanned rows, scanned bytes, and shuffle data volume.
Click Query ID > View Spark UI (landmark) to obtain operator-level execution details.
Check whether the SQL triggered a full table scan. Consider adding partition filtering or adjusting the Catalog materialized view.
Q3: How do I stop a long-running query?
The current file is running. Click Stop in the toolbar.
References
SQL IDE Basic Operations