Scalar


A scalar is the most atomic object considered by NBi. A scalar is equivalent to an atomic value. A scalar has a type that can be defined as text, numeric, dateTime or boolean. The default type of a scalar is text.

Supported types

Text

This is the most common type for a scalar. If no type is specified then this type is effectively used. The exact content of the cell is used during comparison. It means that values “10.0”, “010” and “10” are considered as different when using the type text. This is usually what you’ll use when specifying Key columns. Pay attention that the default comparison for this type is case-sensitive.

Numeric

To avoid comparison of textual content, you can use the numeric type. The content of the cell is first converted to a numeric (decimal) value using the international format (a dot to separate the decimal part). It means that values 10.0, 010 and 10 are considered as equal when using this type. This type is useful when you’ve Value columns.

Date and time

The content of the cell is first converted to a DateTime value using the international format (yyyy-mm-dd hh:mm:ss).

Boolean

The content of the cell is first converted to a boolean value. NBi understands “0” or “false” and “1” or “true” as boolean values.

Definitions

You’ve many options to define a scalar but not all of them are supported everywhere. Refer to the documentation of the different xml elements and attributes to know which kind of definition are supported where. Only the most common (and basic) options are enlisted here, others are detailled where they are available.

Literal

This is the most straightforward way to define a scalar, just input its value.

<parameter name="myParam">145</parameter>

Keep into account that the value should be castable to the type expected by the parameter. It means that dates should have the internaltional format and numerics should have a dot to separate the decimal parts.

Reference to a variable

The value of the scalar is identical the value of the variable. It could be a global-variable or an instance-variable.

<parameter name="myParam">@myVar</parameter>

Inline transformations

From time to time, you’ll need to use a variable and slightly transform it to get what you really want. Defining additional variables, supporting these transformations, has a negative impact on readiness of your test-suite. You can achieve the same result with inline transformations. The list of transformations supported is defined at this page.

Inline transformations make usage of a pipe | to list them. They are applied from left to right and the result of the previous evaluation is always the input of the next evaluation.

<parameter name="myParam">@myVar | dateTime-to-first-of-month</parameter>

In the case above, the variable @myVar will be transformed using the native transformation dateTime-to-first-of-month. If the variable @myVar is not a valid date, it will raise an exception.

Formatting

A text scalar can be dynamically evaluated based on one or several variables and some literal parts. To enable this feature, you must precede the scalar value by a tilt ~ and mix static parts of the filename with dynamic parts. The dynamic parts must be contained between curly braces {} and start by the variable’s name to consider.

<parameter name="myParam">~File_{@myYear}.csv</parameter>

Using the previous notation, if the value of myYear is 2018 then the filename File_2018.csv will be considered for loading the result-set.

A number of types support format strings, including numeric type (both standard and custom format strings), but also dateTime (both standard and custom format strings). This formatting must be specified after a column (:).

<parameter name="myParam">~File_{@myDate:yyyy}_{@myDate:MM}.csv</parameter>

Using the previous notation, if the value of myDate is 25th October 2018 then the filename File_2018_10.csv will be considered for loading the result-set.

Formatting and inline transformations

It’s possible to combine formatting and inline transformations. The following example will calculate the previous month and this value will be used during the formatting. Supposing the value of myDate is 25th October 2018 then the filename File_201809.csv will be considered for loading the following result-set.

<parameter name="myParam">~File_{@myDate | dateTime-to-previous-month:yyyyMM}.csv</parameter>

It’s also possible to apply an inline transformation to the result of a formatting operation. The following example will calculate the length of the formatted rendering of the variable myNumeric. Based on a value of 100.2, the rendering will be 100.20 and its length will be 6.

<parameter name="myParam">~{@myNumeric:##.00} | text-to-length</parameter>