[ https://issues.apache.org/jira/browse/FLINK-31098?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17689678#comment-17689678 ]
Sergey Nuyanzin edited comment on FLINK-31098 at 2/16/23 10:25 AM: ------------------------------------------------------------------- Do we really need {{ARRAY_SIZE}}? I'm asking because there is already existing {{CARDINALITY}} which also gives size of array or map and returns {{NULL}} for null input. I would rather suggest something like {{ARRAY_LENGTH}} from postgres which could return the size of the specified array dimension {noformat} array_length ( anyarray, integer ) → integer Returns the length of the requested array dimension. (Produces NULL instead of 0 for empty or missing array dimensions.) array_length(array[1,2,3], 1) → 3 array_length(array[]::int[], 1) → NULL array_length(array['text'], 2) → NULL {noformat} https://www.postgresql.org/docs/current/functions-array.html#ARRAY-FUNCTIONS-TABLE was (Author: sergey nuyanzin): Do we really need {{ARRAY_SIZE}}? I'm asking because there is already existing {{CARDINALITY}} which also gives size of array or map and returns {{NULL}} for null input. > Add ARRAY_SIZE supported in SQL & Table API > ------------------------------------------- > > Key: FLINK-31098 > URL: https://issues.apache.org/jira/browse/FLINK-31098 > Project: Flink > Issue Type: New Feature > Components: Table SQL / Planner > Affects Versions: 1.18.0 > Reporter: jackylau > Assignee: jackylau > Priority: Major > Labels: pull-request-available > Fix For: 1.18.0 > > > Returns the size of an array. > Syntax: > array_size(array) > Arguments: > array: An ARRAY to be handled. > Returns: > An ARRAY. If value is NULL, the result is NULL. > Examples: > {code:sql} > SELECT array_size(ARRAY[1, 2, 3, 2, 1]); > -- 5 > SELECT array_size(ARRAY[1, NULL, 1]); > -- 3 > {code} > See also > spark [https://spark.apache.org/docs/latest/api/sql/index.html#array_size] > snowflake https://docs.snowflake.com/en/sql-reference/functions/array_size > h4. -- This message was sent by Atlassian Jira (v8.20.10#820010)