Class StructFunctions
- java.lang.Object
-
- org.apache.flink.cdc.runtime.functions.impl.StructFunctions
-
public class StructFunctions extends Object
Built-in functions for collection and struct data types.These functions support accessing elements from collections (ARRAY, MAP), structured data types (ROW), and semi-structured data types (VARIANT).
-
-
Constructor Summary
Constructors Constructor Description StructFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<Object>array(Object... elements)Creates an ARRAY value.static BooleanarrayContains(List<?> array, Object value)Returns whether an ARRAY contains the given value.static IntegerarrayPosition(List<?> array, Object value)Returns the 1-based position of a value in an ARRAY, or 0 if it is not found.static Integercardinality(List<?> array)Returns the number of elements in an ARRAY.static Integercardinality(Map<?,?> map)Returns the number of entries in a MAP.static <T> Telement(List<T> array)Returns the only element of an ARRAY.static <T> TitemAccess(List<T> array, Integer index)Accesses an element from an ARRAY by index (1-based, SQL standard).static <K,V>
VitemAccess(Map<K,V> map, K key)Accesses a value from a MAP by key.static VariantitemAccess(Variant variant, Integer index)Accesses an element from a VARIANT array by index (1-based, SQL standard).static VariantitemAccess(Variant variant, String fieldName)Accesses a field from a VARIANT object by field name.static Map<Object,Object>map(Object... keyValues)Creates a MAP value from alternating keys and values.static List<Object>row(Object... fields)Creates a ROW value.
-
-
-
Method Detail
-
map
public static Map<Object,Object> map(Object... keyValues)
Creates a MAP value from alternating keys and values.
-
cardinality
public static Integer cardinality(List<?> array)
Returns the number of elements in an ARRAY.
-
cardinality
public static Integer cardinality(Map<?,?> map)
Returns the number of entries in a MAP.
-
arrayContains
public static Boolean arrayContains(List<?> array, Object value)
Returns whether an ARRAY contains the given value.
-
arrayPosition
public static Integer arrayPosition(List<?> array, Object value)
Returns the 1-based position of a value in an ARRAY, or 0 if it is not found.
-
element
public static <T> T element(List<T> array)
Returns the only element of an ARRAY.
-
itemAccess
public static <T> T itemAccess(List<T> array, Integer index)
Accesses an element from an ARRAY by index (1-based, SQL standard).array[1] returns the first element.
- Type Parameters:
T- the element type of the array- Parameters:
array- the array to accessindex- the 1-based index- Returns:
- the element at the specified index, or null if index is out of bounds
-
itemAccess
public static <K,V> V itemAccess(Map<K,V> map, K key)
Accesses a value from a MAP by key.map['key'] returns the value for 'key'.
- Type Parameters:
K- the key type of the mapV- the value type of the map- Parameters:
map- the map to accesskey- the key to look up- Returns:
- the value for the specified key, or null if not found
-
itemAccess
public static Variant itemAccess(Variant variant, Integer index)
Accesses an element from a VARIANT array by index (1-based, SQL standard).variant[1] returns the first element.
- Parameters:
variant- the variant (must be an array) to accessindex- the 1-based index- Returns:
- the element at the specified index as a Variant, or null if the variant is not an array or index is out of bounds
-
itemAccess
public static Variant itemAccess(Variant variant, String fieldName)
Accesses a field from a VARIANT object by field name.variant['fieldName'] returns the value of the specified field.
- Parameters:
variant- the variant (must be an object) to accessfieldName- the name of the field to look up- Returns:
- the field value as a Variant, or null if the variant is not an object or field is not found
-
-