Create Flow Parameter
At the flow level, you can define flow parameters to reference in your recipes. A flow parameter is a (Variable) value or a set of enumerated values (Selector type).
Note
Flow parameters apply to recipe steps only.
To flow parameters and parameters of other types, you can apply override values at the flow level through the same interface. Details are below.
For more information on flow parameters, see Overview of Parameterization.
Limitations
Flow parameters are of String data type.
Tip
You can wrap flow parameter references in your transformations with one of the
PARSE
functions. See "Examples" below.Flow parameters are converted to constants in macros. Use of the macro in other recipes results in the constant value being applied.
Limitations on usage
A flow parameter cannot be used in the following transformation steps or fields.
Transformations:
Rename columns: Cannot use a flow parameter as a new column name.
The
as
clause when creating a New formula transformation.
Create Parameter
Steps:
Open the flow where you wish to apply the flow parameter.
From the Flow View context menu, select Parameters.
In the Manage Parameters dialog, click the Parameters tab.
Click Add parameter.
Enter a Name for your parameter.
Note
Name values are case-sensitive. After saving a flow parameter, its name cannot be changed.
(optional) Specify a user-friendly Description value.
For Type, select the type of parameter. See below.
Variable type parameter
Variable type parameters are single values that can be one of the following formats:
Format | Example |
---|---|
String | Here is my String value. |
Alteryx patterns | Any string of letters: `{letter}+` |
regular expression | Any string of letters: /[a-zA-z]+/ |
Additional steps:
Enter a default value for this parameter.
Note
Input Values are evaluated as String type.
Click Save.
The parameter is available for use in any recipe in your flow. See "Use Parameter."
Selector type parameter
Selector type parameters are lists of one or more permitted values.
Additional steps:
Under Choices, enter a value.
Tip
The first value that you add is the default value.
Click Add.
Repeat the above steps until all permitted values have been added.
Click Save.
The parameter is available for use in any recipe in your flow. See "Use Parameter."
Parameter Names
Parameter names can contain alphanumeric characters and spaces. in the following table, you can see how parameter names must be referenced in recipe steps.
Parameter name | Valid references | Notes |
---|---|---|
paramRegion | $paramRegion ${paramRegion} | Both references are valid. |
param Region | ${param Region} | Note If the parameter name contains a space, the curly brackets are required. As a matter of habit, you might want to use the curly brackets for all parameter references. This syntax also helps to distinguish your named parameters from metadata references, which are fixed. See Source Metadata References. |
Apply Parameter Override
Note
Parameter overrides that were defined in a pre-Release 7.1 version of the software now appear in the Overrides tab.
You can apply overrides to all parameter types, including flow parameters, at the flow level. An overridden value applies to all references of the parameter within the flow.
Note
You can apply override values for any parameter of any type that is referenced in the flow: dataset parameters, flow parameters, and object parameters.
Note
For selector type flow parameters, the override value must be a value from the defined list of values.
Upstream parameter values: Parameter values can be inherited from upstream recipes and datasets.
Note
Override values applied in a downstream flow are applied to the upstream flow when its objects are invoked for purposes of generating data for use in the downstream flow.
Downstream parameter values: Downstream flows receive parameter values, default or overridden, from upstream flows. These values can be overridden at the flow level.
Steps:
Open the flow where you wish to apply the flow parameter.
From the Flow View context menu, select Manage parameters.....
In the Manage Parameters dialog, click the Overrides tab.
Click Add override.
Select the parameter to override from the drop-down list.
Set the override value for this flow. Click Save.
Click Save.
This override value is applied to all references to the parameter in the flow.
Tip
Through Flow View, overrides can also be applied to the recipe parameters that are included when flow tasks are executed as part of a plan.
Override Evaluation
Override values can be applied in multiple locations. Parameter values are evaluated in the following order of precedence (highest to lowest):
Overrides at run-time in the Run Job page.
Overrides at the flow level.
Default values for the flow.
Inherited values from upstream flows.
For more information, see Overview of Parameterization.
Use Parameter
In your recipe step, you can add references to your flow parameter in the following format:
${MyRecipeParameter}
In a recipe, flow parameters can be applied to:
Function parameters
Replacements for String values
Examples
Below are examples of how to use flow parameters.
Note
When a parameter value is displayed in a column, the column type in the data grid may be correctly inferring the type to your desired data type. However, the underlying type is still String type. To convert the underlying type, you must use one of the PARSE
functions on your String values.
Variable type example - Integer parameter
Instead of segmenting the data by named time zone values, suppose your data is segmented by regions, which are numeric in number. Your flow parameter definition could look like the following:
Setting | Value | Notes |
---|---|---|
Name | paramRegionId | Note the more appropriate name. |
Value | 0 | In this case, there is no region identifier value |
To use this flow parameter as an integer, you must reference it wrapped in the PARSEINT
function, which evaluates the input value against the Integer data type:
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | PARSEINT(${paramregionId}) |
Parameter: New column name | paramRegionId |
In the column histogram for the paramRegionId
column, you can verify that the value 0
is present. Set an override outside at the flow level to insert a different value in the column.
Variable type example - Date parameter
Suppose you need to be able to pass a date into the execution of a recipe. If no date is passed in, then the current time is used. The variable is declared as follows:
Instead of segmenting the data by named time zone values, suppose your data is segmented by regions, which are numeric in number. Your flow parameter definition could look like the following:
Setting | Value | Notes |
---|---|---|
Name | paramDate | Note the more appropriate name. |
Value | In this case, the value is left empty to be overridden as needed in the application with the current timestamp. You should decide on the expected values for this parameter, as you must apply them to:
It may be easier to insert the format string here as the default value. For example: yyyy-mm-dd HH:MM:SS |
You can use the following to insert the parameter value into your dataset. Note that the value is initially inserted as a String value, so the PARSEDATE function is used as a wrapper:
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | PARSEDATE(${paramDate},['yyyy-mm-dd HH:MM:SS']) |
Parameter: New column name | paramDate |
If the inserted value is empty or null, you can insert the current timestamp:
Tip
You could also overwrite invalid values in the following manner. However, that may mask problems with your inserted values.
Transformation Name |
|
---|---|
Parameter: Columns | execDate |
Parameter: Formula | IF((execDate == '') || ISNULL(execDate), NOW('UTC'), execDate) |
In the above, the value in execDate
is tested to see if it is either:
empty
null
If so, the output of the NOW function is written. By default, this function returns the timestamp value at UTC time.
If there is a valid value, then it is written back to the column.
You can use the following to extract the time value from the parsed date param:
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | DATEFORMAT(execDate, 'HH:MM:SS') |
Parameter: New column name | Time |
Since this value is not the parameter value specifically, the column name was listed simply as Time
.
Variable type example - parameter with range of values
Suppose you need to create a parameter that can contain any two-digit value from 0 to 99. To do so, you create a flow parameter of variable type, using a Wrangle as the value:
`{digit}{digit}`
The above matches two-digit values only. It does not match single-digit values. To expand the pattern to also match single digit values, you can use this one:
`({digit}|{digit}{digit})`
Note how the value is specified using backticks (
`
), which are used to indicate a Wrangle .The vertical bars are delimiters to separate the values, when they are processed within the application.
This parameter now accepts the following values:
0-9 00-99
Selector type example - parameter with multiple values
Suppose you wish to create a flow parameter that can contain one of multiple values for color. Typically, you must track these values through an array, such as the following containing a set of colors:
["red","white","blue","black"]
Using a selector type of flow parameter, you can specify these values as choices in your permitted values list for the $myColors
flow parameter:
red white blue black
In this scenario, red
is the default value.
Within your recipe, you can test for the presence of a parameter value. In the following transformation, a value of true
is set in the new column isBlue
if the value of $myColors
is blue
:
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | F($myColors == "blue",true,false) |
Parameter: New column name | 'isBlue' |
Tip
When you reference a selector type flow parameter in a transformation step, you are presented the set of accepted values from which you apply the preferred one.
Apply Parameter Override via API
When you run a job via the APIs, you can apply parameter overrides to the following parameter types:
dataset parameters
output parmeters
flow parameters
For more information, see API Task - Run Job.