Parameter
Create dynamic notebooks and reports.
Last updated
Create dynamic notebooks and reports.
Last updated
By using the Parameter defined in Notebooks, you can make Notebooks and Reports dynamic and interactive. This allows you to control embedded SQL through parameters without directly accessing SQL, and obtain tailored outputs as needed.
Make notebooks and reports dynamic:
Make Notebooks and Reports dynamic and interactive.
Various types of parameters:
Choose from various data types and associated input widgets.
Two types of scopes:
Choose parameters used across the Notebook or on a page-by-page basis.
Parameter overwrite:
Fine-grained control by overwriting parameters when chaining SQL.
Once you create a parameter, you can reference it within an SQL block in the Notebook using the syntax /param/{param_name}
.
For example, if you create a parameter named param1
as a string parameter and input the value val1
, the SQL:
will be converted to:
Simple string input field.
Format:
Enclosed in single quotes('
) in SQL.
Ex: Converted to 'val1'
If empty:
''
A field for entering multiple strings.
Format:
Enclosed in single quotes('
) in SQL.
Ex: Converted to 'val1', 'val2'
If empty:
''
A dropdown to select a single string value.
Source options:
Fixed list or table values or query results.
Format:
Enclosed in single quotes('
) in SQL.
If empty:
''
A dropdown for selecting multiple string values.
Source options:
Fixed list or table values or query results.
Format:
Enclosed in single quotes('
) in SQL.
Ex: Converted to 'val1', 'val2'
If empty:
''
A simple numeric input field.
Options:
min, max, steps (intervals)
If empty:
0
A dropdown for selecting a single number.
Source options:
Fixed list or table values or query results.
If empty:
0
A simple date input field. Allows selection from a calendar or by entering a date.
Options:
Unit:
Date, Week, Month, Year
Start day of week (First day displayed in calendar):
Sun, Mon, Tue, Wed, Thu, Fri, Sat
Relative valid range:
Days before today: Dates earlier than this limit become unselectable. For example, entering '90' will make dates earlier than 90 days unselectable.
Days after today: Dates beyond this limit become unselectable. For example, entering 0
will make dates from the next day onwards unselectable, and entering -1
will make dates from today onwards unselectable.
Absolute valid range:
Lower date: Dates before this specified date become unselectable.
Upper date: Dates after this specified date become unselectable.
Format:
Expanded in yyyy-MM-dd
format with quotes('
) in SQL.
Ex: Converted to '2024-01-01'
Specifies a start and end date as a pair.
Options:
Identical to those for Date Input (DATE)
Syntax for SQL reference:
Start Date: /param/param_name.StartDate
End Date: /param/param_name.EndDate
Simple Boolean checkbox.
Format:
Expanded as TRUE/FALSE in SQL.
The parameter system handles SQL injection protection and value escaping based on the parameter's context. This mechanism not only provides security but also enables dynamic SQL identifier generation through quoted parameters.
Parameters are automatically wrapped in single quotes.
Both single quotes and double quotes within values are escaped with backslash.
Inside double quotes or single quotes:
Both double quotes and single quotes are escaped with backslash
Inside backticks:
Only backticks are escaped with backslash
Other quotes remain unchanged
Regular context: Dates are formatted as 'YYYY-MM-DD'
When used in table names with BigQuery: Dates are formatted as 'YYYYMMDD' (without hyphens)
Quote escaping rules apply as with string parameters
This context-aware processing enables both secure value handling and dynamic identifier generation (table names, column names):
By placing parameters within quotes, you can safely generate SQL identifiers like table or column names.
Select parameters support three types of source options to generate selectable values:
Used when you want to select from fixed values.
Settings:
CSV Text:
Define options in CSV text format, with each item on a new line. To specify a display name, include it on the same line with a comma (,).
For example:
Used when you want to generate selectable values from a specific field in a table.
Settings:
Source Table: Select the table from which values are drawn.
Value Field: Specify the field to be used as the option value.
Label Field: Specify the field to be used as the display label.
Used when you want to generate options based on the results of a specified SQL query.
Settings:
Connection:
Choose the database connection to use for the query.
SQL:
Input the SQL query that returns the option values. If the query returns multiple columns, the first column will be used as the option value, and the second column (if available) as the display label.
SQL queries for options are executed frequently, so avoid using slow or resource-intensive queries for optimal performance.
Parameters can be created from two types of scopes:
Notebook common
Parameters shared across all pages in the notebook
Values are retained on each page
Page specific
Parameters specific to each page
Notebook common parameters can be used, for example, when you want to control components on a Grid Page, such as charts created from SQL on a Doc Page, with the same parameter.
Page specific parameters can be used, for example, when you do not want the parameter to affect anything outside of the specific page.
When chaining SQL, you may want to cut off the parameter dependencies. For example:
Setting unique parameters for each page when chaining SQL across pages.
Using different parameters for different SQLs derived from the same base SQL.
Parameters can be overwritten on a popup displayed by hovering over the referenced SQL in SQL Blocks.
Parameter values and execution results in Notebooks are synchronized among users. However, using Notebook Version and Reports ensure that changes to parameter values and execution results are not synchronized between users, reflecting changes only to the user who changes the values.
For more details, please refer to the Notebook Version.