OceanBase AI Database supports the MAP data type, which is used to store unordered key-value pairs. A MAP consists of keys and their corresponding values. This data type allows you to easily manage unordered key-value pairs, such as {a:1, b:2, c:3}. It is very useful in scenarios such as saving configuration options, user attributes, and product information.
Currently, MAP primarily implements the definition (DDL) and manipulation (DML) of mapping data. You can construct a map in two ways: using a mapping expression or by building it from strings. Additionally, two expressions, map_keys and map_values, are provided to extract key or value arrays from the map, facilitating data processing and analysis.
The following table describes the data types that can be mapped to a key in OceanBase AI Database:
- Integer types:
TINYINT,SMALLINT,INT/INTEGER, andBIGINT, which support theUNSIGNEDmodifier. - Floating-point types:
FLOATandDOUBLE. - String type:
VARCHAR.
The following table describes the data types that can be used as values.
- Integer types:
TINYINT,SMALLINT,INT/INTEGER, andBIGINT, which support theUNSIGNEDmodifier. - Floating-point types:
FLOATandDOUBLE. - String type:
VARCHAR. - Array type:
ARRAY.
The instructions and limitations are as follows:
- The operators
<,>,>=, and<=for comparing sizes are not supported. - The
ORDER BY,GROUP BY,MIN,MAX,AVG, andSUMaggregate operations are not supported. - If the value is an array, the maximum depth of nested arrays is 5. Since a map itself counts as one level, the total depth limit is 6, meaning the value can contain up to five levels of nested arrays.
In addition to providing data type mappings, functions are also available for data mapping. For more information, see Overview of mapping functions.