Function map_access

Source
fn map_access<'a>(
    map: MapRef<'a>,
    key: ScalarRefImpl<'_>,
) -> Result<Option<ScalarRefImpl<'a>>, ExprError>
Expand description

ยงExample

query T
select map_access(map_from_key_values(array[1,2,3], array[100,200,300]), 3);
----
300

query T
select map_access(map_from_key_values(array[1,2,3], array[100,200,300]), '3');
----
300

query error
select map_access(map_from_key_values(array[1,2,3], array[100,200,300]), 1.0);
----
db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
  1: Failed to bind expression: map_access(map_from_key_values(ARRAY[1, 2, 3], ARRAY[100, 200, 300]), 1.0)
  2: Bind error: Cannot access numeric in map(integer,integer)


query T
select map_access(map_from_key_values(array['a','b','c'], array[1,2,3]), 'a');
----
1

query T
select map_access(map_from_key_values(array['a','b','c'], array[1,2,3]), 'd');
----
NULL

query T
select map_access(map_from_key_values(array['a','b','c'], array[1,2,3]), null);
----
NULL