Miscellaneous operators - 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
CAUTION:
This topic relates to Data360 Analyze Script which is the language that is used in some deprecated nodes. If you are looking for help configuring the Python-based nodes, see Python scripting.

evalIf

Allows conditional compilation of any statement or expression. The first argument must be a boolean literal, or a boolean expression, for example, "or", "not", "and", parenthesis "(",")". Logical operators are allowed, as are the "==" and "!=" comparators.

If it is true then the alternate is ignored and the consequent is processed, if it is false and an alternate is given, the converse happens. If it is false and no alternate is given, the evalIf statement is ignored.

The only restriction on using evalIf is that you cannot use it in a statement in a position where a literal parameter is expected. If used where an expression is expected, an evalIf statement must have a value - an expression parameter must be evaluated. The context of the evalIf statement "melts away" and is assumed by the executed statement or evaluated parameter. For instance, a statement that otherwise could only be used as a top-level statement may be used within a top-level evalIf.

To use the comma-notation (',') within emit, exclude, or rename statements in the context of an evalIf, the evalIf argument within which it is used must be wrapped in curly braces {}

Used in the following format, where consequent and alternate may be any (possibly invalid) statement or expression:

evalIf({true|false}, consequent, [alternate])

Examples

evalIf(true, {emit "foo" as "Bar"}, {emit "barry" as "mary"})

evalIf(true, abs(-1.7), "hi") # value: 1.7

evalIf(false, (this would (not) compile)) # OK - param structure ok

getSuccessReturnCode

Get the return value of the node, which will be returned if there is no node error.

Used in the following format:

getSuccessReturnCode()

The return value type is an integer.

logError

Logs an error message to the node’s error log with level and errorCode. If errorCode is omitted, "Lavastorm.script.userLoggedError" is assumed. If level is omitted, 2 (WARN) is assumed.

Used in the following format, where message must be a string, errorCode must be a string or an integer and level must be an integer:

logError(message, [level], [type])

The return value type is null.

Examples

logError("there was an error", 3, "myErrorCode.1234")

property

Returns the value of the property specified by propertyName. If the property does not exist, the default value is returned. If no default is specified, an error is thrown.

Used in the following format, where propertyName specifies the name of property to evaluate and default specifies a default value to return if the specified property is not set:

property(propertyName, [default])

The return value type is a string or a list.

Examples

property("ls.brain.server.port") # returns the value of ls.brain.server.port

# returns the value of ls.brain.server.port or 1234 if the property is not set. property("ls.brain.server.port", 1234)

"ls.brain.server.port".property() # returns the value of ls.brain.server.port

random

Returns a random integer less than high and greater than or equal to low. If low is omitted, 0 is assumed. If high is omitted, then 2^31 is assumed.

Used in the following format, where high specifies a ceiling for the returned value and low specifies a floor for the returned value:

random([high], [low])

The return value type is an integer.

Examples

random() # returns a random number

random(100,10) # returns a random number between 10 and 99, inclusive

reverse

Returns a reverse ordering of the specified value for use in a Sort (Deprecated) node. This means that if A <= value <= B by cmp ordering, then (reverse A) >= (reverse value) >= (reverse B) will also be true by cmp ordering. Can be used with sort to do reverse sorting. Note that this does not reverse the order of elements within a list. Rather, if the value parameter is a list, this allows for reverse sorting of each of the elements of the list, see the following examples.

Used in the following format, where value can be any value:

reverse(value)

value.reverse()

The return value type is the same as the parameter.

Examples

Consider the following input to a Sort (Deprecated) node: id:int,name:string 5,name5 5,name6 6,name6 2,name2 0,name0 1,name1 1,name0 Then in the Sort (Deprecated) node, if the CompareOrderExpr is set to the following: reverse(list('id', 'name'))This tells the node to sort the records, based on descending "id", then descending "name". The output of the node will be: id:int,name:string 6,name6 5,name6 5,name5 2,name2 1,name1 1,name0 0,name0

setSuccessReturnCode

Set the return value of the node which will be returned if the node does not error. This allows for downstream halting or clock halting.

Note: Using this mechanism to prevent downstream nodes from running will not work correctly in streaming mode. This is because in streaming mode, the downstream nodes start execution as soon as possible, rather than waiting for the predecessor nodes to complete. This means that by the time the setSuccessReturnCode has been set by the node, the downstream nodes that it is trying to prevent from running will have already started execution. In order to prevent this from happening, set that node to never be run in streaming mode.

The following steps will ensure that the node is never streamed:

  • Create a new boolean parameter on the node (call it "Streamable").
  • Set the Runtime Property Name of the parameter to "ls.brain.node.streamable".
  • Set that parameter to false.
  • If you are creating a library node, this parameter should then be hidden so users will not modify it and get incorrect behavior.

Some common return values:

0

All nodes wired to the output and output clock will execute normally.

-1

The node errors; no connected nodes execute on either output or output clock.

100

Signal to any nodes wired to this node's output event pin to change to the rescheduled state, without preserving any data on the output.

101-116

Signal to any nodes wired to this node's output event pin to change to the rescheduled state. The data on the 1st to 16th output will be preserved (for example, return code 102 will preserve the data on the 2nd output, 113 will preserve the data on the 13th output, and so on).

Used in the following format, where code must be an integer:

setSuccessReturnCode(code)

The return value type is null.

typeCode

Returns the type code of the evaluated expression.

Used in the following format, where expr can be any valid Script expression:

typeCode(expr)

expr.typeCode()

The return value type is type code.

Examples

type-name((typeCode('TN')) # return "string" type-name('TN'.typeCode()) # return "string"

typeName

Returns the string name of the type-code given.

Used in the following format, where type-code must be a type code, such as is returned by type:

typeName(type-code)

type-code.typeName()

The return value type is a string.

Examples

typeName((typeCode('TN')) # return "string" typeName('TN'.typeCode()) # return "string"

unicode

Takes a unicode string and returns it, or takes a string and converts it to a unicode string (and converts any appropriate unicode escapes), and returns it.

Used in the following format, where string can be any string:

unicode(string)

string.unicode()

Examples

unicode("abcd") # return abcd (in unicode) "abcd".unicode() # return abcd (in unicode)