DSQL map features
Talend Data Mapper provides a few features in DSQL maps on top of the existing Data Shaping Language functions.
You can find the documentation for the other Data Shaping Language functions in the Talend Data Shaping Language Reference Guide.
@emit
The @emit annotation is placed before an assignment statement in a SELECT block. It allows you to conditionally produce output fields based on the evaluation of a condition expression.
If the condition evaluates to true, the output field is produced. If the condition evaluates to false, the field is omitted from the output.
Syntax
@emit ( condition = <expression> )
<field_name> = <value>Arguments
The @emit annotation requires one mandatory argument:
- condition: A boolean expression that determines whether the field is produced.
Example
In this example, the rating field is included in the output only when it has a value:
FROM customer
SELECT {
name = name,
@emit ( condition = hasValue(rating) )
rating = rating
}This produces output records with the name field always present, but the rating field only appears when the customer has a rating value.
getContextVariable
You can use the getContextVariable function to call a context variable defined in your Talend Studio Job.
Arguments
Name of the context variable.
getMapProperty
You can use the getMapProperty function to retrieve the value of an execution property. This function is particularly useful in Camel Routes (including the cMap component) to access exchange inbound headers.
Arguments
Name of the execution property as a string literal.
Examples
getMapProperty('propertyName')If the specified property does not exist, the function returns null.
java:call
You can use the java:call feature to call a Java method. This can be used to call beans and routines available in Talend Studio for example.
Arguments
Java parameters.
- Call to a static method: java:call(<class_name>, <method_name>, <arguments>)
- Call to a non-static method: java:call(java:new(<class_name>, <constructor_arguments>), <method_name>, <arguments>)
- Call to a non-static method of a Java object returned by another method of a Java object: java:call(java:call(<class_name>, <method_name>, <arguments>), <method_name>, <arguments>)