Skip to content

Query Editor

The query editor is the top card of a workspace. It holds the workspace's datastore, its SQL mode, and its SQL, and it runs that SQL. Under the SQL, it can format the query or save it as a computed table or computed file. Everything you type is saved with the workspace as you go.

The Editor Header

The header runs across the top of the editor, from left to right:

Control What it does
Datastore button Shows the workspace's datastore and lets you pick another one.
Editor context Shows where the SQL reads from.
+N Lists the other datastores on the same connection. Appears only when there are some.
SQL badge Names where the SQL runs and its dialect, such as Snowflake • SQL or Qualytics • Spark SQL. Click it to pick where the SQL runs. See SQL Badge.
Run Runs the SQL. While a query runs, it turns into Stop .
Minimize editor Folds the editor up under its header.

Datastore Button

The datastore button names the workspace's datastore. Click it to pick another one: the menu has a Search datastores field and groups the datastores as Recent (up to five), Also readable from this workspace (the others on the same connection), and Other datastores. Picking a datastore changes the workspace's datastore, and the SQL stays as it is.

On a datastore's Explore tab, the button is locked to that datastore. See Datastore and Container Tabs.

SQL Badge

The badge next to Run shows the logo and name of where the SQL runs, then its dialect: the datastore's engine with SQL (for example, Snowflake • SQL), or Qualytics • Spark SQL. Click it to open a menu with both options:

Option Description in the menu
The datastore's engine with SQL, such as Snowflake • SQL Runs on the datastore
Qualytics • Spark SQL Runs in Qualytics, reads computed tables and fields too

The current option carries a check mark. Picking the other one switches the workspace's SQL mode. See SQL Modes and Switch the SQL Mode.

A file datastore runs in Qualytics only, so its badge shows Qualytics • Spark SQL with no menu, and its tooltip reads Runs in Qualytics. On a narrow editor card, the badge shows the logo alone.

Editor Context

The Editor context button opens a card with the workspace's Datastore, Database, and Schema, and one line on how the SQL names tables:

  • In the datastore's mode: Table names on their own are read from <database.schema>.
  • In Qualytics mode: Spark SQL reads this datastore's containers by name.

Datastores on the Same Connection

When other datastores share the workspace's connection, a +N button appears next to the datastore button, where N is how many. Its tooltip reads N datastores share this connection. The menu lists them under Datastores that share the same connection. Click one to insert its prefix (its schema, or its database and schema) at the cursor, followed by a dot, or drag it into your SQL.

The list holds only the datastores where you have the Author or Editor team permission, since those are the only ones your query can read. It is empty in Qualytics mode, which reads the workspace's own datastore alone. See Read Another Datastore.

What Run Sends

Run sends the part of the SQL you point at, so an editor can hold several queries side by side:

What you have in the editor What runs Button label
Selected text The selection alone Run selection
Several statements, nothing selected The statement under the cursor Run
One statement, nothing selected The whole SQL Run
A minimized editor The whole SQL Run

Statements are separated by ;. A semicolon inside a string, a comment, or a quoted name does not end a statement. When the cursor sits on a blank line or right after a ;, Run picks the statement that starts later on the same line, otherwise the one before the cursor.

A query runs one statement at a time. When a selection, or the SQL of a minimized editor, holds several statements, the run is refused with Run one query at a time.

The tooltip of the button says what it will do: Run, or Run only the selected SQL when there is a selection, with the keyboard shortcut next to it. If something keeps the query from running, such as a missing team permission, the button is disabled and its tooltip gives the reason.

To run part of a query, see Run Part of a Query.

Gutter Marks

The gutter next to the line numbers shows what Run sends and what ran last:

  • A colored bar marks the lines that Run will send: the selected lines, or the lines of the statement under the cursor.
  • A check mark sits on the first line of the SQL that ran last. It goes away once you change that text.

A selection tints only its own text. Spaces and tabs inside a selection show as dots and arrows, so you can see exactly what runs.

Under the Editor

The line under the SQL holds a hint on the left and the SQL's own actions on the right:

  • The hint names what the editor expects: Any valid <engine> query in the datastore's mode, or Any Spark SQL query over this datastore's containers in Qualytics mode. On a narrow card it stays on one line and ends in an ellipsis before the buttons.
  • Format formats the SQL. See Format.
  • Save as computed table , or Save as computed file on a file datastore, saves the query as a computed asset. See Save as Computed Table and Save as Computed File.

When the editor card is narrow, these buttons show their icons only, and their tooltips still name them.

Keyboard Shortcuts

