[ 
https://issues.apache.org/jira/browse/FLINK-32262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hanyu Zheng updated FLINK-32262:
--------------------------------
    Description: 
Implement the {{map_entries}} method to transform a map into an array of 
key-value structs.

Description: The current implementation of the {{map_entries}} method in the 
Flink library does not provide a way to transform a map into an array of 
key-value structs. This enhancement aims to add this functionality, allowing 
users to convert a map into a more structured format for further processing.

Syntax:

 
{code:java}
 

map_entries[map: Map[K, V]] -> Array[Struct<K, V>] {code}
{{}}
Arguments:
 * {{{}map{}}}: The input map to be transformed.

Returns: An array of key-value structs obtained from the input map. Each struct 
consists of two fields: {{key}} of type {{K}} and {{value}} of type {{{}V{}}}.

Examples:
 # Transforming a map into key-value structs:

 
 
{code:java}
input_map = [1: 'apple', 2: 'banana', 3: 'cherry'] 
 map_entries[input_map] 
 Output: [{'key': 1, 'value': 'apple'}, {'key': 2, 'value': 'banana'}, {'key': 
3, 'value': 'cherry'}]{code}
 # Handling an empty map:

{code:java}
empty_map = {} 
map_entries[empty_map]
Output: []{code}
See also:

spark:[https://spark.apache.org/docs/latest/api/sql/index.html#map_entries]

  was:
map_entries
map_entries(map) - Returns an unordered array of all entries in the given map.

Examples:
{code:java}
> SELECT map_entries(map(1, 'a', 2, 'b'));
 [{"key":1,"value":"a"},{"key":2,"value":"b"}] {code}
 

See also:

spark:[https://spark.apache.org/docs/latest/api/sql/index.html#map_entries]


> Add MAP_ENTRIES support in SQL & Table API
> ------------------------------------------
>
>                 Key: FLINK-32262
>                 URL: https://issues.apache.org/jira/browse/FLINK-32262
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / Planner
>    Affects Versions: 1.18.0
>            Reporter: Bonnie Varghese
>            Assignee: Hanyu Zheng
>            Priority: Major
>             Fix For: 1.18.0
>
>
> Implement the {{map_entries}} method to transform a map into an array of 
> key-value structs.
> Description: The current implementation of the {{map_entries}} method in the 
> Flink library does not provide a way to transform a map into an array of 
> key-value structs. This enhancement aims to add this functionality, allowing 
> users to convert a map into a more structured format for further processing.
> Syntax:
>  
> {code:java}
>  
> map_entries[map: Map[K, V]] -> Array[Struct<K, V>] {code}
> {{}}
> Arguments:
>  * {{{}map{}}}: The input map to be transformed.
> Returns: An array of key-value structs obtained from the input map. Each 
> struct consists of two fields: {{key}} of type {{K}} and {{value}} of type 
> {{{}V{}}}.
> Examples:
>  # Transforming a map into key-value structs:
>  
>  
> {code:java}
> input_map = [1: 'apple', 2: 'banana', 3: 'cherry'] 
>  map_entries[input_map] 
>  Output: [{'key': 1, 'value': 'apple'}, {'key': 2, 'value': 'banana'}, 
> {'key': 3, 'value': 'cherry'}]{code}
>  # Handling an empty map:
> {code:java}
> empty_map = {} 
> map_entries[empty_map]
> Output: []{code}
> See also:
> spark:[https://spark.apache.org/docs/latest/api/sql/index.html#map_entries]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to