Workspace¶
Workspace provides an easy to use interface for users to run DDL or SQL.
Access to Workspace¶
The Workspace automatically authenticates as the logged in user, so there's no need to provide any credentials. By default all users should have access to Workspace. If that's not the case, see here on how to enable access.
Mode Options¶
Workspace provides two different modes: Okera mode and Presto mode.
When you access Workspace from the Okera UI, by default, it is in Okera mode. When you access Workspace from the dataset details in a crawler or a database, by default, it is in Presto mode.
Okera Mode¶
Used to issue SQL commands to the Okera platform to programmatically perform tasks such as registering data or creating policies. To write multiple commands at once, make sure the queries are separated by semicolons.
For example:
CREATE ROLE role_one;
CREATE ROLE role_two;
Okera is compatible with most HiveQL SQL commands. To understand all supported SQL, visit Supported SQL.
Presto Mode¶
In this mode the queries will be run against Presto engine and the SQL used should be Presto-compatible. Presto allows using aggregation in queries and provides built-in functions for complex queries.
Note that Presto uses double quotes (") for escaping reserved keywords in SQL statements. For convenience, backticks (`) can be used to escape reserved keywords (as is used in Okera SQL) and will be changed to double quotes transparently, for example:
SELECT * FROM `okera`.`sample`;
will be converted into
SELECT * FROM "okera"."sample";
Features of Workspace¶
Recent Command History¶
To the right of the SQL input, you will see a list of your recent commands. Clicking on one re-stages the command in the input box ready to be used again.
History¶
By default the output box will only show the output from the most recent command. If the number of commands run is more than 1, the Show history
button will show up. In Show History mode, all recent queries with their output are shown in the output box. The history only shows the last 30 commands. It is saved while navigating through the app, but will be lost on page reload.
Rerun or re-stage query¶
Next to previously run queries in the output (if there is more than one query shown), you will see two icons.
- Rerun the query
- Re-stage the query (load it into query box)
Workspace Row Limit¶
In Okera mode you can use Row Limit input to apply limit to the output.
In Presto mode Row Limit will be disabled, since Presto allows using LIMIT
keyword natively in SQL.
Note that Workspace's terminal will only render MAX 100 rows per query.
Prompt if you try to leave the page¶
Warning
If you leave the page and have a pending query, you will be prompted whether the query should be cancelled or continue to run.
Formatting Queries Using Keyboard Shortcuts¶
The editor in workspace supports the following keyboard keys and key combinations for formatting your queries and other SQL statements:
Tab Stops - To insert a tab stop in a line (in 4 character intervals), use the TAB
key:
- If the cursor is at the beginning of the line, 4 blank spaces are inserted.
- If the cursor is in the line, enough blank spaces are added to reach the next tab stop.
Comments - To comment out a line (or multiple lines), place the cursor anywhere in the line (or highlight the desired lines), hold down the CMD
(Mac) or CTRL
(Windows) key and type a forward slash, /
Multiple Cursors - To add multiple cursors in the input box, hold down the CMD
(Mac) or CTRL
(Windows) key and click in each new location using the mouse left button or the touchpad.
Select Text Area - To select a text area, hold down the OPTION
(Mac) or ALT
(Windows) key. The cursor turns into a crosshair.
Click and drag using the mouse left button or the touchpad.
Run Commands - To run queries you can either click the Run button or hold down CMD
(Mac) or CTRL
(Windows) key and press the return
key.