Query Editor window

The Query Editor allows you to add or edit your SQL code, change the Query name, or delete a Query. In this article, we will describe all the features of the Query Editor.

To open it, go to the menu and select Extensions > OWOX BI BigQuery Reports > Add a new report or Edit current report as shown below:

00.png

Then in the opened Extension panel, specify your GCP project.

The next step depends on your specific purpose:

  • Creating a new Query: in the Query selector choose '+ Add new query...' item.
    01.png
  • Editing your Query: click on the "Edit" icon from the right side of the Query title to open the Query Editor window.
    02.png

Here you will see the Query Editor window:

03nnnew.png

 

Query title

To change the Query title use text input as shown below:

04.png

 

Revision history

Each change to the SQL code will be saved as a new version of the Query. You can view all versions in the 'Revision History' selector.

05.png

Choose one of the previous versions to view SQL code:

06.png

You can only view and copy the SQL code from previous versions.

07.png

Click the 'Back to current version' button to see the current version of the Query code.

 

SQL code  editor with autosuggestions

In the Query editor, you could press Ctrl+Space (or Command (⌘)+Space) to get auto-suggestions in your code.

It will provide hints for:

  1. for projects, datasets, and tables, as in [my-project:dataset1.tableName]
    • projects (after [ character)
    • datasets (after [ and : characters)
    • tables (after . character)
  2. table fields from tables referenced with brackets
  3. BigQuery clauses, functions, and operators. Learn more

 

The 'Limit' Option with Default Value for All New Reports

The default value for the 'Limit' Option in the Query Editor allows you to set a default value for the  'LIMIT' clause without hardcoding it into the SQL code. It works similarly to the SQL 'LIMIT' clause but allows you to easily change the limit value in the report without editing the SQL code.

Adjusting the 'Limit' Option From the Query Config

When this option is enabled, the default value (e.g., 200,000 rows) will be used in each new report based on the Query config. After running the Query, you will receive a report containing the maximum number of rows defined in the option from the Query config.

We recommend not hardcoding the SQL 'LIMIT' clause directly in your SQL code.

09.png

Instead, check the 'Limit' option and set the default value on your own for greater flexibility.

08.png

Adjusting the 'Limit' Value From the Report

Additionally, this number of rows will be displayed in the Extension panel in the 'Limit' section. This allows your colleagues and other managers to use your Query and adjust the 'Limit' option for their purposes without opening the Query Editor window.

10.png

In this case, the changed value for the 'Limit' option will be saved for this report only. Other reports based on the same Query will have their own values for the 'Limit' option.

Use cases

When you click the 'Run' button in the report, here's what happens:

  1. The SQL code is executed in BigQuery to get the initial result.
  2. If the Query 'Limit' option is enabled and the Report 'Limit' value hasn't been customized, the Query 'Limit' option is applied to this result.
  3. If the Report 'Limit' value has been customized in the Extension panel, that value is applied instead.

Let's see examples in the table below:

Use cases SQL 'LIMIT' clause Query 'Limit' option Report 'Limit' value Maximum number of rows in the resulted report
Use only the SQL 'LIMIT' clause 100 100 rows
Use only the Query 'Limit' option [RECOMENDED] 200 200 rows
Use only the Report 'Linit' value 100 100 rows
         
Use the SQL clause and the Query option 100 50 50 rows
Use the Query 'Limit' option and overwrite it with the Report 'Linit' value [RECOMENDED] 200 500 500 rows
         
All Limits have been applied and the SQL clause is the largest 100 50 25 25 rows
All Limits have been applied and the SQL clause is the smallest 25 50 100 25 rows
         
None applied Number of rows from the initial result from BigQuery

 

These examples show you two key rules:

  1. The customized Report 'Limit' value will always overwrite the Query 'Limit' option, whether increasing or decreasing the limit.
  2. If the SQL 'LIMIT' clause has the smallest value, you cannot increase it with the Query or Report 'Limit' values. However, you can decrease it.
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.