array_ndims The number of an array's dimensions. | array_ndims($a::anyarray)
=>
CAST(CASE WHEN cardinality($a) > 0 THEN length(regexp_extract(typeof($a), '^(array\()+')) / 6 END AS INTEGER)
| | | |
array_dims The text of an array's dimensions, such as [1:2][1:3]. | array_dims($a::anyarray)
=>
array_join(transform(sequence(1, CAST(CASE WHEN cardinality($a) > 0 THEN length(regexp_extract(typeof($a), '^(array\()+')) / 6 END AS INTEGER)), d -> '[1:' || CAST(CASE d WHEN 1 THEN json_array_length(CAST($a AS JSON)) WHEN 2 THEN json_array_length(json_extract(CAST($a AS JSON), '$[0]')) WHEN 3 THEN json_array_length(json_extract(json_extract(CAST($a AS JSON), '$[0]'), '$[0]')) WHEN 4 THEN json_array_length(json_extract(json_extract(json_extract(CAST($a AS JSON), '$[0]'), '$[0]'), '$[0]')) WHEN 5 THEN json_array_length(json_extract(json_extract(json_extract(json_extract(CAST($a AS JSON), '$[0]'), '$[0]'), '$[0]'), '$[0]')) WHEN 6 THEN json_array_length(json_extract(json_extract(json_extract(json_extract(json_extract(CAST($a AS JSON), '$[0]'), '$[0]'), '$[0]'), '$[0]'), '$[0]')) END AS VARCHAR) || ']'), '')
| | | |
array_lower The lower bound of a dimension: 1, as a list's index starts there. | array_lower($a::anyarray, $d::integer)
=>
CAST(CASE WHEN $d BETWEEN 1 AND CAST(CASE WHEN cardinality($a) > 0 THEN length(regexp_extract(typeof($a), '^(array\()+')) / 6 END AS INTEGER) THEN 1 END AS INTEGER)
| | | |
array_upper The upper bound of a dimension: its length. | array_upper($a::anyarray, $d::integer)
=>
CAST(CASE WHEN $d BETWEEN 1 AND CAST(CASE WHEN cardinality($a) > 0 THEN length(regexp_extract(typeof($a), '^(array\()+')) / 6 END AS INTEGER) THEN CASE $d WHEN 1 THEN json_array_length(CAST($a AS JSON)) WHEN 2 THEN json_array_length(json_extract(CAST($a AS JSON), '$[0]')) WHEN 3 THEN json_array_length(json_extract(json_extract(CAST($a AS JSON), '$[0]'), '$[0]')) WHEN 4 THEN json_array_length(json_extract(json_extract(json_extract(CAST($a AS JSON), '$[0]'), '$[0]'), '$[0]')) WHEN 5 THEN json_array_length(json_extract(json_extract(json_extract(json_extract(CAST($a AS JSON), '$[0]'), '$[0]'), '$[0]'), '$[0]')) WHEN 6 THEN json_array_length(json_extract(json_extract(json_extract(json_extract(json_extract(CAST($a AS JSON), '$[0]'), '$[0]'), '$[0]'), '$[0]'), '$[0]')) END END AS INTEGER)
| | | |
array_fill An array of a value repeated to the dimensions given. | array_fill($v::anyelement, $dims::integer[])
=>
CASE WHEN $dims IS NULL THEN fail('postgresql-error 22004: ' || 'dimension array or low bound array cannot be null' || ' <end of postgresql-error>') WHEN cardinality($dims) = 1 THEN repeat($v, $dims[1]) ELSE fail('postgresql-error 0A000: ' || 'array_fill does not read this value' || ' <end of postgresql-error>') END
array_fill($v::anyelement, $dims::integer[], $lower_bounds::integer[])
=>
CASE WHEN $dims IS NULL OR $lower_bounds IS NULL THEN fail('postgresql-error 22004: ' || 'dimension array or low bound array cannot be null' || ' <end of postgresql-error>') WHEN cardinality($dims) = 1 AND all_match($lower_bounds, _b -> _b = 1) THEN repeat($v, $dims[1]) ELSE fail('postgresql-error 0A000: ' || 'array_fill does not read this value' || ' <end of postgresql-error>') END
| - Only one dimension with a lower bound of 1: any other shape is refused.
0A000 array_fill does not read this value
| | |
array_positions The positions of every element equal to a value, a NULL equal to a NULL. | array_positions($a::anycompatiblearray, $v::anycompatible)
=>
CASE WHEN cardinality($a) = 0 THEN CAST(ARRAY[] AS ARRAY(INTEGER)) ELSE CAST(filter(sequence(1, cardinality($a)), _i -> $a[_i] IS NOT DISTINCT FROM $v) AS ARRAY(INTEGER)) END
| | | |
array_replace Each element equal to a value replaced by another, a NULL equal to a NULL. | array_replace($a::anycompatiblearray, $v::anycompatible, $w::anycompatible)
=>
transform($a, _x -> CASE WHEN _x IS NOT DISTINCT FROM $v THEN $w ELSE _x END)
| | | |
array_sample A number of an array's elements, chosen at random. | array_sample($a::anyarray, $n::integer)
=>
CASE WHEN $a IS NULL OR $n IS NULL THEN NULL WHEN $n < 0 OR $n > cardinality($a) THEN fail('postgresql-error 22023: ' || 'sample size must be between 0 and ' || CAST(cardinality($a) AS VARCHAR) || ' <end of postgresql-error>') ELSE slice(shuffle($a), 1, $n) END
| | | |
array_shuffle An array's elements in a random order. | array_shuffle($a::anyarray)
=>
shuffle($a)
| | | |
trim_array An array without its last elements. | trim_array($a::anyarray, $n::integer)
=>
CASE WHEN $a IS NULL OR $n IS NULL THEN NULL WHEN $n < 0 OR $n > cardinality($a) THEN fail('postgresql-error 2202E: ' || 'number of elements to trim must be between 0 and ' || CAST(cardinality($a) AS VARCHAR) || ' <end of postgresql-error>') ELSE slice($a, 1, cardinality($a) - $n) END
| | | |
generate_subscripts The subscripts of a dimension, as rows, in either order. | generate_subscripts($a::anyarray, $d::integer, $reverse::boolean)
=>
refused (its error is under the limitations)
| - Refused: generate_subscripts($a::anyarray, $d::integer, $reverse::boolean).
0A000 generate_subscripts() has no form on trino
| | |