Class MapFunctions


  • public class MapFunctions
    extends Object
    Provides implementations of common Map functions. These functions can be combined to construct more complex expressions.

    These functions accept map objects as input parameters.

    • Constructor Detail

      • MapFunctions

        public MapFunctions()
    • Method Detail

      • mapGet

        public static ScalarValuedFunction mapGet​(String leftField,
                                                  String rightField)
        Builds an expression to get the value mapped to a key from specified field. The specified field must be of type Object and String respectively. The result will be of type Object. If the field value is null, the result is null.
        Parameters:
        leftField - the record field value on the left side of mapGet
        rightField - the record field value on the right side of mapGet
        Returns:
        a function evaluating the expression
      • mapGet

        public static ScalarValuedFunction mapGet​(String leftField,
                                                  ScalarValuedFunction rightExpr)
        Builds an expression to get the value mapped to a key from specified field. The specified field must be of type Object and String respectively. The result will be of type Object. If the field value is null, the result is null.
        Parameters:
        leftField - the record field value on the left side of mapGet
        rightExpr - the ScalarValuedFunction expression on the right side of mapGet
        Returns:
        a function evaluating the expression
      • mapGet

        public static ScalarValuedFunction mapGet​(Map<Object,​Object> leftValue,
                                                  String rightField)
        Builds an expression to get the value mapped to a key from specified constant. The specified field must be of type Object and String respectively. The result will be of type Object. If the constant value is null, the result is null.
        Parameters:
        leftValue - the constant value on the left side of mapGet
        rightField - the record field value on the right side of mapGet
        Returns:
        a function evaluating the expression
      • mapGet

        public static ScalarValuedFunction mapGet​(Map<Object,​Object> leftValue,
                                                  ScalarValuedFunction rightExpr)
        Builds an expression to get the value mapped to a key from specified constant. The specified field must be of type Object and String respectively. The result will be of type Object. If the constant value is null, the result is null.
        Parameters:
        leftValue - the constant value on the left side of mapGet
        rightExpr - the ScalarValuedFunction expression on the right side of mapGet
        Returns:
        a function evaluating the expression
      • mapGet

        public static ScalarValuedFunction mapGet​(ScalarValuedFunction leftExpr,
                                                  String rightField)
        Builds an expression to get the value mapped to a key from specified ScalarValuedFunction. The specified field must be of type Object and String respectively. The result will be of type Object. If an expression evaluates to null, the result is null.
        Parameters:
        leftExpr - the ScalarValuedFunction expression on the left side of mapGet
        rightField - the record field value on the right side of mapGet
        Returns:
        a function evaluating the expression
      • mapGet

        public static ScalarValuedFunction mapGet​(ScalarValuedFunction leftExpr,
                                                  ScalarValuedFunction rightExpr)
        Builds an expression to get the value mapped to a key from specified ScalarValuedFunction. The specified field must be of type Object and String respectively. The result will be of type Object. If an expression evaluates to null, the result is null.
        Parameters:
        leftExpr - the ScalarValuedFunction expression on the left side of mapGet
        rightExpr - the ScalarValuedFunction expression on the right side of mapGet
        Returns:
        a function evaluating the expression
      • mapSize

        public static ScalarValuedFunction mapSize​(String field)
        Builds an expression to get the number of kay-value mappings in the specified field. The specified field must be of type Object The result will be of type integer. If the field value is null, the result is null.
        Parameters:
        field - the record field value
        Returns:
        a function evaluating the expression
      • mapSize

        public static ScalarValuedFunction mapSize​(ScalarValuedFunction expr)
        Builds an expression to get the number of kay-value mappings in ScalarValuedFunction expression. The specified constant must be of type Object The result will be of type integer. If an expression evaluates to null, the result is null.
        Parameters:
        expr - the ScalarValuedFunction expression
        Returns:
        a function evaluating the expression
      • mapToString

        public static ScalarValuedFunction mapToString​(String field)
        Builds an expression to get the string representation of a specified field. The specified field must be of type Object The result will be of type String. If the field value is null, the result is null.
        Parameters:
        field - the record field value
        Returns:
        a function evaluating the expression
      • mapToString

        public static ScalarValuedFunction mapToString​(ScalarValuedFunction expr)
        Builds an expression to get the string representation of a ScalarValuedFunction. The specified expression must evaluate to Object The result will be of type String. If an expression evaluates to null, the result is null.
        Parameters:
        expr - the ScalarValuedFunction expression
        Returns:
        a function evaluating the expression
      • containsKey

        public static ScalarValuedFunction containsKey​(String leftField,
                                                       String rightField)
        Builds an expression to check if a field contains a mapping for the key specified by the other field. Operands must be of type Object and String. The result type is BOOLEAN. If the field representing a map is null, the result is null.
        Parameters:
        leftField - the record field value on the left side of containsKey
        rightField - the record field value on the right side of containsKey
        Returns:
        a function evaluating the expression
      • containsKey

        public static ScalarValuedFunction containsKey​(String leftField,
                                                       ScalarValuedFunction rightExpr)
        Builds an expression to check if a field contains a mapping for the key specified by an expression. Operands must be of type Object and String. The result type is BOOLEAN. If the field representing a map is null, the result is null.
        Parameters:
        leftField - the record field value on the left side of containsKey
        rightExpr - the ScalarValuedFunction expression on the right side of containsKey
        Returns:
        a function evaluating the expression
      • containsKey

        public static ScalarValuedFunction containsKey​(Map<Object,​Object> leftValue,
                                                       String rightField)
        Builds an expression to check if a constant contains a mapping for the key specified by the other field. Operands must be of type Object and String. The result type is BOOLEAN. If the constant representing a map is null, the result is null.
        Parameters:
        leftValue - the constant value on the left side of containsKey
        rightField - the record field value on the right side of containsKey
        Returns:
        a function evaluating the expression
      • containsKey

        public static ScalarValuedFunction containsKey​(Map<Object,​Object> leftValue,
                                                       ScalarValuedFunction rightExpr)
        Builds an expression to check if a constant contains a mapping for the key specified by an expression. Operands must evaluate to Object and String. The result type is BOOLEAN. If the constant representing a map is null, the result is null.
        Parameters:
        leftValue - the constant value on the left side of containsKey
        rightExpr - the ScalarValuedFunction expression on the right side of containsKey
        Returns:
        a function evaluating the expression
      • containsKey

        public static ScalarValuedFunction containsKey​(ScalarValuedFunction leftExpr,
                                                       String rightField)
        Builds an expression to check if an expression contains a mapping for the key specified by the other field. Operands must evaluate to Object and String. The result type is BOOLEAN. If an expression representing a map evaluates to null, the result is null.
        Parameters:
        leftExpr - the ScalarValuedFunction expression on the left side of containsKey
        rightField - the record field value on the right side of containsKey
        Returns:
        a function evaluating the expression
      • containsKey

        public static ScalarValuedFunction containsKey​(ScalarValuedFunction leftExpr,
                                                       ScalarValuedFunction rightExpr)
        Builds an expression to check if an expression contains a mapping for the key specified by the other expression. Operands must evaluate to Object and String. The result type is BOOLEAN. If an expression representing a map evaluates to null, the result is null.
        Parameters:
        leftExpr - the ScalarValuedFunction expression on the left side of containsKey
        rightExpr - the ScalarValuedFunction expression on the left side of containsKey
        Returns:
        a function evaluating the expression