BRAINscript to Python - Data360_Analyze - Latest

Data360 Analyze Server Help

Product type
Software
Portfolio
Verify
Product family
Data360
Product
Data360 Analyze
Version
Latest
Language
English
Product name
Data360 Analyze
Title
Data360 Analyze Server Help
Copyright
2024
First publish date
2016
Last updated
2024-11-28
Published on
2024-11-28T15:26:57.181000

In LAE, many common tasks required you to use script to configure a node. In Data360 Analyze, a number of these tasks can now be completed by using one of the script-free nodes, for example the Aggregate, Sort, Split andFilter nodes.

Take the following example of BRAINscript in an LAE Filter node:

emit *where 'type' == "primary" and 'color' != "Red"

This means, output all records where the value of the type field is "primary" and the value of the color field is not "Red".

In the Data360 Analyze Filter node, this can be configured using the UI grid, for example:

Tip: The Data360 Analyze Transform node has the same functionality as the LAE Filter node, but the underlying code is Python rather than BRAINscript. The Data360 Analyze Filter node is a new script-free node that allows you to easily filter data records.

For advanced use cases, you can use Python script to further tailor nodes. It is worth noting the following differences between BRAINscript and Python:

Null handling

One general difference between BRAINscript and Python is the handling of NULL values ("null" in BRAINscript, and "Null" in Data360 Analyze):

In BRAINscript, null + 10 returns a value of 10. In Python, this type of expression would cause an error, so you would need to state explicitly what to do with the Null value, for example:

if inputs[0]['inputField'] is Null:
    outputs[0]['outputField'] = 10
else:
    outputs[0]['outputField'] = 10 + inputs[0]['inputField']
Tip: The Calculate Fields node provides an option to specify a default value for field types that are referenced in an expression.

Configuring metadata

When using BRAINscript in nodes such as the Filter node, the metadata for output fields was implicitly defined when the node was compiled in BRE for execution. In Data360 Analyze, output metadata must be explicitly defined in the ConfigureFields property of the Transform node (and similar nodes). The ConfigureFields script is executed before any input records are processed. The ConfigureFields script can also be used to import Python modules into the execution environment, retrieve node property values and to set / initialize variable values prior to execution of records. The ProcessRecords script is executed once for each input record.

Input and output field references

In the Python-based nodes, you can use the following input and output field references:

out1 += in1

or

outputs[0] += inputs[0]

The outputs[0] += inputs[0] format uses the output / input pin index rather than the pin's name, so the script will still operate if the output pin name is subsequently changed.

For examples of how to configure the Python-based nodes, see:

If you are still using deprecated nodes in your graphs while you begin to transition to use the new Python-based nodes, it is important to be aware of a number of BRAINscript changes in Data360 Analyze compared to LAE, see BRAINscript changes.