Shortcut Action
Cmd+EnterCtrl+Enter Run the selection, the statement under the cursor, or the whole SQL.
Ctrl+Space Open the autocomplete list.
Shift+Option+FShift+Alt+F Format the SQL.
Esc Close the autocomplete list. With no list open, leave the editor.

Autocomplete

Suggestions appear on their own after a short pause while you type, and Ctrl+Space opens them at any time. They do not appear inside strings or comments. Matching is loose, so a few letters of a name are enough.

The list offers:

  • Tables: the tables of the workspace's datastore by name, and the tables of the other datastores on the connection behind their prefix. Picking a schema keeps the list open, so you can pick one of its tables next.
  • Columns: the columns of the tables in the query's FROM.
  • Keywords and functions of the mode's SQL. A highlighted function shows its signature and a short description under the list.

Keywords and functions follow the datastore's engine. Amazon Athena, BigQuery, Databricks, Hive, MySQL, MariaDB, Oracle, PostgreSQL, TimescaleDB, Presto, Amazon Redshift, Snowflake, Teradata, Trino, SQL Server, Microsoft Fabric, and Synapse get their own functions. Other engines get keywords only. In Qualytics mode, the list holds the Spark SQL functions that Qualytics mode allows.

The list leaves out what a read-only query cannot use: statements that write or change the database, administration functions, and functions that are refused. Suggestions are a help only. Whether a query may run is decided when you run it. See Read-Only Rules.

In the datastore's mode, the list leaves out computed tables and computed files, which only Qualytics reads. In Qualytics mode, it lists them, but not computed joins.

Format

The Format button under the editor, at its right, reformats the whole SQL so it is easier to read. It formats in the datastore's SQL dialect, or in Spark SQL in Qualytics mode. If the SQL cannot be read, nothing changes and an error message appears: Could not format this SQL. See Format the SQL.

Stop

While a query runs, Run turns into Stop , and the running row in the results card has a round Stop the query button too. Either one ends the run in Explore:

  • The results card shows Query stopped with Run it again to see its rows.
  • The run is recorded in History with the outcome Stopped.
  • Stop works even before the first rows arrive.

Stop ends the run in Explore only. It does not promise that the datastore stops its own work on the query at once. See Stop a Query.

Save as Computed Table

The Save as computed table button under the editor, at its right, opens the computed table form, with your query already filled in. The query it saves is the same one Run would send (the selection, else the statement under the cursor, else the whole SQL), without a closing semicolon. Once the form is saved, a success message appears: Computed table created. Qualytics profiles it next.

Its tooltip reads Save the SQL as a computed table. The button is:

  • Disabled in Qualytics mode, with the tooltip A computed table runs on the datastore, in its own SQL. Switch to <engine> to save this query as one.
  • Disabled while the editor is empty.
  • Hidden on a file datastore, where Save as computed file takes its place. See Save as Computed File.

Creating the computed table follows the usual computed table rules and permissions. See Computed Tables and Save a Query as a Computed Table.

Save as Computed File

On a file datastore, the Save as computed file button under the editor, at its right, opens the Add Computed File form with your query already filled in as its Query. Its tooltip reads Save the Spark SQL as a computed file. As with a computed table, the query it saves is the one Run would send, without a closing semicolon. Once the form is saved, a success message appears: Computed file created. Qualytics profiles it next.

A computed file is defined by one Spark SQL query over one file of the datastore: the form's hint reads Any valid Spark SQL query over one file of this datastore, and a query that reads more than one is refused. Preview in the form shows the first rows before you save. The button is disabled while the editor is empty.

Creating the computed file follows the usual computed file rules and permissions. See Computed Files and Save a Query as a Computed File.

Minimize the Editor

Minimize editor folds the editor up under its header, which leaves more room for the results. The SQL then shows on one line in the header. Click that line, or Expand editor , to open the editor again. The text and the cursor stay where they were.

A minimized editor ignores the selection and the cursor, so Run sends the whole SQL.

Drag from Assets

You can drag a datastore, a table, or a field from the Assets panel into the editor. The drop writes the name where it lands, in the way the query needs it:

What you drag What the drop writes
A field The field's name.
A table of the workspace's datastore The table's name.
A table of another datastore on the connection The table's name behind its prefix, such as sales.orders.
A datastore Its prefix.

Names are quoted when the SQL dialect needs it, for example a name with spaces or capital letters. In Qualytics mode, items of other datastores write nothing, since the query reads its own datastore only.

The context menu of an item in Assets also has Insert into SQL , which writes the same text at the cursor. See Assets.


See Also