# Editor Pane

{% hint style="warning" %}
The [DataAnalyst role](https://docs.e6data.com/product-documentation/~/revisions/W5MExJCuvHiG1ioEcgOy/access-control/roles) must be assigned to each user who needs access to the Query Editor, ***including SuperAdmins.***

***Please be sure to use it cautiously, as it provides access to*** [***read potentially sensitive data***](https://docs.e6data.com/product-documentation/~/revisions/W5MExJCuvHiG1ioEcgOy/faqs/security#what-data-other-data-moves-outside-the-data-plane)***.***
{% endhint %}

<figure><img src="https://3484040590-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeVBYKZm1xFKFFVzS0lRJ%2Fuploads%2FHRdXuiXoB1dH1fAp9xPG%2FScreenshot%202023-12-26%20at%2012.21.17%20PM.png?alt=media&#x26;token=a4715260-8b4b-4aa4-a1bb-895e3a142ab9" alt=""><figcaption><p>Editor pane of the Query Editor</p></figcaption></figure>

The Editor Pane consists of three parts:

1. [Tabs](#tabs)
2. [Query Action Bar](#query-action-bar)
3. [SQL Query Editor](#sql-query-editor)

## Tabs

Queries can be written, edited, and run in multiple tabs to organize work.

### Managing Tabs

#### Naming Tabs

The names of tabs can be changed by double-clicking the existing tab name.

#### Ordering Tabs

Tabs can be dragged and moved to change their order. This lets users customize the Editor Pane to suit their workflow. Each user's tab order will be auto-saved for future sessions.

#### Adding Tabs

To open multiple editor tabs, click the **plus** sign after the last tab.

#### Deleting Tabs

Hover over any tab and click the X to delete a tab.

<figure><img src="https://3484040590-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeVBYKZm1xFKFFVzS0lRJ%2Fuploads%2FTnWTaZunsmwLLSE7B6lb%2FUntitled%20design.jpg?alt=media&#x26;token=eaf6aedb-c684-44de-8fef-d49ea983609f" alt=""><figcaption></figcaption></figure>

### Additional Features

Click the kebab menu (three dots) option to access additional features. The features available are :&#x20;

#### Keyboard Shortcuts

You can access these shortcuts by clicking the kebab menu (three dots) option and then the 'Keyboard Shortcuts' button. They can also be accessed by pressing the 'F1' key.&#x20;

The following shortcuts are available for the specified actions.

| Action                  | Shortcut              |
| ----------------------- | --------------------- |
| Run Query               | \<cmd> + enter        |
| Abort Query             | \<cmd> + esc          |
| Find and Replace        | \<cmd> + f            |
| Format Query            | \<cmd> + shift + o    |
| Show/Hide Result        | \<option> + shift + t |
| Undo                    | \<cmd> + z            |
| Redo                    | \<cmd> + shift + z    |
| Show keyboard Shortcuts | F1                    |

#### Format Query

This feature is used to beautify the SQL query in the currently active tab. In the case of lengthy query text, the formatting process may require some time, during which a progress bar will be displayed to indicate the formatting status.

#### Duplicate

This feature duplicates the current tab, preserving the executed queries only. The results will not be copied to the new tab.

## Query Action Bar

### Run a Query

{% hint style="info" %}
If the Cluster used to run the query is suspended, the user will be asked for consent to resume the Cluster before the query is run.
{% endhint %}

A query can be run from the editor in two ways:

* Click the **Run** button
* Press **Cmd + Enter**

By default, all queries in a tab are run and the results of the last query will be displayed in the [Result Pane](#selectively-run-queries).

To run only one query, see [Selectively Run Queries](#selectively-run-queries).

{% hint style="warning" %}
If multiple queries are run and there is an error in any query, the execution of all queries will be aborted and no results will be displayed.

The query containing the error will be highlighted in red.
{% endhint %}

### Stop a Query

When a query is running the **Run** button will change to **Cancel.** Click **Cancel** to stop any running query.

#### Set Default LIMITs

A default LIMIT can be set to prevent inadvertently running queries without a defined LIMIT, which may incur high infrastructure costs.&#x20;

To set a LIMIT, click the drop-down arrow next to the Run button and select the desired limit.

The LIMIT options are:

1. NO LIMIT: The query will run till all results are available.
2. LIMIT 10: The query will stop executing after the first 10 results are available.
3. LIMIT 100: The query will stop executing after the first 100 results are available.
4. LIMIT 1000: The query will stop executing after the first 1000 results are available.

{% hint style="info" %}
The Query Editor will display only the first 10,000 results. To access more than 10,000 rows use an [external connector.](https://docs.e6data.com/product-documentation/~/revisions/W5MExJCuvHiG1ioEcgOy/connectors-and-drivers)
{% endhint %}

### Select Catalog&#x20;

Select from the list of attached catalogs, which should be used.

### Select Database

Select from the list of databases inside the selected catalog.

### Select Cluster

Set the cluster that should be used to execute queries.&#x20;

### Format Query

Click the **<|>** (Format Query) button to beautify the SQL query in the currently active tab.

### Save Query

You can save a query for future use by clicking the **Save** button.

## SQL Query Editor

The SQL query text should be entered in the SQL Query Editor.

### Selectively Run Queries

Although multiple queries can be written in the same tab, if a user wants to run only one query, simply place the cursor on the line containing the query (before the `:`), prior to clicking **Run**.

If the cursor is on the last line of the SQL Query Editor, only the last query will be run.

Queries can also be commented out using standard SQL syntax `--` (single-line comments) or `/* */` (multi-line comments).

### Auto-Completion

As you type a query, the SQL editor suggests commands and functions, suggesting various ways to finish the command or function you've started. To select a proposal, hit the Tab key to accept it, or keep typing to dismiss the dialogue window.

### Find & Replace

The Find & Replace feature can search or replace strings that match a pattern in the query text.

#### Open Find & Replace

Press **CMD + F** (MacOS) or **CTRL + F** (Windows) to bring up the search dialog.

#### Find

* Type the string to search for in the **Search for...** field.
* The search will start highlighting matches when the first character is entered.
* Use the **<** and **>** buttons to toggle between appearances of the search string.
* Click the All button to highlight all appearances of the search string.

#### Replace & Replace All

* Click the **+** button to open the Replace field.
* Type the string to search for in the **Search for...** field.
* Enter the string that should replace the search string in the **Replace with...** field.
* Click **Replace** to replace only the current selected instance of the search string, or click **All** to replace all instances.

#### Regular Expression (RegExp) Search

* Click the **.\*** button to enable the RegExp search feature.
* Enter the regular expression to search for in the **Search for...** field.

#### Case-sensitive Search

* Click the **Aa** button to toggle on case sensitivity in search.

#### Whole Word Search

* Click the **\b** button to toggle on Whole Word Search, this will return only complete matches to the search string.

#### Search in Selection

* Click the **S** button to toggle on Search in Selection which only searches within the lines selected by the user.

<figure><img src="https://3484040590-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeVBYKZm1xFKFFVzS0lRJ%2Fuploads%2FSuVDpmcJcWjXgZwSw1Lx%2FScreenshot%202023-12-26%20at%2012.20.34%20PM.png?alt=media&#x26;token=ca90120f-2023-412e-bc93-5039288230a3" alt=""><figcaption><p>Find &#x26; Replace Feature</p></figcaption></figure>

### Error Highlighting&#x20;

Error highlighting helps identify and rectify errors in the queries. In case of any error, the line or query paragraph containing the error will be highlighted in the query editor.
