In this Page
Table of Contents | ||||
---|---|---|---|---|
|
Overview
Note |
---|
This functionality is not supported in Spark mode. |
...
You can create a library file using your favorite text editor to build the expression. You can make an object literal containing all the values and functions to use.
Example 1
Code Block | ||
---|---|---|
| ||
{ prefix: 'test', prefixer: x => this.prefix + x } |
Placing this content in a file named "helpers.expr" and uploading it to your project will make it available for use in Pipelines.
Info |
---|
|
To import a library into a Pipeline:
...
If you would like to explicitly set the name of the library in the lib variable, you can fill out the "As" column in the Expression Libraries table in the Pipeline Properties dialog.
Example 2
The following expression library can be used to generate the start date and end date of the previous month in multiple formats.
Code Block |
---|
{ // Convert the given Date-with-time object into a Date with only the year and month to_month_date: x => Date.UTC(x.getFullYear(), x.getMonth() - 1), // Get the start of the previous month based on the given date or the current time if no parameters are given prev_month_start: x => this.to_month_date((x || Date.now()).minusMonths(1)), // Get the end time of the previous month based on the given date or the current time if no parameters are given prev_month_end: x => this.to_month_date((x || Date.now()).withDayOfMonth(1)).minusSeconds(1), prev_month_start_string: x => this.prev_month_start(x).toString().split('T')[0], prev_month_end_string: x => this.prev_month_end(x).toString().split('T')[0], prev_month_start_epoch: x => this.prev_month_start(x).getTime(), prev_month_end_epoch: x => this.prev_month_end(x).getTime() } |
...
Code Block |
---|
{ "num": 2, "str": "Hello, World" } |
Example
In this example, we have a set of status updates from certain account types. For example, let us assume the following JSON:
...