Data type functions - Cloud

Talend Data Shaping Language Reference Guide

Version
Cloud
Language
English (United States)
Product
Talend Cloud
Module
Data Shaping Language
Content
Design and Development

The following functions can be used to check values and data types, and to convert a value to another data type.

Function Description Arguments Example
hasValue Returns true if the input element is not null or not an empty string. Input element. Expression: hasValue("Hello World!")

Result: true

isEmpty Returns true if the input element is null or an empty string. Input element. Expression: isEmpty("")

Result: true

isNull Returns true if the input element is null. Input element. Expression: isNull(null)

Result: true

isBoolean Returns true if the input element is a Boolean data type. Input element. Expression: isBoolean(2 < 3)

Result: true

isBytes Returns true if the input element is a bytes data type. Input element. Expression: isBytes(0xFFFF)

Result: true

isDate Returns true if the input element is a date data type. Input element. Expression: isDate("2021-04-01")

Result: false

isDateTime Returns true if the input element is a datetime data type. Input element. Expression: isDateTime(getCurrentDateTime())

Result: true

isDecimal Returns true if the input element is a decimal data type. Input element. Expression: isDecimal(3.5)

Result: true

isDouble Returns true if the input element is a double data type. Input element. Expression: isDouble(5e+3)

Result: true

isFloat Returns true if the input element is a float data type. Input element. Expression: isFloat(3.5F)

Result: true

isInteger Returns true if the input element is an integer data type. Input element. Expression: isInteger(42)

Result: true

isLong Returns true if the input element is a long data type. Input element. Expression: isLong(42L)

Result: true

isNumber Returns true if the input element is a decimal, double, float, integer or long data type. Input element. Expression: isNumber(5e+3)

Result: true

isString Returns true if the argument is a string data type. Input element. Expression: isString("Hello World!")

Result: true

isTime Returns true if the input element is a time data type. Input element. Expression: isTime("12:34")

Result: false

toBoolean Converts a value to a Boolean. If the input element is a bytes array, the function returns true if at least one byte in the array is not 0. If the input element is a string, the function returns true if the string is "true", regardless of its case, and false for any other string. Input element. Expression: toBoolean(0x0000007B)

Result: true

toBytes Converts a value to a Bytes data type. Input element. Expression: toBytes(123)

Result: 0x0000007B

toDate Converts a value to a date. Input element. Expression: toDate("2021-04-21")

Result: 2021-04-21

toDateTime Converts a value to a datetime.
  1. String or date to convert.
  2. Optional: If the first argument is a date, you can specify a time as a string or time data type. Otherwise the local time 00:00 is used.
Expression: toDateTime("2021-04-21")

Result: 2021-04-21T00:00Z

toDecimal Converts a value to a decimal.
  1. Input element.
  2. Optional: Scale of the decimal as a string or numeric data type.
  3. Optional: Rounding mode for the decimal. It can be the name of the mode as a string or the corresponding integer constant:
    • "UP" or 0
    • "DOWN" or 1
    • "CEILING" or 2
    • "FLOOR" or 3
    • "HALF_UP" or 4
    • "HALF_DOWN" or 5
    • "HALF_EVEN" or 6
    • "UNNECESSARY" or 7
    The default value is "FLOOR". For more information about rounding modes, see the Oracle documentation.
Expression: toDecimal(531.256986, 2, "DOWN")

Result: 531.25

toDouble Converts a value to a double. Input element. Expression: toDouble(500)

Result: 500.0

toFloat Converts a value to a float. Input element. Expression: toFloat(5e+3)

Result: 5000.0

toInteger Converts a value to an integer. If the input value is a number with a decimal point, the function keeps the value without the decimal part. Input element. Expression: toInteger(12.95)

Result: 12

toLong Converts a value to a long. Input element. Expression: toLong(12.03e+20)

Result: 9223372036854775807

toString Converts an element to a string.
  1. Input element.
  2. Optional: Date/time format if the input element is a temporal data type.
Expression: toString(123456L)

Result: "123456"

toTime Converts a value to a time. Input element. Expression: toTime("12:34")

Result: 12:34