Map contains key

Supported in: Batch, Faster, Streaming

Returns true if the map contains the key. Returns null if the map or the key is null.

Expression categories: Boolean, Map

Declared arguments

  • Key: Key to look for in the map.
    Expression<K>
  • Map: Map expression.
    Expression<Map<K, AnyType>>

Type variable bounds: K accepts ComparableType

Output type: Boolean

Examples

Example 1: Base case

Argument values:

  • Key: [ 1 ]
  • Map: {
     [ 1 ] -> Foo,
    }

Output: true


Example 2: Base case

Argument values:

  • Key: 2
  • Map: {
     1 -> 10,
     2 -> 20,
    }

Output: true


Example 3: Base case

Argument values:

  • Key: Foo
  • Map: {
     Bar -> World,
     Foo -> Hello,
    }

Output: true


Example 4: Base case

Argument values:

  • Key: Foo
  • Map: {
     Bar -> World,
    }

Output: false


Example 5: Null case

Argument values:

  • Key: key
  • Map: map
mapkeyOutput
nullnullnull
{
 Foo -> Hello,
}
nullnull
nullFoonull

Example 6: Null case

Argument values:

  • Key: key
  • Map: map
mapkeyOutput
{
 Foo -> null,
}
Footrue