PQL editor overview
Note
You're currently viewing a topic describing a Studio feature using the general availability feature set. This feature is also available in the new Studio experience, however both the design and the way it works may be different to what you see described here.
For more information about the new Studio experience, see: Studio
The PQL editor enables you to run studio analysis reports, with the following supported features:
1) Code Auto-completion
Get context-sensitive code suggestions as you type or when triggered with Ctrl+Space. To toggle the details window for a completion item, navigate upon it with Up/Down arrow buttons and hit Ctrl+Space again. To apply the completion, hit Enter. Some of the types of completion items are Function, Column, Table, Keyword.
For Function completions, the details window contains brief documentation and when the completion is applied, the corresponding code snippet with parameter placeholders is inserted.
2) Code Diagnostics
With code diagnostics, you can spot the PQL syntax errors quickly. As you type, automatically Errors are highlighted with red color whereas warnings are highlighted with yellow color. Warnings do not indicate a broken PQL query but point out deprecated/discouraged usages in the language. Hover over the diagnostic annotations to learn details about them. Use a mini-map on the right-hand-side of the editor to quickly identify lines with syntax errors.
3) Code Formatting
A PQL query is formatted by hitting the keyboard shortcut Ctrl+Shift+I. If the query is short, formatting may yield a result where it's fitted into a single line. The formatting strategy tries to place 120 characters in a line before attempting to push the query contents to a new line. If the query is valid but incomplete, formatting is still possible. In certain cases where there are many syntax errors, formatting cannot be performed. In these cases document does not change even if Ctrl+Shift+I is hit.
4) Code Folding
Some symbols/keywords in PQL define a block of code that can be folded. For example a pair of parentheses or CASE and END. When these symbols occur in different lines, the new PQL editor can fold those lines when the arrow buttons next to the corresponding line number are clicked. Typically formatting your query helps to find out about the folding blocks. This feature is useful when one wants to focus on a particular fragment of the code as an unimportant query can be folded away. Another use case is to explore a large PQL query.
In the command palette (triggered with F1) there are a number of useful commands related to code folding: Fold all, Unfold all, etc.
5) Miscellaneous Features
Editor Commands
There are a variety of commands packed within the new PQL editor. The complete list can be displayed in the Command Palette that is triggered with F1. Some of the common keyboard shortcuts/commands improving productivity are:
Mini-map
Displayed on the right-hand side of the editor. Shows a zoomed-out version of the editor. Useful when navigating a long query.
Zoom in/out
Scroll your mouse wheel while holding the Ctrl button to increase/decrease the editor font size.
Copy/Paste with Style
Editor contents are copied as rich text instead of plain text. Therefore when pasted to another document/text editor that supports rich texts (for example Google Docs), style is retained.