Data connectivity & integrationPipeline Builder ExpressionsCast

Cast

Supported in: Batch, Streaming

Cast expression to given type.

Expression categories: Cast, Popular

Declared arguments

  • Expression - Expression to cast.
    Expression<AnyType>
  • Type - Type to cast to.
    Type<C>

Type variable bounds: C accepts AnyType

Output type: C

Examples

Example 1: Base case

Argument values:

  • Expression: a
  • Type: Array<String>
aOutput
[ 12.3, 20.1 ][ 12.3, 20.1 ]

Example 2: Base case

Argument values:

  • Expression: a
  • Type: String
aOutput
[ {
date: 2020-01-01,
foo: false,
time: 2020-10-01T00:00:01Z,
} ]
[{false, 2020-10-01 00:00:01, 2020-01-01}]

Example 3: Base case

Argument values:

  • Expression: a
  • Type: Array<Float>
aOutput
[ 12.3, 20.1 ][ 12.3, 20.1 ]

Example 4: Base case

Argument values:

  • Expression: a
  • Type: String
aOutput
[ true, false ][true, false]

Example 5: Base case

Description: Casting string to long Argument values:

  • Expression: 1234
  • Type: Long

Output: 1234


Example 6: Base case

Description: Casting long to string Argument values:

  • Expression: 1234
  • Type: String

Output: 1234


Example 7: Base case

Argument values:

  • Expression: a
  • Type: String
aOutput
truetrue
falsefalse
nullnull

Example 8: Base case

Argument values:

  • Expression: a
  • Type: Date
aOutput
2020-01-012020-01-01
nullnull

Example 9: Base case

Argument values:

  • Expression: a
  • Type: String
aOutput
{
 1 -> true,
 2 -> false,
}
{1 -> true, 2 -> false}

Example 10: Base case

Argument values:

  • Expression: a
  • Type: String
aOutput
[ [ true, false ], [ true ] ][[true, false], [true]]

Example 11: Base case

Argument values:

  • Expression: a
  • Type: String
aOutput
{
 foo -> {
 1 -> true,
 2 -> false,
},
}
{foo -> {1 -> true, 2 -> false}}

Example 12: Base case

Argument values:

  • Expression: a
  • Type: String
aOutput
{
a: {
bar: false,
foo: 1,
},
}
{{1, false}}

Example 13: Base case

Description: Casting string to decimal Argument values:

  • Expression: 1234
  • Type: Decimal(4, 0)

Output: 1234


Example 14: Base case

Argument values:

  • Expression: a
  • Type: Integer
aOutput
11
1.0null
nullnull

Example 15: Base case

Argument values:

  • Expression: a
  • Type: Long
aOutput
11
1.0null
nullnull

Example 16: Base case

Argument values:

  • Expression: a
  • Type: String
aOutput
{
bar: null,
foo: 1,
}
{1, null}

Example 17: Base case

Argument values:

  • Expression: a
  • Type: String
aOutput
{
bar: false,
foo: 1,
}
{1, false}

Example 18: Null case

Argument values:

  • Expression: a
  • Type: String
aOutput
[ true, null ][true, null]
nullnull

Example 19: Null case

Argument values:

  • Expression: a
  • Type: String
aOutput
{
 1 -> null,
 2 -> false,
}
{1 -> null, 2 -> false}

Example 20: Null case

Argument values:

  • Expression: a
  • Type: Date
aOutput
nullnull