Skip to content

Commit

Permalink
fix isvalid function in query data set
Browse files Browse the repository at this point in the history
  • Loading branch information
gmansueto committed Apr 6, 2023
1 parent 2f5d4f3 commit d7e4593
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions chapter_3/create_dataset/query.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SQL Query Data Set

Selecting the query option requires the BI developer to write an SQL statement to retrieve data.

Pay attention that the SQL dialect depends on the chosen data source. The SQL text must be written in the Query text area. Look at this SQL query example.
Remember that the SQL dialect depends on the data source that has been chosen. The SQL text must be written in the Query text area. Below a SQL query example.

.. code-block:: sql
:caption: SQL query example
Expand All @@ -14,7 +14,7 @@ Pay attention that the SQL dialect depends on the chosen data source. The SQL te
JOIN promotion p on s.promotion_id=p.promotion_id
GROUP BY p.media_type
It is also possible to dynamically change the original text of the query at runtime. This can be done by defining a script (Groovy or JavaScript) and associating it to the query. Click on the **Edit Script** section (see next figure) and the script editor will open. Here you can write the script. The base query is bounded to the execution context of the script (variable query) together with its parameters (variable parameters) and all the profile attributes of the user that executes the dataset (variable attributes).
It is also possible to dynamically change the original text of the query at runtime. This can be done by defining a script (Groovy or JavaScript) and associating it to the query. Click on the **Edit Script** section (see next figure) to open the script editor and write your script. The base query is bounded to the execution context of the script (variable query) together with its parameters (variable parameters) and all the profile attributes of the user that executes the dataset (variable attributes).

.. _scripteditingdataset:
.. figure:: media/image31.png
Expand All @@ -28,11 +28,11 @@ In the script below we use JavaScript to dynamically modify the ``FROM`` clause
:linenos:
if(isValid('year')) {
if( parameters.get('year') == 1997 ) {
if( parameters.get('year') == 1997 ) {
query = query.replace('FROM sales_fact_1998', 'FROM sales_fact_1997');
} else {
query = query; // do nothing
}
}
In the above example we use the function *isValid* to test if the parameter value contains a not null value.
In the above example we use the function *isValid* to test whether the parameter *year* contains a *null* value or not.

0 comments on commit d7e4593

Please sign in to comment.